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.
But Joe, I used Len() because the Language Reference states that the
integer parameter for the read method is 'reads count characters,' so
that's what I used. It mentions nothing about substituting bytes. As I
menetion earlier, as long as there are no option key characters in the
text, the file writes and reads back without a hitch.
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.
Ah, I think this is the real reason for my problem. I didn't include the
Encoding parameter because I really don't understand what it is or why
there is even a need for it. In my mind every character in an edit field
has an ASCII number and that's what is being save to a file. And when I
read back the file, I don't expect extra characters thrown in that
presumably defines the following character as being an option key
character... as in the example I gave, '¬©' where the added character ¬
presumably says something about the © character in my text.
To be quite frank, explanations and examples in the Language Reference
for Encoding are at a level way over my head and seem geared for those
who already understand the jargon and how to apply it. I haven't the
foggiest idea what to put in that parameter. Once again Joe, any help
will be greatly appreciated.
Thank you,
Pete Gatti
- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|