<< Prev        Next >>

ID : 5518

SwapByteArray

Function

In a one-dimensional array with byte type, change the order of elements according to the byte counts specified.

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

Syntax

SwapByteArray(Variable,Data size,Number of data [,Initial number of element to rearrangement ]) 

Guaranteed entry

Variable
Specify variables to be rearranged by Variant type data which Internal processing format is a one-dimensional array of byte type.
Data size
Specify the byte count of data rearranged by Integer type data.
Number of data
Specify the number of data by Integer type data.
Initial number of element to rearrangement
Specify an element number which starts the rearrangement by Integer type data. This is an optional value. This should be "0" if it is omitted.

Return value

Return the byte count of data rearranged.

Description

Reverse the order of elements by byte counts specified by the Data size. This function is useful when you change the endianness of data.

The following figure shows an example of SwapByteArray command execution. Each variable is set to Data size= 4, Number of data=3, and Initial number of elements to rearrangement=4.

SwapByteArray

Attention

-

Example

'!TITLE "Change endianness"
'Change the endianness of variables I[0] and I[1], 
'and then send the binary data of these variables changed. #include <Variant.h> Sub Main Dim varData as Variant Dim Index as integer varData = CreateArray( LenB(I0) + LenB(I1) ) Index = 0 Index = Index + WriteByteArray(I0, varData, Index) Index = Index + WriteByteArray(I1, varData, Index) 'Switch two of I-type variables SwapByteArray varData, LenB(I0), 2 Comm.Open 1 Comm.Output 1, varData Comm.Close 1 End Sub

ID : 5518

<< Prev        Next >>