7.9.10 CHARS_TO_STRING
Function
Convert array of CHAR or BYTE to string
LD graphics

Parameter description
| Interface Variable | Declaration | Data Type | Description |
|---|---|---|---|
| SOURCE_CHARS | Input | Array of CHAR Array of BYTE | Source array variable for copy operation User instance input can only be Array of CHAR / Array of BYTE variables |
| POS | Input | DINT | The 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 |
| CNT | Input | DINT | Number 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_STRING | Output | STRING | The destination string for the copy operation. Observe the maximum length of the STRING data type: 254 characters |
| Function name | Return value | INT | Error 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 |
|---|---|
| 0000 | No errors, complete copy successful |
| 0001 | Truncated copy successfully, the copied source length exceeds the length defined by the string variable |
| 8151 | The reference in the SOURCE_CHARS parameter is invalid and cannot be copied |
| 8251 | The reference in the DEST_STRING parameter is invalid and cannot be copied |
| 8381 | The value of the CNT parameter exceeds the limit of the SOURCE_CHARS array and cannot be copied |
| 8382 | The value of the POS parameter exceeds the limit of the SOURCE_CHARS array and cannot be copied |
Example
- LD sample animation is as follows:

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