[simpits-tech] OT: Delphi Record problems
Stig Joergensen
simpits-tech@simpits.org
Sat, 21 Dec 2002 21:12:12 +0100
Thanks Erwin
I was thinking of this also - but that produces a new problem.... can
not load the file directly, but only one item at a time....
/Stig
-----Original Message-----
From: Erwin Neyt [mailto:rwntn@hvv.nl]
Sent: 21. december 2002 20:27
To: simpits-tech@simpits.org
Subject: RE: [simpits-tech] OT: Delphi Record problems
Stig,
You right about numbers being just a pointer.
And because of this the SizeOf any TMYRec instance will be always the
same.
I suggest you make TMyRec into a class and write a function to
increase/decrease the 'numbers' size.
TMyClass = class
type : integer;
size : integer;
name : array[0..7] of char
count : integer;
numbers : array of integer
state : integer;
procedure SetSize(NewSize: integer);
end;
implementation
procedure TMyClass.SetSize(NewSize: integer)
Begin
// alloc new memory for numbers
SetLength(numbers, NewSize);
size := NewSize;
End;
Now you can query MyClass.size to get the current size if the numbers
instance.
Hope this helps
Erwin.
> -----Original Message-----
> From: Stig Joergensen [mailto:stig.joergensen@clearsky.dk]
> Sent: zaterdag 21 december 2002 16:52
> To: simpits-tech@simpits.org
> Subject: [simpits-tech] OT: Delphi Record problems
>
>
> Sorry for the OT, but i have a problem i Delphi, and some of
> you might know the answer
>
>
>
>
> I have a problem with record that i for the life of me can
> not get a handle on:
>
> say i have a file that are organized like this
>
>
> 0000000100000001abcdefgh00000003111111112222222233333333000000
> 00........
> .
>
>
>
> i have create a record that match the above
>
> TMYRec = packed record
> type : integer;
> size : integer;
> name : array[0..7] of char
> count : integer;
> numbers : array of integer
> state : integer;
> ...
> ...
> ...
> end;
>
> myrec : TMyRec;
>
> so i set the size of "numbers" to the "count", one would hope that the
> sizeof(MyRec) would reflect the change, but this is not the
> case, which leaves me to beleave that the "numbers" is just a
> pointer....
>
> any idea how i can expand the "numbers" at runtime to reflect
> the content of the file?
>
> /Stig
>
>
>
> ------------------------ Yahoo! Groups Sponsor
> ---------------------~--> Get 128 Bit SSL Encryption!
> http://us.click.yahoo.com/CBxunD/vN2EAA/xGHJAA> /i7folB/TM
>
>
> --------------------------------------------------------------
> -------~->
>
> The Delphi Collection Web Site!
> http://www.delphicollection.com/public/index.s> html
>
> ---------------------------------------------------------------
> Unsubscribe:delphi-programming-unsubscribe@yahoogroups.com
> List owner:delphi-programming-owner@yahoogroups.com
> ---------------------------------------------------------------
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
> _______________________________________________
> Simpits-tech mailing list
> Simpits-tech@simpits.org
> http://www.simpits.org/mailman/listinfo/simpit> s-tech
> To
> unsubscribe, please see the instructions at the
> bottom of the above page. Thanks!
>
_______________________________________________
Simpits-tech mailing list
Simpits-tech@simpits.org
http://www.simpits.org/mailman/listinfo/simpits-tech
To unsubscribe, please see the instructions at the bottom of the above
page. Thanks!