AnyBuffer_To_OctetString
Converts and copies the data of any variable into the octet string or one-dimensional byte array.
Namespace: Tc3_Collections
Library: Tc3_Collections (Tc3_Collections.compiled-library)
FUNCTION AnyBuffer_To_OctetString : UDINT
VAR_IN_OUT
target : ARRAY[*] OF BYTE;
END_VAR
VAR_INPUT
pSource : PVOID;
cbSource : UDINT;
bSwapBytes : BOOL;
END_VAR
VAR_OUTPUT
bUnderflow : BOOL;
bOverflow : BOOL;
END_VAR
/
Inputs/Outputs
Name | Type | Description |
---|---|---|
target | ARRAY[*] OF BYTE | Target variable. |
Inputs
Name | Type | Description |
---|---|---|
pSource | PVOID | Address pointer of the source variable. |
cbSource | UDINT | Byte size of the source variable. |
bSwapBytes | BOOL | With TRUE the data bytes are exchanged. |
Outputs
Name | Type | Description |
---|---|---|
bUnderflow | BOOL | If TRUE then the source variable is smaller than the target variable. |
bOverflow | BOOL | If TRUE then the source variable is greater than the target variable. |
Return value
Name | Type | Description |
---|---|---|
AnyBuffer_To_OctetString | UDINT | Number of successfully copied data bytes. |
Example
METHOD FINAL Sample_AnyBuffer_To_OctetString : BOOL
VAR
sValue : STRING:='0123456789';
ui64 : LWORD:=16#3031323334353637;
ui32 : UDINT:=16#30313233;
o6 : T_OCTET6;
o8 : T_OCTET8;
o64 : T_OCTET64;
size : UDINT;
bOverflow : BOOL;
bUnderflow : BOOL;
END_VAR
size:=AnyBuffer_To_OctetString(target:=o6, pSource:=ADR(sValue), cbSource:=SIZEOF(sValue), bSwapBytes:=FALSE, bUnderflow=>bUnderflow, bOverflow=>bOverflow);(* size:=6 *)
size:=AnyBuffer_To_OctetString(target:=o8, pSource:=ADR(ui64), cbSource:=SIZEOF(ui64), bSwapBytes:=TRUE, bUnderflow=>bUnderflow, bOverflow=>bOverflow);(* size:=8 *)
size:=AnyBuffer_To_OctetString(target:=o64, pSource:=ADR(ui32), cbSource:=SIZEOF(ui32), bSwapBytes:=TRUE, bUnderflow=>bUnderflow, bOverflow=>bOverflow);(* size:=4 *)
Sample_AnyBuffer_To_OctetString:=TRUE;