5.8 Standard Character String Functions
194
FXCPU Structured Programming Manual
(Application Functions)
Error
An operation error occurs in the following cases. The error flag M8067 turns ON, and D8067 stores the error
code.
1) When "00H" does not exist in the corresponding device range after the devices specified in and
(Error code: K6706)
2) When the value specified in exceeds the number of characters of a character string stored in
devices specified in
(Error code: K6706)
3) When the value specified in is negative
(Error code: K6706)
4) When the value specified in is "-2" or less
(Error code: K6706)
5) When the value specified in exceeds the number of characters of a character string stored in
devices specified in
(Error code: K6706)
Program example
In this program, specified number of characters starting from an arbitrary position of a character string stored
in devices specified in are replaced with a character string stored in devices specified in , and the
character string obtained by replacement is output to devices specified in .
1) Function without EN/ENO(REPLACE)
2) Function with EN/ENO(REPLACE_E)
[Structured ladder]
[ST]
[Structured ladder]
[ST]
s1
s2
n1
s2
n2
n1
n2
s1
s1
s2
d
REPLACE
g_string1="ABCDEFGH"
g_string2="012345678"
_IN1
_IN2
g_string3="AB012345"
g_int1=6
_L
g_int2=3
_P
g_string3:=REPLACE(g_string1,g_string2,g_int1,g_int2);
REPLACE_E
EN ENO
g_string3
g_bool1
g_string1
g_string2
_IN1
_IN2
g_bool3
g_int1
_L
g_int2
_P
g_bool3:=REPLACE_E(g_bool1,g_string1,g_string2,g_int1,g_int2,g_string3);