I been appending code to a unit for a while, I dont know why i havnt thought
of this before, since it's reusable across my projects. I recently completed
a new unit with working read/write functions. Now I have a question. When my
code was in my mess of appendages, I wrote this structure to save memory
however when I stuck it into my new unit, it had memory leaks or whatever I
dont know, but it liked to fill in all the data to each element that I didnt
want it to. To fix this, I just removed the case statement. I am not sure
why, but using that case statement, even when I specificially allocated data
for only what I wanted, seemed to fill it into all the variables and with
the same values. Doing it without the case statement does what it supposed
to. LOL can some one tell me why my case statement caused the opposite of
what I wanted? (memory saving, not duplicating).
TSelData = record
seltype: TSelType;
vxsIdxArray,
faceIdxArray,
edgeArray: PIntegerArray;
nbrSelVxs,
nbrSelFaces,
nbrSelEdges: integer;
{case TSelType of
stVerts: (vxsIdxArray: PIntegerArray;
nbrSelVxs: integer);
stFaces: (faceIdxArray: PIntegerArray;
nbrSelFaces: integer);
stEdges: (edgeArray: PIntegerArray;
nbrSelEdges: integer);
}
end;
----- Original Message -----
From: "Mark Bracey" <[EMAIL PROTECTED]>
To: "Delphi-Talk Discussion List" <[email protected]>
Sent: Monday, October 10, 2005 5:40 PM
Subject: RE: writing binary to file
> Have you considered using objects instead?
>
> The persistence built into the VCL/Language could be just what you need.
>
>
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Richard R
> Sent: Monday, October 10, 2005 6:16 PM
> To: Delphi-Talk Discussion List
> Subject: Re: writing binary to file
>
>
> They only change if the user does something.
>
> ----- Original Message -----
> From: "Mark Bracey" <[EMAIL PROTECTED]>
> To: "Delphi-Talk Discussion List" <[email protected]>
> Sent: Monday, October 10, 2005 8:07 AM
> Subject: RE: writing binary to file
>
>
>> Are the pointers in
>>
>> TSPEObjs = record
>> nbrPEObjs: integer;
>> peObjs: PObjArray;
>> SelData: PSelDataArray;
>> end;
>>
>> fixed, or are they continuously changing (pointing to something else)
>> during
>> the course of your program's execution?
>>
>>
>> -----Original Message-----
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] Behalf Of Richard R
>> Sent: Monday, October 10, 2005 2:54 AM
>> To: 'Delphi-Talk Discussion List'
>> Subject: writing binary to file
>>
>>
>> Hello, I want to write a complex structure to a file. I am wondering how
>> I
>> should go about it. I am new to this sort of thing, and have found out
>> just
>> writing the pointer doesnt work. Do i need to write out each element in
>> the
>> structure to file or is there some way I can write the pointer so I can
>> also
>> load it into the structure.
>>
>> TObjArray = array[0..1] of Pointer;
>> PObjArray = ^TObjArray;
>>
>> TSelType = (
>> stNone,
>> stVerts,
>> stFaces,
>> stEdges
>> );
>>
>> TIntegerArray = array[0..1] of Integer;
>> PIntegerArray = ^TIntegerArray;
>>
>> TSelData = record
>> seltype: TSelType;
>> case TSelType of
>> stVerts: (vxsIdxArray: PIntegerArray;
>> nbrSelVxs: integer);
>> stFaces: (faceIdxArray: PIntegerArray;
>> nbrSelFaces: integer);
>> stEdges: ( edgeArray: PIntegerArray;
>> nbrSelEdges: integer );
>> end;
>>
>> TSelDataArray = array[0..1] of TSelData;
>> PSelDataArray = ^TSelDataArray;
>>
>> TSPEObjs = record
>> nbrPEObjs: integer;
>> peObjs: PObjArray;
>> SelData: PSelDataArray;
>> end;
>> PEObjs = ^TSPEObjs;
>>
>> You can see how complex this is. I'm thinking I need to write a custom
>> file
>> type using writeinteger and so forth, or perhaps there is a quicker way?
>> BTW
>> I just want to write the PEObjs to file, which is what i'm working with.
>> It
>> works very well in my program to control user selections on geometry.
>> __________________________________________________
>> Delphi-Talk mailing list -> [email protected]
>> http://www.elists.org/mailman/listinfo/delphi-talk
>>
>> __________________________________________________
>> Delphi-Talk mailing list -> [email protected]
>> http://www.elists.org/mailman/listinfo/delphi-talk
>>
> __________________________________________________
> Delphi-Talk mailing list -> [email protected]
> http://www.elists.org/mailman/listinfo/delphi-talk
>
> __________________________________________________
> Delphi-Talk mailing list -> [email protected]
> http://www.elists.org/mailman/listinfo/delphi-talk
>
__________________________________________________
Delphi-Talk mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi-talk