[fpc-pascal]RE: Defining Records on the fly:
Adam Victor Nazareth Brandizzi
qbyron at yahoo.com.br
Thu Feb 19 03:34:14 CET 2004
You can also define a function that returns the record you need:
function NewMyRec( X, Y : double ) : TMyRec;
begin
NewMyRec.x := X;
NewMyRec.y := Y;
end;
I think it's really better than declare a new variable and initialize it
by the code.
if CheckPoint(NewMyRec(1.2, 2.2)) then ...
Be well...
Jeff Pohlmeyer wrote:
>Since Free Pascal supports function overloading,
>you could do something like this:
>
>
>Function CheckPoint(X, Y:real): Boolean;
>Begin
> {Does something here..}
>end;
>
>
>Function CheckPoint(aPoint: tMyRec): Boolean;
>Begin
> Result:=CheckPoint(aPoint.X, aPoint.Y);
>end;
>
>
>// So you can use it either way:
>
>var
> MyRec:tMyRec;
>begin
> if CheckPoint(MyRec) then {do stuff};
> if CheckPoint(1.2, 2.2) then {do more stuff};
>end;
>
>
>
>
>>Here is why I was wondering why you couldn't, say I have this type:
>>Type tMyRec = Record X, Y : Real; End;
>>
>>And I have this function:
>>
>>Function CheckPoint(aPoint: tMyRec): Boolean;
>>Begin
>> {Does something here..}
>>end;
>>
>>begin
>> CheckPoint((X:1.2;Y:2.2));
>>end.
>>
>>
>
>
>__________________________________
>Do you Yahoo!?
>Yahoo! Mail SpamGuard - Read only the mail you want.
>http://antispam.yahoo.com/tools
>
>_______________________________________________
>fpc-pascal maillist - fpc-pascal at lists.freepascal.org
>http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
>
>
--
Adam Victor Nazareth Brandizzi
Estudante de Ciência da Computação - UnB
e-mails: qbyron at yahoo.com.br, adam at click21.com.br
ICQ: 168537710
Jaber: bardo0 (users.jabber.org)
More information about the fpc-pascal
mailing list