Extract String (Middle)

Extracts a string from a desired position.

Block
Text

TARGET = substring(INPUT, STARTPOSITION, COUNT);
  1                  4          2          3

# Description
1 [Destination Data]
Set the destination where you want to store the extracted string.
2 [Start position]
Integer value that specifies the start point for string extraction. The value must be greater than or equal to 1 and less than or equal to the extractable start position.
3 [Number of characters]

Set the number of characters to extract. The value must be greater than or equal to 1, and less than or equal to the number of characters that can be extracted.

Double-byte characters are counted as a single character.

4 [Source Data]
Set the source data where the string to extract is stored.

(Example)

Block

Text

Var4 = substring(Var3,Var5,Var1);

Operation Example

Variable in [Source Data]

[Start position]

[Number of characters]

Variable in [Destination Data]

Comments

Target string

Maximum Number of Bytes Extracted string to store
ABCDE 2 3 5 BCD -
4 3 5 (none)
A string is not stored because the [Number of characters] exceeds the number of retrievable characters. It is judged as fail in the "Operation Result" Operation.
6 3 5 (none)
A string is not stored because the [Start position] exceeds the available start position. It is judged as failed in the "Operation Result".
0 3 5 (none)
A string is not stored because the [Start Position] is less than 1. It is judged as failed in the "Operation Result".
-1 3 5 (none)
A string is not stored because the [Start Position] is less than 1. It is judged as failed in the "Operation Result".
4 0 5 (none)
A string is not stored because the [Number of characters] is less than 1. It is judged as fail in the "Operation Result" Operation.
4 -1 5 (none)
A string is not stored because the [Number of characters] is less than 1. It is judged as fail in the "Operation Result" Operation.
2.1 3 5 BCD The decimal part of the [Start Position] is truncated.
2 3.5 5 BCD
Values to the right of the decimal point in [Number of characters] are dropped.
ABCDEF 1 6 5 (none)
A string is not stored because the converted string has exceeded the maximum number of bytes that can be stored. It is judged as fail in the "Operation Result" Operation.
AB(0x00)CDE 2 3 5 (none)
A string is not stored. If there is a NULL (0x00), the string is terminated there. As a result, the [Number of characters] exceeds the number of retrievable characters. It is judged as fail in the "Operation Result" Operation.
4 3 5 (none)
A string is not stored. If there is a NULL (0x00), the string is terminated there. As a result, the [Start position] exceeds the available start position. It is judged as failed in the "Operation Result".
AあB 1 3 5 AあB
String is stored based on the [Number of characters]. *1
2 3 5 (none)
A string is not stored because the [Number of characters] exceeds the number of retrievable characters. It is judged as fail in the "Operation Result" Operation.
2 2 5 あB
String is stored based on the [Number of characters]. *1

*1 If the maximum number of bytes in the [Destination Data] variable is less than the size of the retrieved string, the operation will fail. The maximum number of bytes depends on the encoding of the [Destination Data] variable.