Type
| Function |
Description
| Extracts a substring from the middle of a string connected to the input IN. L characters of IN are extracted, beginning at character position P. |
Notes
|
- P cannot be 0. The first position in a string is 1.
- It is not possible to use the same string as input and output string. In this
case there should be used an intermediate variable at the output. Then this
intermediate variable has to be assigned to the input variable.
- When the string output is longer than 80 characters and the FU/FB is directly connected to another FU/FB, temporary string variables of size 80 are used. Calculation/usage will fail. Use an intermediate local variable in-between.
- Problem for calculation of position and length: Characters in WSTRING can have a size of 2 bytes or 4 bytes. Due to this, there may be calculation problems on 4-byte containing character STRINGs with 2-byte oriented position and length.
|
Parameters
| Inputs
IN
Data type: | WSTRING |
Description: | Input string. |
L
Data type: | ANY_INT |
Description: | Number of characters to be extracted. |
P
Data type: | ANY_INT |
Description: | Position of the first character to be extracted. |
Output
OUT
Data type: | WSTRING |
Description: | Output string. |
|
Error behavior
| Error behavior
The following table shows the errors which may occur while executing the function and the value returned by the function in the corresponding error case.
Error case | Output value |
L < 0 | Empty string '' |
P <= 0 | Empty string '' |
P+L > len(IN) + 1(len(...) = actual string length) | Empty string '' |
L > maxlen(OUT)(maxlen(...) = maximum string length allowed (maxlen(default string) = 80)) | Empty string '' |
Resulted string too short | Empty string '' |
If any of the listed errors occurs, a string error is written to the Online log in the MESSAGES window.
Note
Controller stop on string error: The controller can be automatically stopped when a string error occurs. This allows you to locate the error in your project. To enable the automatic stop of the controller in case of a string error, activate the button in the Cockpit toolbar of the controller. |
|
Additional information
| EN/ENO behavior
The POU is only executed if TRUE is applied to the EN input. If EN = FALSE, the POU is not executed and ENO = FALSE indicates the inactivity.
If any of the errors listed under "Error behavior" occurs while executing the function, ENO is set to FALSE.
|