Yes, it is true that VBScript will throw an exception as soon as you try to 
"touch" a Variant containing anything of Byte subtype.  I'm well aware of that 
long-standing limitation on the desktop as well.

You can perform limited manipulation of Byte arrays though using helper 
objects.  On the desktop ADO.Stream objects can be very handy helpers.  
Msxml2.Xmlhttp has a .responseBody property that returns Byte arrays and 
newObject's SFStream has .ReadBin() and .WriteBin() methods that work with them 
just as you described.

A really LONG way around might be to take results back from a DECLAREd call (as 
Integers) and convert these to a hex string and then back once more to get a 
Byte array using newObject's StringUtilities...

... but seriously, folks! ;)

No, both memory and cycles are too precious on a CE/WM device.  I'll need to 
think about this more I guess.

Thanks for the heads up though.  This was valuable feedback.

- Bob

--- In nsbasic...@yahoogroups.com, "George Henne" <g...@...> wrote:
>
> The core problem here is that VBScript (the underlying engine) does not
> support byte arrays.
> 
> I don't have a solution for you, but here is a related trick to get a
> long from a byte array, using the newObjects SFMain object. It also
> deals with the big endian/little endian problem, which you probably
> won't have.
> 
> AddObject "NewObjects.utilctls.StringUtilities","su"
> AddObject "newObjects.utilctls.SFMain","FS"
> Set file=FS.OpenFile(DataFile)
> ...
> 
> Function getLong(offset)
>       Dim y
>       file.pos=offset
>       y=file.readbin(4)
>       y=su.BinToHex(y) 'convert the byte array into a format we can use
>       y=Right("00000000" & y,8) 'left pad it to 8 characters long
>       getlong=CLng("&h" & Mid(y,7,2) & Mid(y,5,2) & Mid(y,3,2) & Mid(y,1,2))
> 'reverse the byte order
> End Function


-- 
You received this message because you are subscribed to the Google Groups 
"nsb-ce" group.
To post to this group, send email to nsb...@googlegroups.com.
To unsubscribe from this group, send email to 
nsb-ce+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/nsb-ce?hl=en.

Reply via email to