2 Instruction Descriptions
2-530
NJ-series Instructions Reference Manual (W502)
The following example is for when In1 is ‘ABCDEF’, In2 is ‘GHI’, P is UINT#2, and L is UINT#4. The
value of variable abc will be ‘AGHIF’.
• If L is 0, an error will not occur and all of the characters in In1 are inserted to Out.
• If the value of In2 is 0, L characters are deleted from P in In1.
• Multi-byte characters are counted as one character each.
• An error occurs in the following cases. ENO will be FALSE, and Out will not change.
• In1 or In2 does not end in a NULL character.
• In1 results in a character code error.
• In1 does not have enough characters for the number of characters specified by L from the position
specified by P.
• The value of P is 0.
• The length of the replacement result exceeds the size of Out.
Precautions for Correct Use
abc:=REPLACE(‘ABCDEF’, ‘GHI’, UINT#4, UINT#2);
LD ST
abc
‘ABCDEF’
‘GHI’
UINT#4
UINT#2
REPLACE
EN ENO
In1
In2
L
P
Out=abc
In
Repl
Deleted
Insert
‘AGHIF’
‘ABCDEF’
‘GHI’