Sub-strings
Sub-strings

Sub-strings

Using a sub-string operator on a string allows a specific portion of the string to be accessed. This portion may be the target of an assignment operation or a reference to a portion of the string. To determine the coordinates of the string portion to be used, count the characters from the beginning to the end of the string, including spaces.
Format
LET <STRVAR$>(<A>:<B>)=<C$>
LET
<C$> = <STRVAR$>(<A>:<B>)
Parameters
<A>
= the position of the first character in the desired string
<B>
= the position of the last character in the desired string.
<STRVAR$>
= base string variable
If the A parameter is less than 1, it is automatically assigned a value of 1. Because the string is calculated starting with 1, the A parameter cannot be less than 1.
If B is greater than the length of the string, it is replaced with the length of the string.
If A is greater than B, a NULL string (""), which points to the location of the smaller of A or the end of the string, is returned. This is used when adding a string in the middle of another string without removing a character.
Example
This is an example of a sub-string reference:
LET A$="Zebra Quality Printers" LET B$=A$(1:13) PRINT B$ Zebra Quality
This is an example of a sub-string assignment.
LET A$= "1234" LET A$(2:3)= "55" ! A$ NOW = 1554 LET A$(2:3)= "" ! A$ NOW = 14 LET A$= "1234" LET A$(2:3)= A$(1:2) ! A$ NOW = 1124 LET A$= "1234" LET A$(2:1)= "5" ! A$ NOW = 15234
The best way to think of assignment to a sub-string is as follows: an assignment is like selecting a word, and pasting over the selection with the new string.