Modify

From BR Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

A BR String may be modified using its subscripts. For example, A$(4:6) uses the substring of A$ beginning with position 4 up to and including position 6; the numbers inside the parentheses could be replaced by any numeric expression. In the following example, line 40 sets element 3 of array Z$ to "XXC":

00010 LET Z$(3) = "ABC"
00020 LET A = 1
00030 LET B = 2
00040 LET Z$(3)(A:B) = "XX"

In the next example, line 40 replaces "BC" with "23" and assigns the value "A23D" to X$:

00030 LET X$ = "ABCD"
00040 LET X$(2:3) = "23"

Note that you the number of characters being replaced does not have to match the number of characters they are being replaced with. Consider the following example:

00010 dim a$*255
00020 let a$ = "beginning end"
00030 let a$(10:10) = " middle " ! here we are replacing one character (a space) with 6 characters (" middle ")
00040 print a$

The result of the example above is

beginning middle end