Of String$ and Things

Author(s): Earl Dunnington
Pub Details: Time Designs Magazine v2 n3 (Volume 2, Issue 3)
Date: March/April 1986
Pages: 10-11

While working up examples for my series of articles “Adventure In The RAM Jungle And Other Mysteries” appearing in the SEPT/ OCT 85 through JAN/FEB 86 issues, I came across a curious feature of the TS 1000/1500 concerning un-dimensioned and dimensioned strings, that is not covered in the owner’s manual. In some computers there is a built in limit of 255 characters in an undimensioned string. Likewise in a print statement. This is not the case in the Timex/ Sinclair computers. However, there is an undefined limit on undimensioned strings that is based on three factors. These factors are: the number of bytes in the program, the size of the available RAM, and the number and size of the other undimensioned variables and strings in the program. In most cases you can store more characters in a dimensioned string than you can in an undimensioned string. In order that those readers with only 2K RAM can obtain the same results, set RAMTOP at 18432 by ENTERing the following direct commands:

POKE 16388,0
POKE 16389,72
NEW

Now type in Program No.1 as follows:

10 FAST
20 LET A$=""
30 LET B$="A"
40 FOR N=1 TO 900
50 LET A$=A$+B$
60 NEXT N

RUN the program and when the 4/50 report is given (out of memory), ENTER the direct command: PRINT LEN A$

You should get 577 as the length of the A$. To see the string, ENTER the direct command: PRINT A$

Now change line 50 to read: 50 LET A$(N)=B$

This time instead of RUN, ENTER the direct commands:

DIM A$(900)
GOTO 30

To see the entire string, change line 50 to read: 50 PRINT A$(N);

ENTER: GOTO 40

When the 5/50 report is given (no more room on the screen), ENTER: CONTINUE

As you can see, we can store many more characters in a dimensioned string. The disadvantage is that the LEN function reports the dimensioned size of the string, not how many characters were actually stored, if less than the dimensioned size. This disadvantage can be overcome by assigning a permanent variable in the program to keep track of the number of characters in the string. For example:

55 LET LENAD=N

Add line 55 and change lines 40 and 50 to:

40 FOR N=1 TO 800
50 LET A$(N)=B$

As before, ENTER the direct commands:

DIM A$(900)
GOTO 30

When the 0/60 report is given, ENTER the direct command: PRINT LEN A$

The result will be the length of the dimension, 900. ENTERing: PRINT LENAD will give 800; the actual amount of characters stored in the string A$. If we never use the variable N again in the program, then we could use N instead of the variable LENAD to keep track of the number of characters.

In his otherwise excellent book “A PRACTICAL GUIDE TO MACHINE LANGUAGE PROGRAMMING ON THE TIMEX/SINCLAIR 1500 AND 1000 (AND ZX81)” (SiriusWare), David B. Wood states on pages 28 and 29, “Note that if you change RAMTOP, but do not execute NEW the upper stacks still operate in their original locations.” In my article “ADVENTURES IN THE RAM JUNGLE AND OTHER MYSTERIES (CONCLUSION)” JAN/FEB 86 issue, we proved that this is essentially correct (with a slight difference of semantics). However, he goes on to say “The only effect will be that the system will not expand lower memory beyond this RAMTOP”. This is what I will kindly call a “Jungle superstition” perpetuated by other authors without proof. The lower RAM memory extends from the start of the system variables area to the top of the Calculator stack during the program RUN. E_Line is an address that marks the start of the workspace and spare area. The address of E_Line is stored in the two bytes of the system variable E_Line, 16404 and 16405. The address immediately below E_Line always contains the value 80h (128 decimal). Delete line 55 and change line 40 back to:

40 FOR N=1 TO 900

Now POKE the system variable RAMTOP to address 17408 without entering NEW:

POKE 16388,0
POKE 16389,68

As before, ENTER the direct commands:

DIM A$(900)
GOTO 30

When the 0/60 report appears on the screen, find the address of E_Line by PEEKING the system variable E_Line using the direct command:

PRINT PEEK 16404+256*PEEK 16405

The result displayed on the screen should be 17548. PEEK this address-1 with the direct command:

PRINT PEEK 17547

The value displayed should be 128. As this is the marker immediately below E_Line and is at address 17547 which is indeed above the address in the system variable RAMTOP, it proves that changing RAMTOP (i.e.; the value stored in the system variable RAMTOP) without executing NEW, DOES NOT stop the lower RAM memory from expanding beyond that changed value. Q.E.D.

As a matter of fact, I have a word-processor that has over 11K bytes of programming and it will operate when the system variable RAMTOP is changed to 17408, without executing NEW. Try it with one of the longer programs in your own library.

To save memory, dimensions, strings, and variables do not have to be in a program line. They can be added to a program with direct commands before saving the program, provided GOTO (not RUN) is used to operate the program. To illustrate this, ENTER NEW and type in the following lines:

10 PRINT A
20 PRINT A$
30 INPUT B$
40 PRINT B$

Now ENTER the direct commands:

DIM B$(5)
LET A=12
LET A$="ABCDEFG"

SAVE the program. ENTER NEW to clean the memory. LOAD the program and operate it using GOTO 10. To show that the DIM was recorded, when the cursor appears ENTER more than 5 characters. This feature can also be used for program security as listing the program does not reveal what was added with direct commands.

To me there is nothing more frustrating than waiting several weeks for a new software program and it will not load when it arrives. The tape recorder I normally use with both my 1500 and 2068 is a GE Computer Program Data Recorder Model No.3-5158B. I have only had one problem, other than when the head needs cleaning, recording and loading my own programs. The one exception is with the Speedload Cartridge (Intercomputer) and that was not with the recorder, but with the tape used. You cannot use Radio Shack computer tapes with Speedload. Oddly enough it works with Radio Shack Realistic Low Noise 30 minute audio tapes. Also with KMART Lazer computer tapes as well as Memorex and Maxell UD audio types. The Speedload cartridge works only with either the 16K Rampack or the 2040 printer…not with both at the same time as the cartridge draws too many Amps.

I have had no problems loading Timex, Aerco, Scientific Software, or Bob Berch produced programs. They all load over a wide range of volume control settings.

Most of the software produced by IPC (International Publishing and Software Inc.) sold by Gladstone, is either on poor tapes or produced by bad recording methods. The width of a human hair on the volume control setting determines a successful load. These particular programs have security measures to prevent them from being copied once they have been loaded into the computer. Fortunately, there is a remedy. I borrowed a Realistic CTR-55 recorder from a friend. Connected the Ear output from the CTR to the Mic input of the GE, using a miniplug 40db signal reducer (from Radio Shack- $2.00) and re-recorded the programs using only battery power. The new back-up tapes load without any problem.

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.