0‑999: | Standard routines (see section 3). These routines are different for each computer and are therefore contained in the translation program. |
1000: | first line of the BASICODE-2 program. It must be in the following form: 1000 A=(value): GOTO 20: REM program name. (value) is the maximum number of characters that can be used by all strings together. Line 20 is used to reserve memory space for the strings in those computers which need it. |
1010‑32767: | the main program. There are no restrictions on this section, except that line numbers above 32767 are forbidden. |
1000‑19999: | the main program. |
20000‑24999: | subroutines which you need for your program, but which contain statements which are not allowed in BASICODE-2. |
25000‑29999: | lines with DATA statements. |
30000‑32767: | lines with REM statements. You can use this space for any background details about the program, references or your name and address. |
ABS | INPUT | RESTORE |
AND | INT | RETURN |
ASC | LEFT$ | RIGHT$ |
ATN | LEN | RUN |
CHR$ | LET | SIGN |
COS | LOG | SIN |
DATA | MID$ | SQR |
DIM | NEXT | STEP |
END | NOT | STOP |
EXP | ON | TAB |
FOR | OR | TAN |
GOSUB | THEN | |
GOTO | READ | TO |
IF | REM | VAL |
+ | ^ | <> |
- | = | <= |
* | < | >= |
/ | > |
ABS | Gives the absolute value of the stated variable. For example:
| ||||||
AND | Logic AND, can only be used for logic variables. The result is a logical result. Use brackets to show clearly the order in which the work is to be done. Examples: IF (A=5) AND (B=0) THEN …. Q=(A-5) AND (B=0): IF Q THEN…. | ||||||
ASC | This gives the ASCII value of the first character of the given string. Examples:
| ||||||
ATN | Gives the arctangent in radians of the given variable. For example: PRINT ATN(1) 0.785398 PRINT ATN(-1) -0.785398 | ||||||
CHR$ | This gives a character with the same ASCII value as the given variable. The variable can be anywhere between 32 up to and including 127. Be very careful with values less than 32, since control characters on different brands of computers vary. Only the RETURN key always has the same value, ASCII code 13. In addition not all computers recognise lower case letters. So be careful with ASCII codes larger than 96. For example:
| ||||||
COS | This gives the cosine of the given angle in radians. For example: PRINT COS(1) .540302 | ||||||
DATA | After this term will follow numbers and/or strings until the end of the line, which can be read using READ. On a DATA line there should be no other statements, such as REM. The elements should be separated by a comma. String variables must be placed between quotation marks. For example: DATA 100,200,"HELLO","BASICODE",4,6,89 | ||||||
DIM | This statement is used to dimension arrays. An array can only be dimensioned once in a program, and before it is used. The maximum number of dimensions is two, whilst the maximum number of elements is limited by the size of the memory. One DIM statement can be used for more than one array. But there are two points to note:
| ||||||
END | Used to indicate the end of a program. Do not just let a program stop. Always finish with an END statement. | ||||||
EXP | Raises the number e (=2.71828…) to a specified power. For example: PRINT EXP(2) 7.38906 | ||||||
FOR…TO…STEP…NEXT… | Program loop construction. The loop will be used at least once. STEP can be left out, in which case the step is automatically 1. NEXT must only be followed by a single variable. For example: FOR X=10 TO 100 Program in loop NEXT X FOR C=A TO B STEP -3 Program in loop NEXT C FOR I=1 TO 10:FOR J=1 TO 5 Program in loop NEXT J:NEXT I Note: don't jump out of a FOR-NEXT loop before it has ended. A way to end the loop is by raising the variable to exceed the end point. | ||||||
GOSUB | Used to call a subroutine and indicated by the line number following the statement. For example: GOSUB 100. Note, though, that A=100:GOSUB A is not allowed. | ||||||
GOTO | Indicates a jump to a given line number. For example: GOTO 1500 Note, though, that A=1500:GOTO A is not allowed. | ||||||
IF…THEN | Conditional split, for between IF and THEN will be logical variables or logical comparisons. If the logic is "true" then the process continues through to statements after THEN. If not, then the computer simply moves to the next line. A line number may be given after THEN, from which the program should continue. Note that ELSE is forbidden in BASICODE-2. For example: IF A=3 THEN B=0: C=5 IF A>3 THEN 1500 C=(A>3):IF C THEN GOSUB 100 Note: Use IF…THEN 2000 and not: IF…GOTO 2000. Use IF…THEN GOSUB 2000 and not: IF…GOSUB 2000 | ||||||
INPUT | Asks the user to input either a number or a string variable. A string may not consist of either commas or colons. If commas or colons are needed, then it is better to make use of subroutine 210. A prompt string is not allowed, and neither is more than one variable after an INPUT. Most BASICs print a question mark on the screen to show that input is required. In some computers, when the RETURN key is pressed, the line from the last cursor point to the end of the line is erased. Examples: PRINT "WHAT'S YOUR NAME": INPUT N$ PRINT "KEY VALUE IN": INPUT A: INPUT B But note!! INPUT "YOUR NAME";A$ is forbidden. | ||||||
INT | Gives the pargest who number (integer) less than or equal to the given variable. For example:
| ||||||
LEFT$ | Used to select a number of characters from a given string starting with the character farthest to the left. You may select a minimum of 1 character up to the maximum number of characters in the string. For example: A$=LEFT$("BASICODE",5) A$ now consists of "BASIC". But note that C$= LEFT$("BASICODE",0) is not allowed. | ||||||
LEN | Reports the length of a given string. For example:
| ||||||
LET | The variable name left of the equal sign is assigned the value of the strong or expression to the right of the equal sign. It is not really necessary, since LET A=5 is the same as A=5. | ||||||
LOG | Calculates the natural log of the given variable or expression. For example: PRINT LOG(1) 0 PRINT LOG(10) 2.302585 | ||||||
MID$ | Takes a number of characters from a string. MID$(A$,X,Y) gives Y characters from A$, beginning with the Xth character. Note that the first character is number 1, so X=0 or Y=0 is forbidden. For example: A$="THIS IS BASICODE" B$=MID$(A$,9,8) B$ now consists of "BASICODE" | ||||||
NEXT | Closing statement for a program loop (see FOR). A NEXT statement must always be followed by a variable. Examples are given under FOR. | ||||||
NOT | Logic negation, only usable on logic variables (see also AND). For example:
| ||||||
ON…GOSUB… ON…GOTO… | Makes a jump to either a subroutine or a program line. After ON follows an expression or variable. After GOSUB or GOTO follows a series of line numbers. The expression or variable should be a whole number and determines which line number is to be chosen. You can think of the line numbers as having numbers: if the variable is 1 then the first line number is chosen, if the variable is 2 then the second line number is chosen, etc. But the variable cannot be greater than the number of line numbers given. For example:
| ||||||
OR | Logic OR can only be used with logic variables (see AND). For example: IF A=5 OR B<3 THEN… C=(A-5) OR (B<3):IF C THEN… | ||||||
Prints a variable or a string on the screen beginning at the present cursor position. More than one variable in a PRINT statement must be separated by semi-colons. If it is not desired that the computer should automatically continue with the next line then the end of the instruction must be finished off with a semi-colon. Some computers print one or more spaces before and/or after the number(s) being printed. If you do not want this, then use subroutine 300 or 310. For example: A=5:A$="HELLO":PRINT A:A$ 5HELLO PRINT "HELLO":PRINT "THERE" HELLO THERE CN=3:CT=5:SR=5:GOSUB 310:PRINT "FIVE=";SR$ FIVE=5.000 | |||||||
READ | Reads the elements after the DATA statements and gives them to variable(s) which follow the READ statement. More than one variable after a READ statement should be separated by commas. After the RUN command, the computer will read the DATA starting with the lowest line number. All data on that line will be read before continuing with any other DATA lines. But note: A numeric variable must read only numbers, a string variable can only read strings. For example: DATA 1,"COMPUTER",3 READ A,A$:READ B or READ A:READ A$:READ B or READ A,A$,B | ||||||
REM | This is used for adding REMarks in the program to help other users understand what you are doing. Anything after a REM statement until the end of the line is ignored in BASIC by the computer. But do not use a colon after the REM statement as this gives problems with some computers. | ||||||
RESTORE | This statement resets READ-ing from the first DATA statement in the program. But note that you may not give a line number after a RESTORE statement. | ||||||
RETURN | Is used to indicate the end of a subroutine. The computer then jumps back to the line after the respective GOSUB statement that started the subroutine sequence. A subroutine should always be closed with a RETURN statement. | ||||||
RIGHT$ | Gives a number of characters of a given string, ending with the last character. The minimum number that can be asked is 1, the maximum being the length of the string. For example:
| ||||||
RUN | Starts the program afresh, while all variables are erased. Note that a line number after RUN is not allowed. For example: IF (A$="J") OR (A$="j") THEN RUN Note that RUN 100 is forbidden. | ||||||
SIN | Gives the sine of a variable which should be given in radians. See COS for further details. | ||||||
SGN | Is used to give the sign of a variable, i.e. -1 if the variable is negative, 0 if the variable is zero, and +1 if the variable is positive. For example:
| ||||||
SQR | Calculates the square root of a variable or expression, which cannot be negative. For example:
| ||||||
STEP | Sets the step size in a loop. See FOR. | ||||||
STOP | Stops the program, but retains the possibility of going further, keeping the same variables. | ||||||
TAB | Is used in PRINT statements to move the cursor to a specific point on the screen. You can only use TAB to move the cursor further on a line, and depending on the computer, either spaces will be printed or whatever is on the line will be kept. Note that TAB(0) is not allowed. Although most computers start counting at 0, there are those that start at 1. So for this reason it is better to use subroutine 110. For example: PRINT "A";TAB(5);"B";TAB(10);"C" gives:
| ||||||
TAN | Calculates the tangent of a given angle in radians. See COS. | ||||||
THEN | See IF. | ||||||
TO | See FOR. | ||||||
VAL | Gives the numeric VALue of a string. But if the string is not purely numeric, the result is not the same on all computers. For example:
| ||||||
Summary | |||||||
Now follows a short summary of the operators allowed in BASICODE-2. | |||||||
+ | In the case of numbers of variables this operator adds two numbers or variables together. In the case of strings, two are coupled to each other. For example:
| ||||||
- | Subtracts two numbers or variables from each other. For example:
| ||||||
* | Multiplies two numbers or variables together. For example:
| ||||||
/ | Divides two numbers or variables. For example:
| ||||||
△ | Raises a number or variable to a specified power. For example:
| ||||||
= | Logic operator: indicates equality between the two expressions on either side of it. See also AND. Or: the variable name to the left of the equal sign is assigned the value of the string or expression to the right of the equal sign. Examples:
| ||||||
< | Compares two numbers or expressions and checks whether the one to the left of the operator is less in value than the one to the right. The result is therefore a logic variable. If strings are being compared, then the string to the left of the operator is checked to see if it comes earlier in alpha-numeric order than the string to the right. You can use this operator for alphabetical sorting. For example:
| ||||||
> | Identical to < except that the test is now "greater than" or "later" in alpha-numeric order. | ||||||
<> | Checks to see whether two variables or expressions are "un-equal". The result is a logical value. For example:
| ||||||
<= | Less than or equal to. For the function of this operator see <, but substitute "less than or equal to" in place of "less than". | ||||||
>= | Greater than or equal to. For the function of this operator see >, but substitute "greater than or equal to" in place of "greater than". | ||||||
Note: When using the last three operators the order of the two characters is important. For example: A=>5 is wrong. | |||||||
We trust the BASICODE-2 protocol is explained clearly enough, and look forward to your program contributions. For details of how to contribute, see Chapter One. | |||||||
Jochem Herrmann |