{$mode objfpc} unit modul; interface type dir = (left, right, up, dn); T = object x, y: integer; //procedure print; end; (*procedure T.print; begin writeln('X: ', x, ' Y: ', y); end;*) const p: array[dir] of record s: string; px, py: integer; end = ( (s:'left' ; px:-1; py: 0), (s:'right'; px: 1; py: 0), (s:'up' ; px: 0; py:-1), (s:'dn' ; px: 0; py: 1) ); implementation operator := (const d: dir): T; begin with result do begin x := p[d].px; y := p[d].py; end; end; operator := (const s: string): T; var i: dir; begin result.x := 0; result.y := 0; for i := low(dir) to high(dir) do if p[i].s = s then with result do begin x := p[i].px; y := p[i].py; end; end; end.