TOPS-20 User's Guide
Appendix D Using BASIC
If you want to enter and run a BASIC program using BASIC-PLUS-2, type in your program directly to BASIC; you should not use EDIT. The following sections show how to start BASIC, and then how to enter, save, run, edit, rerun, and list your program. Section D.10 shows you how to leave BASIC.
- Starting BASIC
- Entering your program
- Saving your program
- Running your program
- Editing your program
- Renaming your program
- Rerunning your program
- Listing your program
- Running an existing program
- Leaving BASIC
D.1 Starting BASIC
After you see the @, type BASIC, and press the RETURN key. BASIC prints READY.
@BASIC READY
Once BASIC prints READY, you can use any of the BASIC commands discussed in this section. You must not, however, use any TOPS-20 command or recognition input.
D.2 Entering your program
- After you see READY, type NEW to enter a new file into
your working area in the computer. Press the RETURN key.
READY NEW New Program Name--
- After you see New Program Name--, type a name for your
program, and press the RETURN key. The program name can
have up to 39 letters and numbers. The following example
shows using the name SQUARE for the new program name:
New program name--SQUARE READY
- After you see READY, begin typing your program. Type line numbers at the beginning of each line of your program. Press the RETURN key at the end of each line.
The example shows a BASIC program as it was originally entered; the program contains an error that is corrected later in this section.
100!SQUARE.B20 - THIS PROGRAM CALCULATES A SQUAREROOT. 200 PRINT "TYPE A NUMBER." 300 INPUT X 400 Y = SQR(X) 500 PRINT "THE SQUAROOT OF ";X;" IS ";Y 600 STOP 700 END
D.3 Saving your program
After you enter your program into your working area, type SAVE, and press the RETURN key. When you see READY, it means that BASIC saved the program you just typed into your storage area. By saving your program, you can run it at a later time without having to reenter it into the computer. (Refer to Section D.9).
SAVE READY
To see a list of the files saved in your storage area, type CATALOG, and press the RETURN key.
CATALOG ADDTWO.FOR.2 FACTOR.B20.1 RANDOM.B20.2 SQRT.ALG.2 SQUARE.B20.1 READY
D.4 Running your program
To run the program in your working area, type RUN, and press the RETURN key. You wil see the name of your program, the time, and the date. When you see READY, your program has finished running.
RUN SQART.B20 Friday, June 10, 1988 09:13:16 TYPE A NUMBER. ? 45.668 THE SQUAREOOT OF 45.668 IS 6,75781 STOP at line 00600 of MAIN PROGRAM Compile time: 0.054 secs Run time: 0.138 secs Elapsed time: 0:00:08 READY
D.5 Editing your program
To edit the program in your working area:
- Type the number of the line that you want to change.
- Type the new contents of the line.
- Press the RETURN key.
500 PRINT "THE SQUAREROOT OF ";X;" IS ";Y
D.6 Renaming your program
To rename an existing BASIC program in your storage area:
- Type RENAME.
- Type the new program name.
- Press the RETURN key.
RENAME SQART READY
D.7 Rerunning your program
Now that you have changed your program, run it to make sure that it works properly.
RUN SQUARE.B20 Friday, June 10, 1988 09:11:44 TYPE A NUMBER. ? 45.668 THE SQUAREROOT OF 45.668 IS 6.75781 STOP at line 00600 of MAIN PROGRAM Compile time: 0:086 secs Run time: 0.229 secs Elapsed time: 0:00:10 READY
D.8 Listing your program
To get a final copy of your corrected program, type LIST, and press the RETURN key.
LIST SQART.B20 Tuesday, February 6, 1988 11:03:31 00100!SQUARE.B20 - THIS PROGRAM CALCULATES A SQUAREROOT. 00200 PRINT "TYPE A NUMBER." 00300 INPUT X 00400 Y = SQR(X) 00500 PRINT "THE SQUAREROOT OF ";X;" IS ";Y 00600 STOP 00700 END READY
To list a single line of your program, type LIST, type the line number of the line, and press the RETURN key.
LIST 500 SQART.B20 Tuesday, February 6, 1988 11:03:40 00500 PRINT "THE SQUAREROOT OF ";X;" IS ";Y READY
D.9 Running an existing program
To run an existing BASIC program, you must do two things:
- Move a copy of the program from your storage area into your working area.
- Type the RUN command.
To move a copy of an existing program into your working area and run the program:
- Type OLD.
- Type the program name.
- Press the RETURN key.
- Type RUN.
- Press the RETURN key.
OLD FACTOR READY RUN<RET> FACTOR Tuesday, February 6, 1988 11:28:46 FIND THE FACTORIAL OF: ? 6<RET> THE FACTORIAL OF 6 IS 720 RUNTIME: 0.563 SECS ELAPSED TIME: 0:00:51 READY
D.10 Leaving BASIC
To leave BASIC, type MONITOR, and press the RETURN key. When you see the @, you can type any TOPS-20 command.
MONITOR @
To leave BASIC and log out automatically, type BYE.