<< Prev        Next >>

ID : 5522

WriteByteArray

Function

This command stores variables into the one-dimensional array (Variant type) for every one byte. The byte order is not changed when it is stored in the arrays.

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

Syntax

WriteByteArray(Variables to be stored,Destination array
               [,Element number to start storage [,Destination byte count ]])

Guaranteed Entry

Variables to be stored
Specify values to be stored in Destination array. All types of data (except for array variables of Variant type) can be specified.
Destination array
Specify an array of destination by Variant type data.
Element number to start storage

Specify the element number which is stored first at Destination array. 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 array by Integer type data. Up to the size (byte count) of variables to be stored can be stored. This is an optional value. This should be "-1" if it is omitted. If "-1" is specified, all the data of Variables to be stored will be stored in Destination array.

Return Value

Return the byte count of data which has been stored in Destination array by Integer type data.

Description

This command stores values of Variables to be stored into Destination array for every one byte. The byte order is not changed when it is stored in the arrays.

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

Assuming that Variables to be stored is Integer type, and the hexadecimal number &H4030201, which is equal to 67305985 in decimal numbers, is stored; Destination array will store these data in ascending order. Element number 0, 1, 2 and 3 stores the value of 1, 2, 3 and 4 respectively.

If the data type that is used in Variables to be stored 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. Also, in each element, 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

You do not need to convert Destination array into a one-dimensional array beforehand by means of CreateArray or other ways.
Once WriteByteArray is executed, the values of Destination array are converted to a one-dimensional array of byte counts that will be actually stored. And then, the values of converted Destination array are stored.

Example

'!TITLE "Convertion to Byte arrays
'Send binary data of variables I[0] and I[1] as Byte array

Sub Main
  Dim Var as Variant

  Comm.Open 1

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

  Comm.Output 1, Var

  Comm.Close 1
End Sub

ID : 5522

<< Prev        Next >>