Special

Clearance Sale!

We've been publishing for over five years now and it's time to clear out our inventory of back issues, so we're slashing prices!

RBD Magazines

Check out this amazing clearance sale of all our past issues. Missing some issues? This is a great time to complete your RBD collection. Save up to 40% off the regular price of our printed back issue packages. These prices are only good until the end of the year May 2008 and supplies are limited, so place your order today.

Article Preview


Buy Now

Print:
PDF:

Intel corner

Cross platform streams

We write our own binary stream to save our data

Issue: 2.4 (March/April 2004)
Author: Christian Schmitz
Author Bio: Christian Schmitz is the creator of the Monkeybread Software REALbasic Plugins.
Article Description: No description available.
Article Length (in bytes): 11,246
Starting Page Number: 42
RBD Number: 2421
Resource File(s):

Download Icon 2421.sit Updated: Monday, March 15, 2004 at 1:02 AM

Related Link(s): None
Known Limitations: None

Excerpt of article text...

Why Our Own Binary Stream?

The idea behind this article is that you often need a way to store your data in some binary files. With REALbasic, on the Mac you can often simply use BinaryStream.WritePString to write a short string to a binary file, but this method has some limitations. First, a Pascal string has a maximum of only 255 characters, which may not be sufficient for uses such as the printer setup string (which is a few kilobytes in size on Mac OS X). Second, the string encoding is not stored inside the file, so you need to convert the encoding before saving.

This article shows you, in source code, how to make a cross platform binary stream which should work on Mac OS X, Mac OS Classic, Windows, and even Linux.

Implementation of our CrossBinaryStream class

Initialization: The Constructor

Make a new class and call it "CrossBinaryStream". Open it and add a private property "stream as binarystream". Inside this property we will save a reference to the target BinaryStream.

...End of Excerpt. Please purchase the magazine to read the full article.

Article copyrighted by REALbasic Developer magazine. All rights reserved.


 


|

 


Weblog Commenting and Trackback by HaloScan.com