Path: utzoo!utgpu!news-server.csri.toronto.edu!qucdn!spraggej Newsgroups: comp.lang.pascal Subject: Re: more fun things to do with files Organization: Queen's University at Kingston Date: Thursday, 16 Aug 1990 19:24:38 EDT From: John G. Spragge Message-ID: <90228.192439SPRAGGEJ@QUCDN.BITNET> References: <6789.26caaab3@jetson.uh.edu> Not that much of a problem, since you can save each data structure as a string of bytes. For example, consider the following: TYPE astruct = RECORD { one data structure } i : LONGINT; { and other good things... } END; bstruct = RECORD { another data structure } s : STRING [100]; { and anything else you want... } END; VAR fds : astruct; { first data structure } sds : bstruct; { second data structure } saver : FILE; { untyped file to save f and s } BEGIN fds.i := 100; sds.s := 'NO TYPE, BUT STILL SOME CLASS'); REWRITE (saver, 1); { saver is a file of BYTES } BLOCKWRITE (saver, fds, SIZEOF (fds)); { write fds byte by byte } BLOCKWRITE (saver, sds, SIZEOF (sds)); { write sds byte by byte } CLOSE (saver); { finished writing... } RESET (saver, 1); { open the file to read the data back } BLOCKREAD (saver, fds, SIZEOF (fds)); { read the first structure } BLOCKREAD (saver, sds, SIZEOF (sds)); { read the second structure } WRITELN (fds.i, ' ... ', sds.s); END. Moral of the story: if you tell TURBO the (untyped) file record is 1 byte, you can get it to read your data byte by byte into your data structures. Disclaimer: I represent no one but myself, and none of this is guaranteed to work on your compiler. John Spragge