[fpc-pascal] allocating memory for records
Leonardo M. Ram�
martinrame at yahoo.com
Fri Jul 7 20:31:52 CEST 2006
You also can create an object an instantiate it in the initialization section of the unit an
finalize at the end, if you use this unit, the instance of the created object will not lose it's
value:
type
MyRec = class
public
a: integer; /* very clear */
b: string; /* not clear, how much bytes are needed? */
end;
var
myRecVar: MyRec;
initialization
myRecVar := MyRec.Create;
myRecVar.a := 10;
myRecVar.b := 'Hello World!';
finalization
myRecVar.Free;
--- Marc Santhoff <M.Santhoff at t-online.de> wrote:
> Am Freitag, den 07.07.2006, 10:09 -0700 schrieb Leonardo M. RamX:
> > Marc,
> > you don't need to allocate memory for records, you can us as follows:
> >
> > type
> > MyRec = record
> > a: integer; /* very clear */
> > b: string; /* not clear, how much bytes are needed? */
> > end;
> >
> > var
> > myRecVar: MyRec;
> >
> > begin
> > myRecVar.a := 10;
> > myRecVar.b := 'Hello World!';
> > end;
>
> Yes, I know. But in this case I definitely have to because a static
> variable disappears outside a function declaring it, so I need a
> solution that is robust and portable.
>
> But thank you anyways, a helping hand is always welcome.
>
> Marc
>
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
Leonardo M. Ramé
http://leonardorame.blogspot.com
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the fpc-pascal
mailing list