Re: Commands Writing To Binary File
- Posted by DerekParnell (admin) Mar 27, 2009
- 863 views
Andy said...
Hey Guys,
I'm using Eu 4.0 and I heard that there was an easier to write data to a binary file. I'm wondering what the commands are, or how I would go about writing data to a binary file.
If all your data is in one sequence you can simply do this ...
-- Write data to file include std/serialize.e integer size = dump(myData, theFileName) if size = 0 then puts(1, "Failed to save data to file\n") else printf(1, "Saved file is %d bytes long\n", size) end if
And to read it back in ...
-- Read data from file include std/serialize.e sequence mydata = load(theFileName) if mydata[1] = 0 then puts(1, "Failed to load data from file\n") else mydata = mydata[2] -- Restored data is in second element. end if