TWENEX's BASIC programming system is LOTS BASIC, developed at Stanford University.
Start BASIC with the EXEC command BASIC. Return to EXEC with the BASIC command MONITOR.
The following tutorial is adapted from chapter 17. "Using BASIC" in LOTS DECSYSTEM-20 Overview Manual1) . (The referenced chapter contains additional information on LOTS BASIC file manipulation and other commands.)
(Although not strictly relevant to LOTS BASIC, a description of the BASIC programming language largely the same as that supported by LOTS BASIC can be found in DECsystem-10 BASIC Conversational Language Manual2) .)
For those already familiar with BASIC and who would like a summary of LOTS BASIC commands, skip the following example and see BASIC Command Summary.
Here is an example of how you might start BASIC, enter a program and run it, then leave BASIC. In the example, what the user types in is underlined. We start in the EXEC, which prompts with the @. The BASIC command starts the BASIC program.
@basic
Welcome to LOTS-BASIC
For help, type HELP
To exit, type MONITOR
BASIC types a greeting message, spaces down a line and stops. We may no begin typing in our program, including the line numbers. At the end of each line we press the RETURN key; BASIC will then be ready to accept another line or a command.
10 print "Type in a number"
20 input a
30 if a=0 go to 70
40 let s2=a*a
50 print "The square of",a,"is",s2
60 go to 10
70 stop
We have finished typing in the program, so we ask BASIC to run it by typing the RUN command. BASIC knows this command is not part of the program because it does not begin with a line number. BASIC types out the name of the program and the date and time. The heading "NONAME" stems for the fact that we haven't named the program yet.
run
NONAME 17:00 10-Aug-84
? NO END INSTRUCTION
TIME: 0.04 SECS.
READY
BASIC tells us that the program needs an END statement, then it tells us how long the run took. When BASIC types READY, it means that it is waiting for another command or a new program line. We need to add an END statement, which is always the last line in a program. We can give it any number greater than 70. The line numbers aren't required to be incremented by tens.
100 end
Now our program should run, so we try it again. The "?" tells us that we should type something in. We type in a 15 and BASIC tells us the square of it.
run
NONAME 17:01 10-Aug-84
Type in a number
? 15
The square of 15 is 225
Type in a number
? 666
The square of 666 is 443556
Type in a number
? 0
TIME: 0.24 SECS.
READY
By the way, you probably understood the program as it was written, without any commentary on our part; this illustrates the advantage of BASIC: it is easy to understand. Now let's add one more line.
55 print "And that's the truth!"
It makes perfect sense to insert this line between lines 50 and 60, and this is what BASIC does. Let's see what the program looks like now. The "NH" we append to the "LIST" stands for "no header".
listnh
10 PRINT "Type in a number"
20 INPUT A
30 IF A=0 GO TO 70
40 LET S2=A*A
50 PRINT "The square of",A,"is",S2
55 PRINT "And that's the truth!"
60 GO TO 10
70 STOP
100 END
READY
We rerun the program to see the effect of the new line.
runnh
Type in a number
? 4
The square of 4 is 16
And that's the truth!
Type in a number
? 0
TIME: 0.19 SECS.
READY
Having put so much effort into our program, we would like to keep it around for later use. In saving it, we decide to give it the name TEST.
save test
READY
In the future, when we are in BASIC and want to retrieve this program, we would use the command "OLD TEST". We have reached the end of our example, se we return to the EXEC.
monitor
@
We will find our saved program on our disk area under the name TEST.BAS.
This is a summary of commands in version 17D of LOTS BASIC.
In the commands above which accept such arguments, if "dev:" is omitted, "DSK:" is assumed; if ".typ" is omitted, ".BAS" is assumed. A null file type is indicated by "." with no "typ". The SAVE, REPLACE, and UNSAVE commands allow the "filenm" part of the argument to be omitted, in which case ".typ" must be omitted also and the name and file type of the program currently in core are assumed.
The keywords of commands (CATALOG, LIST, etc.) may be abbreviated to their first three letters. Only the three letter abbreviation and the full word form are legal; intermediate abbreviations such as CATAL, for example, are not allowed. If an intermediate abbreviation is used, the extra letters will be seen as part of the command argument (because BASIC does not see blank spaces or tabs at command level.) For example, "CATAL SX:" would be seen as a request to catalog the device "ALSX:". An example of a legal abbreviated command is: CAT DOC:
Whenever BASIC finishes executing a command, it types "READY". It does not answer "READY" after deleting a line by the alternate method described under the delete command or after receiving a line for the program currently in core from the user's terminal.
To insert or replace a line in the program currently in core, simply type the line and then press the RETURN key. BASIC distinguishes between lines (which must be stored or erased) and commands (which must be processed) by the fact that a line always begins with a line number whereas commands all begin with letters.