ADELIA |
VADELIA |
SADELIA |
WADELIA |
MADELIA |
(I/B) |
(I/B) (C/S) |
(B) (S) |
(I/B) (C/S) |
(I) (C/S) |
Section for use
All
Syntax
REPLACE_SSTRING StringToAssign AlphaVariable StartPosition Length1 Length2
Description
This instruction modifies the AlphaVariable variable or alphanumeric array element by replacing the first Length1 characters after the StartPosition position with the first Length2 characters in StringToAssign (which may be a constant, a variable or an element in an alphanumeric array).
StartPosition, Length1 and Length2 must be numerical variables or constants. StartPosition and Length2 must have a strictly positive value.
Length1 must have a positive value if Length2 is specified, and a strictly positive value if Length2 is omitted.
Their values must satisfy the following conditions:
Length1 + StartPosition - 1 <= Size of AlphaVariable
If StringToAssign is shorter than Length2, it will be padded with blank characters.
If StringToAssign is longer than Length2, it will be truncated.
The Length1 parameter is optional. If it is omitted, the instruction operates with a length of Size of AlphaVariable - StartPosition + 1.
The Length2 parameter is optional. If it is omitted, the instruction operates as if it was the same length as Length1.
Example
VAR1 = 'abcdefg'
REPLACE_SSTRING '12' VAR1 2 3
=> VAR1 contains 'a12 efg'
VAR1 = 'abcdefg'
REPLACE_SSTRING '12' VAR1 2 3 2
=> VAR1 contains 'a12efg'
VAR1 = 'abcdefg'
REPLACE_SSTRING '12' VAR1 2 0 2
=> VAR1 contains 'a12bcdefg'
VAR1 = 'abcdefg'
VAR2 = '123'
POS = 4
LEN = 2
REPLACE_SSTRING VAR2 VAR1 POS LEN
=> VAR1 contains 'abc12fg'
VAR1 = 'abcdefg'
REPLACE_SSTRING '12' VAR1 2
=> VAR1 contains 'a12'