I *think* when a string variable is added to, then a new string variable is created at the end of the variable space and then the earlier version is deleted with everything being shuffled along.
Changing the program (adding, editing or removing program lines) also shifts things in memory.
Hi,
Yes, the DIM command able to fixe the string variable location.
It's due to its length.
10 LET c$="xx"
20 LET c=100
30 LET c$="x" < the VARS will be move after the C value.
40 LET E=50 <will be add after C$
50 LET C$=C$+C$ <Will move C$ after E...
In case of DIM E$(4), 4 characters are reserved.
LET E$="xxxxxxxxxxxooooo" => LET E$="xxxx"
DIm E$(2)
LET A$="A"
LET B$="B"
LET E$=B$+A$="BA"
LET E$=A$+A$+A$+A$+A$+A$+B$="AA"
LET A$="ABC"
LET B$="BCD"
LET E$=A$ E$=="AB"
LET E$=A$(2 TO)="BC"
LET E$=A$(2)+B$(3)="BD"
If you don't change the string length, the BASIC program don't had to refresh and move the VARS and is faster.
In 1k, the vars move if the screen length is change (With the CLS or SCROLL command for example!).
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
1 REM [HEX:\
ED,4B,12,40,C9 ]
10 LET C$="HELLO"
15 LET D$="WORLD"
20 GOSUB 1000
30 LET C$=C$+C$
100 GOSUB 1000
110 LET C$=C$+D$
120 GOSUB 1000
130 LET C$="-THANKS"
140 GOSUB 1000
150 STOP
1000 LET C$=C$+CHR$ 128
1010 LET C$(1)=C$(1)
1020 RAND USR 16514
1030 LET A=PEEK 16434+PEEK (16435)*256
1040 FOR A=A TO 4E4
1050 LET B=PEEK A
1060 IF B<128 THEN PRINT CHR$(B);
1070 IF B<128 THEN NEXT A
1075 LET C$=C$( TO (LEN C$-1))
1080 PRINT
1100 RETURN