Re: Writing array to disk with Put
From: J French (erewhon_at_nowhere.uk)
Date: 12/20/04
- Next message: pramod rao: "Abt IShellExecuteHook"
- Previous message: Tom Esh: "Re: Registry write delay"
- In reply to: mayayana: "Re: Writing array to disk with Put"
- Next in thread: mayayana: "Re: Writing array to disk with Put"
- Reply: mayayana: "Re: Writing array to disk with Put"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 20 Dec 2004 08:49:29 +0000 (UTC)
On Sun, 19 Dec 2004 17:51:30 GMT, "mayayana"
<mayaXXyana1a@mindYYspring.com> wrote:
<snip>
> Thank you, Jerry. I find, myself, that between lack
>of coffee in the morning and lack of sleep at night
>it's not easy for me to send a post without mistakes. :)
> (Morning is the worst. My mind is in a semi-hypnogogic
>state until after the second cup of coffee....or maybe I'm
>just making excuses for the noticeably ossifying mental
>process that seems to accompany aging.)
Tell me about it !
I also have problems reading the text in my News Reader
- but changing the Font/Size makes things worse
> What I was actually doing was saving bytes in a
>winsock callback (for a dependency-free file download
>component). I'm dimming a dynamic array with
> Dim A1() as Byte
> and then redimming for the recv call. Then the loaded-up
>A1 goes into a collection, in order to accomodate the
>possibility of large downloads. When I go to write the file I'm
>just writing the saved arrays out, one at a time. All of it was
>working fine for text files, because I was converting the
>arrays to unicode strings before writing, but it was causing
>problems with writing binary files.
>
>I knew that a fixed-size array could be written:
> Dim A1(1024) as Byte......
> Put #FF, , A1()
>But the docs say that you get the array descriptor written
>if you try to use a dynamic array.
Not my VB5 docs
- not if the file is opened in Binary or Random mode
I must confess the docs are not that lucid
- but I've spent a lot of time squinting at that area
> I still don't understand why I can't just write the
>dynamic array in the collection, and yet it works to
>assign the collection Item to a new dynamic array.
> In other words, I can't use Collection.Item(i) but
>I can use Dim A1() as Byte: A1 = Collection.Item(i)
>as Norm Cook showed.
While in the Collection the 'thing' you are trying to write is
perceived by VB as being a Variant containing a Dynamic Byte Array
Get and Put for Variants just don't work the same as for the things
they contain.
> Maybe there's an extra step with the collection?....
>...that the Item pointer does not point directly to the
>Item contents?
>
> I was curious about whether I might just use
>an ANSI string directly, with s = Collection.Item(i) but
>I wondered if the Chr(0)s in that might cause a
>problem. (Since I had to fire up the sample program
>and download something for every test I didn't
>research all the options.)
Yes, in one of the examples I showed using StrConv to convert the Byte
Array (in a Deviant) into a Unicode String, then relying on VB's trick
of converting Unicode to ANSI whenever it writes to disk.
It works - but I find it slightly ugly
Personally I would experiment with a simple Function that takes in a
Variant and returns a pure Byte Array
Function VarArrayToByteArray( V As Variant ) As Byte()
VarArrayToByteArray = V
End Function
It is really the same as explicitly copying the Array, but much more
neatly packaged.
I can't test this with VB5, and it is possible that the function will
really return a Variant - but it is worth testing.
- Next message: pramod rao: "Abt IShellExecuteHook"
- Previous message: Tom Esh: "Re: Registry write delay"
- In reply to: mayayana: "Re: Writing array to disk with Put"
- Next in thread: mayayana: "Re: Writing array to disk with Put"
- Reply: mayayana: "Re: Writing array to disk with Put"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|