UnpackArrayOfByte (FUN)

FUNCTION UnpackArrayOfByte : UINT

The function unpacks an "ARRAY OF BYTE" in an "ARRAY OF BOOL".

abySource[0].0 -> axDestination[0]

abySource[0].1 -> axDestination[1]

...

abySource[1].0 -> axDestination[8]

...

abySource[1].7 -> axDestination[15]

...

The function copies the amount of "uiNumberOfBits" from "abySource" to "axDestination". The function will return the number of bytes considered in "abySource". If "pabySource", "paxDestination" or "uiNumberOfBits" are set to "0", the copying will not be carried out and the function will return "FALSE".

Example:

abySource : ARRAY[0..2] OF BYTE :=  16#32, 16#01, 16#00 ;
axDestination : ARRAY[0..9] OF BOOL ;
uiNumberofBytes := MEM.UnpackArrayOfByte(ADR(abySource), ADR(axDestination), 10) ;
->
uiNumberofBytes = 2
axDestination[0] = FALSE
axDestination[1] = TRUE
axDestination[2] = FALSE
axDestination[3] = FALSE
axDestination[4] = TRUE
axDestination[5] = TRUE
axDestination[6] = FALSE
axDestination[7] = FALSE
axDestination[8] = TRUE
axDestination[9] = FALSE
Note

The size of the array "axDestination" has to be adjusted to the number of bits to be copied! Source and target may not overlap!

InOut:

Scope

Name

Type

Comment

Return

UnpackArrayOfByte

UINT

function returns the number of bytes considered in "abySource"

Input

pabySource

POINTER TO BYTE

address of BYTE ARRAY

paxDestination

POINTER TO BYTE

address of BOOL ARRAY

uiNumberOfBits

UINT

number of bits to copy from "abySource" to "axDestination"