[fpc-pascal] Re: Procedures in records not supported :( Object variable required but might work ?

Skybuck Flying skybuck2000 at hotmail.com
Sat Feb 9 21:58:43 CET 2008


Hello,

This fpc example seems to do more or less the same as the Delphi static 
class/record procedure example.

Only extra requirement is to declare a object instance variable and use that 
to call the test routine.

Less ideal.

type
 TmyRecord = record
  A,B,C,D,E,F : integer;
 end;

 TmyObject = object
  A,B,C,D,E,F : integer;

  procedure Test;
 end;


procedure TmyObject.Test;
begin
 writeln( 'Hi' );
end;


var
 MyObject : TmyObject;

begin
 writeln( SizeOf(TmyRecord) );
 writeln( SizeOf(TmyObject) );

 // TmyObject.Test; // not allowed, does not compile

 MyObject.Test;

end.

Bye,
  Skybuck. 




More information about the fpc-pascal mailing list