New topic: Binary stream troubles
<http://forums.realsoftware.com/viewtopic.php?t=32412> Page 1 of 1 [ 2 posts ] Previous topic | Next topic Author Message serd83 Post subject: Binary stream troublesPosted: Tue Feb 09, 2010 5:00 am Joined: Thu Feb 22, 2007 7:08 pm Posts: 884 I have some troubles with binary files. For example in Version 2(new version) I add a new variable "FileVersion As Double" and use this to save a file: Code:binarystream = folderitem.createbinaryfile("FileType") if binarystream <> nil then binarystream.writedouble fileversion // defined as 1.1 // write the other data end What I want do is to check if the binary file is an old or a new version. But the problem here is that FileVersion not exists in Version 1. With the code below I can open the files which are saved with the new Version(2), because I saved FileVersion to the file. The only solution to open an older file is to remove fileversion = b.readdouble, but then I can not distinguish if the file is an old or new file with the if statment. Load: Code:dim b as binarystream = folderitem.openasbinaryfile(false) if b <> nil then fileversion = b.readdouble // if I remove this then it is possible to load an old file, but then it is not possible to use an if statment like below while b.eof <> true if fileversion >= 1.1 then // read a new file else // try to read a old file but it destroyed the data end wend end Top timhare Post subject: Re: Binary stream troublesPosted: Tue Feb 09, 2010 5:03 am Joined: Fri Jan 06, 2006 3:21 pm Posts: 7208 Location: Portland, OR USA Place the version number after the version 1 data. That way, a version 1 program will still open the file, and version 2 and later programs have the version number to help them interpret the data. Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 2 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
