This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tutorials:basic [2013/07/14 16:05] irl created |
tutorials:basic [2024/10/04 04:14] (current) papa [Using BASIC] |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Using BASIC ====== | ||
+ | |||
+ | TWENEX' | ||
+ | |||
+ | Start BASIC with the EXEC command '' | ||
+ | |||
+ | The following tutorial is adapted from chapter 17. "Using BASIC" in //LOTS DECSYSTEM-20 Overview Manual//(( | ||
+ | //LOTS DECSYSTEM-20 Overview Manual//. (1984). Accessed: October 1, 2024. [Online]. Available: | ||
+ | http:// | ||
+ | |||
+ | (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 // | ||
+ | ===== BASIC Example ===== | ||
+ | |||
+ | 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|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 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. | ||
+ | |||
+ | > '' | ||
+ | > '' | ||
+ | > '' | ||
+ | > '' | ||
+ | > '' | ||
+ | > '' | ||
+ | > '' | ||
+ | |||
+ | 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 " | ||
+ | |||
+ | > '' | ||
+ | > '' | ||
+ | > ''? | ||
+ | > '' | ||
+ | > | ||
+ | > '' | ||
+ | |||
+ | 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. | ||
+ | |||
+ | > '' | ||
+ | |||
+ | Now our program should run, so we try it again. The "?" | ||
+ | |||
+ | > '' | ||
+ | > | ||
+ | > '' | ||
+ | > | ||
+ | > '' | ||
+ | > ''? | ||
+ | > '' | ||
+ | > '' | ||
+ | > ''? | ||
+ | > '' | ||
+ | > '' | ||
+ | > ''? | ||
+ | > '' | ||
+ | > | ||
+ | > '' | ||
+ | |||
+ | 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. | ||
+ | |||
+ | > '' | ||
+ | |||
+ | 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 " | ||
+ | |||
+ | > '' | ||
+ | > | ||
+ | > '' | ||
+ | > '' | ||
+ | > '' | ||
+ | > '' | ||
+ | > '' | ||
+ | > '' | ||
+ | > '' | ||
+ | > '' | ||
+ | > '' | ||
+ | > | ||
+ | > '' | ||
+ | |||
+ | We rerun the program to see the effect of the new line. | ||
+ | |||
+ | > '' | ||
+ | > | ||
+ | > '' | ||
+ | > ''? | ||
+ | > '' | ||
+ | > '' | ||
+ | > '' | ||
+ | > ''? | ||
+ | > '' | ||
+ | > | ||
+ | > '' | ||
+ | |||
+ | 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. | ||
+ | |||
+ | > '' | ||
+ | > | ||
+ | > '' | ||
+ | |||
+ | 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. | ||
+ | |||
+ | > '' | ||
+ | > '' | ||
+ | |||
+ | We will find our saved program on our disk area under the name TEST.BAS. | ||
+ | |||
+ | ===== BASIC Command Summary ===== | ||
+ | |||
+ | This is a summary of commands in version 17D of LOTS BASIC. | ||
+ | |||
+ | |CTRL/ | ||
+ | |BYE|Logs you completely off the system.| | ||
+ | |CATALOG dev:|Lists onto the user's terminal the names of the user's files which exist on the specified device.| | ||
+ | |COPY dev: | ||
+ | | |Copies the first file onto the second.| | ||
+ | |DELETE line number arguments|| | ||
+ | | |Erases the specified lines from core. For example, " | ||
+ | |LIST line number arguments|| | ||
+ | | |Lists the specified lines of the program currently in core onto the user's terminal. The line number arguments are of the form described under the delete command. If no arguments are specified, the entire program is listed.| | ||
+ | |MONITOR|Returns to the EXEC. BASIC may be resumed via CONTINUE. This is just like CTRL/C for most non-BASIC programs. BASIC intercepts CTRL/C aside from returning to BASIC command level.| | ||
+ | |NEW dev: | ||
+ | | |The program currently in core is erased from core and the specified filename is established as the name of the " | ||
+ | |OLD dev: | ||
+ | | |The program currentloy in core is erased from core and the specified file is pulled into core to become the new " | ||
+ | |RENAME dev: | ||
+ | | |Changes the name of the program currently in core to the specified name.| | ||
+ | |REPLACE|See SAVE.| | ||
+ | |RESEQUENCE|Changes the line numbers of the program currently in core to 10, 20, 30,.... (Line numbers within lines (as, GO TO 1000) are changed appropriately).| | ||
+ | |RUN|Compiles and executes the program currently in core. The command RUNNH is equivalent, but runs the program without printing a header.| | ||
+ | |SAVE dev: | ||
+ | | |Writes out the program currently in core as a file with the specified name. BASIC will return an error message if save attempts to write over an existing file; to write over a file you must type " | ||
+ | |SCRATCH|Erased from core the program currently in core.| | ||
+ | |SYSTEM|Exits from BASIC to monitor level. N.B., the contents of core are lost. You must give the EXEC command REENTER rathre than CONTINUE, START, or BASIC to resume the current BASIC program. " | ||
+ | |UNSAVE dev: | ||
+ | | |Deletes the specified file. More than one file can be specified; for example, UNSAVE DSK: | ||
+ | |||
+ | In the commands above which accept such arguments, if " | ||
+ | |||
+ | 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 " | ||
+ | |||
+ | Whenever BASIC finishes executing a command, it types " | ||
+ | |||
+ | 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. | ||
+ | |||