This function of the ⇘ CAA_Memory.library packs an "ARRAY OF BOOL" into an "ARRAY OF BYTE".
axSource[0] -> abyDestination[0].0
axSource[1] -> abyDestination[0].1
...
axSource[8] -> abyDestination[1].0
...
axSource[15] -> abyDestination[1].7
...
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".
提示! The size of the array "abyDestination" has to be adjusted to the amount of bits to be copied! Source and target may not overlap! |
Input:
paxSource |
DWORD |
Address of ARRAY OF BOOL |
pabyDestination |
DWORD |
Address of ARRAY OF BYTE |
uiNumberOfBits |
UINT |
Number of bits to be copied |
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(axSource), ADR(abyDestination), 10) ;
->
uiNumberofBytes = 2
abyDestination[0] = 16#32
abyDestination[1] = 16#01
abyDestination[2] = 16#00