Windows Console Mini-Basic USER'S GUIDE INTRODUCTION Mini-Basic is an adaptation of original TINY BASIC. The TINY BASIC language originated in the pages of Dr. DOBB'S JOURNAL and PEOPLE'S COMPUTER COMPANY in late 1975 and early 1976. The TINY BASIC language supports a very limited subset of the Dartmouth BASIC language and does not support strings. Then, why MINI-BASIC ? Well, first for my pleasure, the size is still small (about 20 Kb. PE file). For Basic programmers, it is efficient and easy to learn, and may be usefull at least for education and small applications. For asm programmers, it may be considered as a toy to play with, study program structure, modify, enhance, add new commands... The present version of MINI-BASIC is based on Li-Chen Wang's Palo Alto 8080 TINY BASIC as published in the May 1976 issue of DR. DOBB'S JOURNAL. It has been optimized for 32 bits microprocessors and Windows console environment. Other enhancements include the use of an internal line editor. This manual uses large parts of original TINY BASIC documentation. THE LANGUAGE Numbers In MINI-BASIC, all number are 32 bits signed integers and must be within the range of -2 147 483 647 .. 2 147 483 647. Variables There are 26 scalar variables donoted by the letters A through Z. The one array variable is denoted by '@(I)'. Its dimension is originally limited to 2000 cells in source code, but it can be extended to hundreds thousands of cells if you really need it. Functions There are four functions in MINI-BASIC. ABS(X) - Returns the absolute vaulue of the variable X. PEEK(X)- Returns the contents of 8 bits memory location X in Basic text area. RND(X) - Returns a random number between 1 and X (inclusive). SIZE - Returns the number of bytes left unused by the program Arithmetic and Comparison Operators The following operators are supported: / - integer divide (fractional results not returned) * - integer multiply - - subtract + - add > - compare if greater than < - compare if less than = - compare if equal to NOTE: multiple assignment statements are not supported, i.e., "A=B=O" is interpreted by MINI-BASIC as meaning "set A to the result of comparing B with 0 <> - compare if not equal to >= - compare if greater than or equal to <= - compare if less than or equal to The +,-,*, and / operations return a value within the range -2 147 483 647.. 2 147 483 647. All compare operations result in a 1 if the comparison is true and a 0 if it is false. Expressions Expressions are formed with numbers, variables, and functions with arithmetic and compare operators between them. + and - signs can also be used at the beginning of an expression. The value of an expression is evaluated from left to right, except that the * and / operators are always given precedence, with + and -, and then the compare operators following, in that order. Parentheses can be used to alter the order of evaluation in the standard algebraic sense. Statements A MINI-BASIC statement consists of a statement number between 1 and 99999 followed by one or more commands (see Commands below).Commands in the same statement are seperated by a colon ":".If the "GOTO", "STOP", and "RETURN" commands are used then they must be the last command in that statement. Program A MINI-BASIC program consists of one or more statements. When the direct command (see Direct Commands below) "RUN" is issued, the statement with the lowest statement number is executed first, then the one with the next lowest statement number, etc. The "GOTO", "GOSUB", "STOP", and "RETURN" commands can alter this normal sequence. Within any statement the execution takes place from left to right. The "IF" command can cause remaining commands within the same statement to be skipped. Blanks MINI-BASIC statements and commands may use blanks freely, except that numbers, command key words, and function names may not have embedded blanks. Editor MINI-BASIC contains a useful line editor for entering and correcting MINI-BASIC programs. Maximum line length allowed is 255 char. All of the line editing features of a standard editor are used : - Right and left arrows to go right and left in the edited line - Home and End keys move cursor to top or end of line - Del and BackSpace keys to cancel a char. preceding or following cursor position - Insert to switch between normal and insert mode. Insert is the mode by default, and cursor appearence is modified, depending of the mode used. - Alt+num. sequence to enter an ASCII code character The EDIT nn command allows to correct an existing MINI-BASIC statement. Statements may be deleted by simply typing their statement number, followed by a CR. Corrections may be verified by typing LIST nn and striking the Escape to terminate the LIST process. ERROR MESSAGES There are 23 error messages in MINI-BASIC. When an error is encountered the error message itself is printed, followed by the statement causing the program error. Control is then passed to the MINI-BASIC editor. STATEMENT COMMANDS MINI-BASIC statement commands are listed below with examples. Remember that commands can be concatenated with semi-colons. In order to store any given statement, you must precede that statement with a statement number between 1 and 32767. Statement numbers are NOT shown in the examples. LET command LET A=234-5*6;A=A/2;X=A-100;@(X+9)=A-1 The LET command assigns the value of an expression to the specified variable. In the example above, the variable "A" assumes the value of the expression "234-5*6", or "204". Then the variable "A" assumes the value "102". Next, the variable "X" is set to the value of the expression "A-100", or "2". The last command assigns the value "101" to the array variable "@(11)". The "LET" portion of the LET command is optional, i.e., the following examples are true: A=10 C=5*3/5;C=C*5 REM Command REM ANYTHING CAN BE WRITTEN AFTER "REM" The REM command is ignored by TINY BASIC. It is used by experienced programmers to comment BASIC programs. A program comment is used by programmers to remind themselves of the logic of a program section. All good programs are invariably commented. PRINT Command PRINT PRINT will cause a carriage-return (CR) and a line-feed (LF) on the output device. PRINT A*3+1,"ABC" This form of the PRINT command will print the value of the expression A*3+1 on the output device, followed by the string ABC on the same line. Note that single (') or double quotes (") may be used to denote character strings, but that pairs must be mached. PRINT A*3+1,"ABC", This form of the PRINT command will produce the same results as the previous example except that the normal CR-LF is inhibited by the trailing comma at the end of the statement. This allows other PRINT commands to print on the same line. PRINT A,B,#3,C,D,E,#10,F,G This form of the PRINT command demonstrates format control. The format character # is used to indicate the number of leading spaces to be printed before a number. The default number is 6. Once the # format is invoked it is active for the remainder of the statement unless overridden by a subsequent format specifier, as in the example. PRINT 'ABC',\,'XXX' The back-slash (\) character is used to cause a CR without a LF. In this example, the string ABC is printed followed by the string XXX on top of the original ABC. INPUT Command INPUT A,B The INPUT statement is used to acquire input data during program execution. In the example above, MINI-BASIC will print A: and wait for a number to be typed at the console terminal. Next, MINI-BASIC will print B: and wait for another number to be typed at the console terminal. In this example the variables A and B will assume the values of the appropiate input values. The INPUT statement will accept expressions as well as numbers as input. INPUT 'WHAT IS THE WEIGHT'A,"AND SIZE"B In this example MINI-BASIC will print the string WHAT IS THE WEIGHT: and wait for operator input. Next, the string AND SIZE: will be printed, on the same line, and MINI-BASIC will wait for operator input. INPUT A,'STRING',\,"ANOTHER STRING",B MINI-BASIC will react to the back-slash character (\) in this example in the same fashion as in the PRINT command. The second string will overwrite the first string STRING. IF Command IF A' prompt). All statement commands (those listed above) can be invoked while in command mode. Typing a control-C while in command or monitor mode will cause TINY BASIC to terminate. Control is then passed to the host operating system monitor. Recall that a statment consists of a statement number followed by one or more commands. If the statement number is missing, or if it is 0, the command will be executed immediatly after typing the terminating CR. The following commands can be used as direct commands; they CANNOT be used as part of a MINI-BASIC statement. RUN Command RUN The RUN command causes execution of the stored TINY BASIC program. Execution will commence at the lowest numbered statement and continue until there are either no more statements to execute or a STOP command is found. A long MINI-BASIC program may be terminated by typing control-X at the console. This passes control the the TINY BASIC monitor. A control-C may be typed at any time also, then TINY BASIC is terminated and control is passed to the host operating system. LIST Command LIST The LIST command is used to display the current TINY BASIC program on the operator's console. The statements will be listed in numerical order. If LIST is followed by an expression (e.g. LIST 200) the listing will commence with statements following the specified statement, inclusive. NEW Command NEW The NEW command deletes the current program from TINY BASIC's memory. SAVE Command SAVE FILENAME The SAVE command saves the current TINY BASIC program on the logged in disk with the specified filename FILENAME. The default filetype is ".TBI". If there is insufficient room on the disk, the SAVE command responds with "HOW?". LOAD Command LOAD FILENAME The LOAD command loads the specified MINI-BASIC program from the logged in disk into the program area. Any program residing within TINY BASIC prior to the LOAD operation is lost. If the specified program is not found on the disk, or if there is insufficient room for the program, LOAD responds with "HOW?". The filetype is assumed to be ".TBI". BYE Command BYE The BYE command terminates MINI-BASIC. Control is passed back to the host operating system. MINI-BASIC OPERATION MINI-BASIC is initiated from the host operating system's command mode like any other transient command. TINY BASIC will sign-on, announce 'OK', and then prompt '>' awaiting operator interaction. An example follows: A:TBASIC 8086 MINI-BASIC V1.0 OK > In the example above the program 'TBASIC.COM' was found on the logged-in disk ('A' in the example). TINY BASIC then commenced execution by first announcing itself and then prompting '>' for operator input. MINI-BASIC utilizes all of the host operating system's line editing facilities. For example, if an operator wished to cancel a line typed to MINI-BASIC, he need only type a control-X, etc. If hard copy of a MINI-BASIC session is desired, control-P and control-N will toggle the printer, if it exists. At present, saved MINI-BASIC programs can be edited only with the internal TINY BASIC editor. Programs prepared by an external editor can not be read by MINI-BASIC.