grzegorz@pithekos.net (Grzegorz Chrupa³a) writes:
> But sometimes I just want to write some records to a file in a
> human-readable way, maybe modify them manually, and read them back later.
> I could probably wrap all the records in a list or something and write it
> out. Then to read them back, I could read the whole file into a string and
> call Compliler.virtualStringToValue on it.
Don't do this. The documentation warns you away from it.
If you absolutely need to do what you describe, proceed as follows:
- write a record
- write a terminator, e.g. some otherwise unused or illegal character
- repeat
then, when you read your data back in: you just read a chunk up to
that terminator character, compile the string you thus obtained and
get back your record, etc...
You will eventually realize that this is just the wrong thing to do,
but until then you'll have something that gets the job done.
Another possibility is to use XML. I have an XML parser in MOGUL.
Cheers,
PS: you might want to search the archives. I once posted a message
describing a number of possibilities for dealing with data.
-- Dr. Denys Duchier Équipe Calligramme LORIA, Nancy, FRANCE - Please send submissions to users@mozart-oz.org and administriva mail to users-request@mozart-oz.org. The Mozart Oz web site is at http://www.mozart-oz.org/. Please send bug reports to bugs@mozart-oz.org.