Skip to main content

7.9.10 CHARS_TO_STRING

Function

Convert array of CHAR or BYTE to string

LD graphics

alt text

Parameter description

Interface VariableDeclarationData TypeDescription
SOURCE_CHARSInputArray of CHAR
Array of BYTE
Source array variable for copy operation
User instance input can only be Array of CHAR / Array of BYTE variables
POSInputDINTThe relative subscript position of the source array SOURCE_CHARS, starting from this position to copy characters
The POS parameter will be calculated from 0, corresponding to the starting subscript position of the array
CNTInputDINTNumber of characters to copy. Using the value "0" will copy all characters starting from POS of the SOURCE array
Length will be truncated if it exceeds the length of the STRING variable Value
DEST_STRINGOutputSTRINGThe destination string for the copy operation. Observe the maximum length of the STRING data type: 254 characters
Function nameReturn valueINTError message
description
  • This instruction can copy the string from the SOURCE_CHARS array to the DEST_STRING string of data type STRING

  • In principle, the number of characters in the DEST_STRING string is at least the same as the number of characters copied in the source domain SOURCE_CHARS

  • If the string length of the DEST_STRING actual parameter is less than the number of characters in the source field, the maximum number of characters will be written in the string

  • If the value of the POS and CNT parameters exceeds the limit of the SOURCE_CHARS array, it cannot be copied

  • Demonstration: If you read all starting from the third position, use the value "2" in the parameter POS, CNT can use the value 0

  • Return value error code
Error code*(W#16#)Description
0000No errors, complete copy successful
0001Truncated copy successfully, the copied source length exceeds the length defined by the string variable
8151The reference in the SOURCE_CHARS parameter is invalid and cannot be copied
8251The reference in the DEST_STRING parameter is invalid and cannot be copied
8381The value of the CNT parameter exceeds the limit of the SOURCE_CHARS array and cannot be copied
8382The value of the POS parameter exceeds the limit of the SOURCE_CHARS array and cannot be copied

Example

  • LD sample animation is as follows:

alt text

  • ST example is shown in the following code:
OUT:=CHARS_TO_STRING(
SOURCE_CHARS:=IN1,
POS:=IN2,
CNT:=IN3,
DEST_STRING=>ARR
);