At 4:20 PM -0500 11/21/03, Peter Gatti wrote:
y=Len(DVDList.cell(x,9))
S.WriteLong y
S.Write DVDList.cell(x,9) // details
...
Notice for the details cell I had to use S.Write instead of
S.WritePString because that cell almost always exceeds the PString
256 byte limit. So I save the length of the string first and then
use it to S.Read(y) in later. I don't know of any other way around
this since I don't know the exact number of characters in any one
details cell.
Fair enough. Except that you used Len(), which gives you the length
of the string in characters. And when you read it back in, it's not
the length in characters you need to know; it's the length in bytes.
You aren't saving that information in the file, so you couldn't
possibly read it back in reliably.
Change that Len to LenB and all will be fine.
Also, you didn't show the reading code, but I hope you're remembering
to use DefineEncoding (or make use of the optional Encoding parameter
to BinaryStream.Read) to define the encoding of the strings you get
back in. Otherwise they're nothing but a bunch of bytes, and you
force RB to make guesses about how to treat them as text. These
guesses will often be wrong, leading to odd behavior later.
Best,
- Joe
--
,------------------------------------------------------------------.
| Joseph J. Strout REAL Software, Inc. |
| joe at realsoftware dot com http://www.realsoftware.com |
`------------------------------------------------------------------'
- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|