Name
ByteVal -- convert raw bytes to value (V8.0)
Synopsis
v = ByteVal(s$[, type, le])
Function
This function can be used to convert raw bytes from the string passed in s$ to a numeric value. The number of bytes that will be read from the string s$ depend on the type that you pass in the type argument. The following types are currently supported:

#BYTE:
Reads an 8-bit value (1 byte) from the string and returns it.

#SHORT:
Reads a 16-bit value (2 bytes) from the string and returns it.

#INTEGER:
Reads a 32-bit value (4 bytes) from the string and returns it. This is the default.

#FLOAT:
Reads a 32-bit floating point value (4 bytes) from the string and returns it.

#DOUBLE:
Reads a 64-bit floating point value (8 bytes) from the string and returns it.

For all multi-byte types, i.e. all types except #BYTE, you can use the additional le argument to specify the order in which the bytes should be read from s$. If you set le to True, the bytes will be read in little endian order (LSB first), otherwise the bytes will be read in big endian order (MSB first). Big endian is also the default.

Note that for all integer types the result will always be unsigned. You can use the Cast() function if you need to cast the result to a signed type. See Cast for details.

If you need to convert a value to raw bytes, you can use the ByteStrStr() function. See ByteStrStr for details.

Inputs
s$
string to read data from
type
optional: type of value to read (defaults to #INTEGER)
le
optional: whether or not to use little endian byte order (defaults to False)
Results
v
resulting value

Show TOC