Converting Hexadecimal in Binary
Dar Scott
dsc at swcp.com
Sun Jan 11 13:15:12 EST 2004
This has text pictures needing a fixed pitch font.
On Sunday, January 11, 2004, at 02:26 AM, Alejandro Tejada wrote:
> put binaryDecode("H*", char i to i+2 of asd)after var
> -- produces an error!
> put binaryEncode("H*", char i to i+2 of asd)after var
> -- works perfectly!
It is related to where the binary data is. In binaryDecode(), it is a
parameter; you are decoding the binary data. In binaryEncode() it is
the value returned by the function; you are encoding or building the
binary data.
Like this:
put binaryDecode( formatsList, binaryData, datum1, datum2, datum3) into
numConverted
datum1
{ binaryData ========> datum2 }-------> numConverted
^ datum3
|
formatsList
local datum1, datum2, datum3
put binaryEncode( formatsList, datum1, datum2, datum3) into binaryData
datum1
datum2 ========> binaryData
datum3 ^
|
formatsList
Now the designers could have made binaryEncode to be more like
binaryDecode, and that might have made things easier to remember, but I
like the functional binaryEncode and I build functions for conversions
around both anyway.
So the problem with your example of binaryDecode is that the parameter
for the binary data is missing.
Dar Scott
More information about the use-livecode
mailing list