On Mar 28, 2008, at 7:10 PM, Mark O'Neill wrote:
> Ah, right. Didn't know that. I just opened the BinaryStream example
> that was shipped with RB - having never worked with files in RB before
> - and that's what they used in the example.
That example probably dates back to OS9 days. It should be updated
or removed.
> What should I use instead for storing text? I don't see a ReadString
> or WriteString in the help file or the contextual helper - or should I
> just avoid BinaryStreams for preference files and just use a text
> file?
You can read and write strings in binary files just fine, but as with
any binary file, you have to define (i.e. make up) the format.
Perhaps you'll choose to write out the length in bytes as a long
integer, followed by the data in UTF-8 format. Upon reading, do the
reverse (and remember to define the encoding as UTF-8). This is
similar to PString, but removes the 255-byte limit and uses a more
sensible encoding.
Or, just use a text stream; that's certainly much easier if all your
data is text.
Cheers,
- Joe
--
Joe Strout
Inspiring Applications, Inc.
http://www.InspiringApps.com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|