<< Prev        Next >>

ID : 5523

ReadByteArray

Function

This command stores the values of a one-dimensional array (Variant type) of a byte unit into the specified variable for every one byte. The byte order of the array is not changed when it is stored in the variable.

This command is available in Ver.1.6.* or higher.

Syntax

ReadByteArray(Destination variable,Array to be stored 
              [,Element number to start storage [,Destination byte count]])

Guaranteed Entry

Destination variable
Specify a variable of the destination. All types of data (except for array variable of Variant type) can be specified.
Array to be stored

Specify an Array to be stored by Variant type data (Internal processing format is a one-dimensional array with byte type).

Element number to start storage
Specify an element number in the Array to be stored that is converted first. Specify the element number by Integer type data. This is an optional value. This should be "0" if it is omitted.
Destination byte count
Specify the byte count of data which is stored in Destination variable by Integer type data. Up to the size (byte count) of destination variable can be stored. This is an optional value. This should be "-1" if it is omitted. If "-1" is specified, the data is stored in the same byte size of Destination variable.

Return Value

Return the byte count of data stored in Destination variable by Integer type data.

Description

This command stores values of Array to be stored into estination variable for every one byte. The elements order is not changed when it is stored in the variable.

The storage starts from the lowest byte of Array to be stored in ascending order; the highest byte is stored in the last. The lowest byte of Array to be stored is stored into the lowest element number of Destination variable.

Assume that Array to be stored stores value of elements in order of 1, 2, 3 and 4, where the order of elements number is ascending order which starts from the elements number 0. If Destination variable is Integer type, the hexadecimal number &H4030201, which is equal to 67305985 in decimal number, is stored.

If the data type that is used in Destination variable includes multiple elements, such as Vector type and Position type, the order of storage complies with the order of elements.

For example, the order of elements in Vector type is X, Y and Z. Therefore, the value of “X” is stored at first, and the value of “Z” is stored last. Within each element, bytes have the order as well; the lowest byte is stored first and the highest byte is stored at last.

For about elements order of each type, see Data Types.

Attention

-

Example

'!TITLE "Convert data from the Byte array into each variable type"
'Store received binary data into variables I[0] and I[1]

Sub Main
  Dim Var as Variant

  Comm.Open 1

  Comm.Input 1, Var

  ReadByteArray I[0], Var, 0
  ReadByteArray I[1], Var, 4

  Comm.Close 1
End Sub

ID : 5523

<< Prev        Next >>