Skip to content

Latest commit

 

History

History
90 lines (75 loc) · 2.95 KB

SUBSTR$.org

File metadata and controls

90 lines (75 loc) · 2.95 KB

Top | Up (String) | < Previous (PAGE NAME) | Next (PAGE NAME) >

SUBSTR$

Inserts a string in another string, with optional character substitution.

Syntax

SUBSTR$ target$, pos%, substitute$ OUT result$
SUBSTR$ target$, pos%, [numberofchars%,] substitute$ OUT result$
ParameterDescription
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.
OutputDescription
result$Resulting string after operation.
  • If numberofchars% is omitted, all characters in target$ after pos% will be replaced by substitute$, regardless of the length of both strings.
  • If numberofchars% is 0, substitute$ will be placed on the given pos% and no replacement happends.

Examples

' 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"

Possible Errors

ErrorCause
Out of rangepos% is less than 0, or bigger than the length of target$. Or numberofchars% is less than 0.

See Also:


Top | Up (String) | < Previous (PAGE NAME) | Next (PAGE NAME) >