Top | Up (String) | < Previous (PAGE NAME) | Next (PAGE NAME) >
Inserts a string in another string, with optional character substitution.
SUBSTR$ target$, pos%, substitute$ OUT result$
SUBSTR$ target$, pos%, [numberofchars%,] substitute$ OUT result$
Parameter | Description |
---|---|
target$ | A string. |
pos% | Position on target$ to place substitute$ . Can be the length of target$ . |
numberofchars% | Number of characters to replace after pos% . |
substitute$ | A character or string to insert. |
Output | Description |
---|---|
result$ | Resulting string after operation. |
- If
numberofchars%
is omitted, all characters intarget$
afterpos%
will be replaced bysubstitute$
, regardless of the length of both strings. - If
numberofchars%
is 0,substitute$
will be placed on the givenpos%
and no replacement happends.
' Substitution
PRINT SUBSTR$("1234567890",1,"#") ' "1#"
PRINT SUBSTR$("12345",0,1,"#") ' "#2345"
PRINT SUBSTR$("12345",1,3,"=") ' "1#5"
' Append
' Append at the end
PRINT SUBSTR$("123",3,"_ABC") ' "123_ABC"
' Append at the beginning
PRINT SUBSTR$("ABC",0,0,"DEF") ' "DEFABC"
' Append at the middle
PRINT SUBSTR$("12345",2,0,"//") ' "12//345"
Error | Cause |
---|---|
Out of range | pos% is less than 0, or bigger than the length of target$ . Or numberofchars% is less than 0. |
Top | Up (String) | < Previous (PAGE NAME) | Next (PAGE NAME) >