Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write an object to a File?

Status
Not open for further replies.

ahhchu

Programmer
Sep 19, 2001
38
US
Can an object be written to a file and then retrieved back into the object or do I have to break it down into appropriate fields in a record and write the record?

Thanks !
 
I found that using BLOCKWRITE and BLOCK READ on an untyped file seems to work. If it doesnt or causes problems I will put more information here..

f : file;
hFile : integer;
myUserApp : TUserApp;


AssignFile (f,'test');
ReWrite (f,1); //must specify size other wise io err 1784
myObject := TObject.Create;

BlockWrite (f,myObject,512);
 
myUserAppp : TUserApp

should be

myObject : TObject

oooops
 
Can write the block but the values dont come back properely.

AssignFile (f,'test');
Reset (f,1); //must specify size other wise io err 1784
myObject := TObject.Create;

BlockRead (f,myObject,512);

Any Ideas ? Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top