PackArrayOfBoolToArrayOfByte (FUN)¶
FUNCTION PackArrayOfBoolToArrayOfByte : UINT
The function packs an “ARRAY OF BOOL” into an “ARRAY OF BYTE”.
The function copies “uiNumberOfBits” from “axSource” to “abyDestination”. It will return the necessary number of bytes in “abyDestination”. Only if “paxSource”, “pabyDestination” or “uiNumberOfBits” are set to “0”, the copying will not be carried out and the function will return “0”.
Example:
axSource : ARRAY[0..9] OF BOOL := FALSE,TRUE,FALSE,FALSE,TRUE,TRUE,FALSE,FALSE,TRUE,FALSE ;
abyDestination : ARRAY[0..2] OF BYTE ;
uiNumberofBytes := MEM.PackArrayOfBool(ADR(abSource), ADR(abyDestination), 10) ;
->
uiNumberofBytes = 2
abyDestination[0] = 16#32
abyDestination[1] = 16#01
abyDestination[2] = 16#00
Note
The size of the ARRAY “abyDestination” has to be adjusted to the amount of bits copied! Source and target may not overlap!
- InOut:
Scope
Name
Type
Comment
Return
PackArrayOfBoolToArrayOfByteUINTfuncton returns the necessary number of bytes in “abyDestination”
Input
paxSourcePOINTER TO BYTE
address of ARRAY OF BOOL
pabyDestinationPOINTER TO BYTE
address of ARRAY OF BYTE
uiNumberOfBitsUINTnumber of bits to copy from “paxSource” to “pabyDestination”