Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-01

Frog game. OO-izing SDL. Replace record with class then Lazarus can't find .create or .free for class

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Pew piffle.the.cat

Hi All,

http://hotfile.com/dl/100225293/35136c1/frog_game.tar.gz.html

I am modernising the SDL unit by replacing all of the records with classes. This should avoid warnings.

basically all

whatever = record
   x : integer;
   // blah blah blah
end;

becomes

whatever = class
   public
     x : integer;
     // blah blah blah
end;

and then

var
   whatever1 : whatever;
begin
   // new(whatever1);
   // becomes
   whatever1 := whatever.create;
...
uFixedWidthFonts.pas(98,21) Error: Unknown record field identifier "CREATE"
uFixedWidthFonts.pas(177,17) Error: Operator is not overloaded
uFixedWidthFonts.pas(182,16) Error: Unknown record field identifier "FREE"
uFixedWidthFonts.pas(253) Fatal: There were 3 errors compiling module,
stopping

and Lazarus does not understand how to do a

whatever1.whatever.create;
nor a
whatever1.free;

Best Regards,
pew

Reply by email

Alberto Narduzzi
to Pew piffle.the.cat
Show quoted text 16 lines
I am modernising the SDL unit by replacing all of the records with classes. This should avoid warnings. and then var whatever1 : whatever; begin // new(whatever1); // becomes whatever1 := whatever.create; ... and Lazarus does not understand how to do a whatever1.whatever.create; nor a whatever1.free;

maybe because your classes don't descend from any other class that owns a "create" or "free" methods...

If you use classes, out of the top of my head, I could say that an instantiation, like

var C: MyRecordConvertedToClass;
...
C.X = 10;
C.Y = 20;

should be enough.

Otherwise, you had better define a base class, with constructor and destructor, overriding them as needed in every derived class.

Anyone correct me if I am wrong in this statement...

Cheers, A.

Reply by email