Reference for all commands used in STTR1.
A letter from A to Z; or a letter immediately followed by a number (from 0 to 9).
Examples: A0, B, M5, C2, Z9, D
Variables are used to represent numeric values.
There are two other types of variables, string variables and array variables.
The following format specifiers are used in STTR1:
Format specifier | Meaning |
---|---|
D | one digit |
3D | 3 digits, left padded with spaces |
4D | 4 digits, left padded with spaces |
5D | 5 digits, left padded with spaces |
6D | 6 digits, left padded with spaces |
8X | 8 spaces |
9X | 9 spaces |
11X | 11 spaces |
15X | 15 spaces |
3A | 3 characters of a string; left padded with whitespace? |
6A | 6 characters of a string; left padded with whitespace? |
3(3D," :") | 3 times: 3 digits followed by " :" |
8(X,3A) | 8 times: 1 space followed by 3 characters of a string |
8(3X,3D) | 8 times: 3 characters of a string followed by 3 digits |
Functions return a numeric result; they may be used as expressions or parts of expressions. PRINT is used for examples only; other statement types may be used.
Full Name | Example | Purpose |
---|---|---|
DEF FN |
DEF FNA(X)=(M*X)+B |
Allows the programmer to define functions; the function label (A) must be a letter from A to Z; the argument(X) is a dummy variable. |
ABS(X) |
310 PRINT ABS(X) |
Gives the absolute value of the expression (X). |
INT(X) |
330 PRINT INT(X) |
Gives the largest integer ≤ the expression (X). |
RND(X) |
350 PRINT RND(X) |
Generates a random number greater than or equal to 0 and less than 1; the argument (X) may have any value. A negative argument is used to restart a sequence of random numbers. |
SQR(X) |
360 PRINT SQR(X) |
Gives the square root of the expression (X); expression must have a positive value. |
TIM(X) |
460 PRINT TIM(X) |
Gives current minute (X=0) 0-59 or hour (X=1) 0-23. |
NOTES:
- Absolute maximum matrix size is 4900 elements.
- Matrix variables must be a single letter from A to Z.
Name | Sample Statement | Purpose |
---|---|---|
DIM |
10 DIM A (10,20) |
Allocates space for a matrix of the specified dimensions. |
MAT ZER |
MAT B=ZER |
Sets all elements of the specified matrix equal to 0. |
NOTES:
- A string is 1 to 72 characters enclosed in quotes; it may be assigned to a string variable (an A to Z letter followed by a $).
- Each string variable used in a program must be dimensional (with a DIM statement) if it has a length of more than one character. The DIM sets the physical or maximum length of a string.
- Substrings are described by subscripted string variables. For example, if A$ = "ABCDEF", A$(2,2) = B, A$(1,4) = "ABCD" and A$(3) = "CDEF".
Full Name/Symbol | Example (Abbreviation) | Purpose |
---|---|---|
DIM |
10 DIM A$ (27) |
Declares maximum string length in characters. |
= |
20 A$="**TEXT1 |
Assigns the character string in quotes to a string variable. |
= |
105 IF A$=C$ THEN 600 |
Allows comparison of strings, and substrings and transfer to a specified statement if the comparison is true. Comparison is made in ASCII codes, character by character, left to right until a difference is found. |
INPUT |
205 INPUT N$ |
Accepts as many characters as the string can hold (followed by a return). The characters need not be in quotation marks. |
NOTE: The numeric values used in logical evaluation are:
- "true" = any nonzero number
- "false" = 0
Symbol | Sample Statement | Purpose/Meaning/Type |
---|---|---|
= |
100 A = B = C = 0 |
Assignment operator; assigns a value to a variable. |
^ |
120 PRINT X^2 |
Exponentiate (as in X²). |
* |
130 C5 = (A*B)*N2 |
Multiply |
/ |
140 PRINT T5/4 |
Divide |
+ |
150 P = R1/10 |
Add |
- |
160 X3 = R3 - P |
Subtract |
= |
170 IF D = E THEN 600 |
expression "equals" expression |
<> |
180 IF D6<>(2*D) THEN 700 |
expression "does not equal" expression |
> |
190 IF X>10 THEN 620 |
expression "is greater than" expression |
< |
200 IF R8<P7 THEN 640 |
expression "is less than" expression |
>= |
210 IF R8>=P7 THEN 710 |
expression "is greater than or equal to" expression |
<= |
220 IF X2<=10 THEN 650 |
expression "is less than or equal to" expression |
Full Name | Example | Purpose |
---|---|---|
END |
390 END |
Terminates the program; the last statement in a program must be an END statement. |
FOR...NEXT |
440 FOR J=1 TO N |
Executes statements between FOR and NEXT the specified number of times (a loop), incrementing the variable by 1. |
GOTO |
450 GOTO 900 |
Transfers control (jumps) to specified statement number. |
GOTO...OF |
460 GOTO n OF 100,10,20 |
Transfers control to the _n_th statement of the statements listed after "OF". |
GOSUB |
470 GOSUB 800 |
Begins executing the subroutine at specified statement (see RETURN ) |
IF...THEN |
490 IF A<>10 THEN 350 |
Logical test; transfers control to statement if "true". |
IMAGE |
500 IMAGE 6D,AA,SD,5DE |
Used to specify the format of a PRINT USING statement. |
INPUT |
510 INPUT X$,Y2,B4 |
Allows data to be entered from terminal while program is running. |
IF ... THEN |
490 IF A#10 THEN 350 |
Logical test; transfers control to statement number if "true". |
NEXT |
530 NEXT J |
Marks the end of the FOR loop. |
PRINT |
540 PRINT A,B,C$ |
Prints the specified values; 5 fields per line when commas are used as separators, 12 when semicolons are used. |
550 PRINT |
Causes the terminal to advance one line. | |
580 PRINT USING "3A";A$ 590 PRINT USING A$;A,B4 600 PRINT USING 200;N,A$ |
Prints the specified data according to the specified format. The format can be a string, a string variable or the statement number of an image statement containing the format string (200). The format is optionally followed by a semicolon and an expression list (A,B4). | |
REM |
630 REM ANY TEXT |
Inserts non-executable remarks in a program. |
RETURN |
660 RETURN |
Subroutine exit; transfers control to the statement following the matching GOSUB. |
The PRINT statement provides a simple and direct means for BASIC programs to display values on your terminal.
The items to be printed (print list) are evaluated and displayed in sequential order from left to right in one or more lines. Each item in the print list is separated from the following one by either a semicolon or a comma.
A semicolon serves only to separate items in the print list; the first character of the following item's value is printed immediately after the last character of the preceding item's value.
A new line is begun whenever the next value will not fit on the remainder of the current line.
A comma serves another purpose besides separating print list items.
Each line on the terminal is divided into four consecutive fields of 15 character positions and a final field of 12 character positions (72 character positions per line).
When a comma follows an item which did not completely fill the last of the one or more fields its value occupies, blanks are added to complete that field.
Thus the value of an item following a comma always begins at the start of a field.
If the previously completed field was the last one in the current line, the next item's value will be printed on a new line.
Since most values occupy less than fifteen character positions, the usual effect is a table of five columns per line.
If a comma or semicolon follows the last item in the print list, the print list of the next PRINT statement executed will be printed as a continuation of the current line.
Otherwise, the current line is completed and the next PRINT statement will begin printing values on the next line.
A PRINT statement with no item list either completes the previous line, if it ended with a comma or semicolon, or skips the current line.
This is frequently used to produce a blank line.