Vector Basic Interpreter Basic 80 Reference Manual
Reklama
Reklama
5IA)iC intc:tit=tcl:c=t
MIClOSOI"l' BASIC-88
Rsrision 5.9
RE!'ERENC!
MANUPd.
Revision A
January 1, 1988
CopyriC)ht 1988 Vector Graphic Inc.
Copyright 1979 Microsoft
Copyright 1980 by Vector Graphic Inc.
All rights reserved.
Disclaimer
Vector Graphic makes no representations or warranties with respect to the contents of this manual itself, \1ohetheror not the product it describes is covered by a warranty or repair agreement.
Further, Vector Graphic reserves the right to revise this publication and to make changes from time to time in the content hereof without obl igation of Vector Graphic to notify any person of such revision or changes, except ~en an agreement to the contrary exists.
Revisions
The date and reV1Slon of each page herein appears at the bottom of each page.
'I'he revision letter such as A or B changes if the MANUAL improved but the PRODUCT has not been significantly ItDdified.
'I'he date and revision on the Title Page corresponds to that of the page most recently revised.
When the product itself is roodified significantly, the product will get a new revia ion number, as shown on the manual's title page, and the manual will revert to revision A, as if it were treating a brand new product.
EAai MANUAL
TITLEPAGE.
'Ibis manual is intended for cemputer suppliers, or others with at least a technical knowledgeof small canputers and canputer progranming, and the basic c:p!ration of the Vector Graphic canputer to be used.
'Ibis manualwill describe the features, cannands, and syntax of Microsoft BASIC-80,
Revision 5.0, ani explain howit is used on a Vector Graphic canputer that uses CP/M as its c:p!rating system. '!houghit oovers every aspect of the language, it is not intended as a training manualfor novice programners•
Chapter 1 discusses BASIC-80
Chapter 2 contains the syntax and use of every cxmnandand statenent in BASIC-80,in alphabetic order.
Chapter 3 describes every intrinsic 80, also alphabetically.
In the appendices, certain tcpics such as disk I/O, using assembly language subroutines, the relationship to
CP/M,ani the carrpatibility with the BASIC carpiler, are discussed in greater detail, and there are lists of error messages, ASCII codes, math functions, newfeatures in
Revision 5.0, ani sane tips on converting
£ran other BASIC's.
\
This is the reference manual for Vector Graphic's implementation of
Microsoft's BASIC-Se,Revision 5.e, one of the most extensive and .high-speed
BASIC's available.
It meets the ANSIqualifications for BASIC,as set forth in document BSRX3.60-l97S.
Vector Graphic is proud to offer; the BASIC-S0 interpreter with Vector GraPlic systems.
For readers familiar with earlier versions of Microsoft BASIC,Appendix A describes the enhancements in Revision 5.0 over earlier releases, including incanpatibilities with them.
If you have software written in one of the earlier execution.
versions, check Appendix A for new features that may affect
This manual covers a number of upward compatible versions of BASIC-Se, specifically the -SK,- -Extended," an; "Disk- versions.
My feature in the
SK and Extended versions is available in the Disk version.
available fran Vector Graphic is the Disk version.
Therefore,
The version everything described in this manual is present in the Vector Graphic implementation, no matter ~at version it is listed under.
Most users will make use of the BASIC-aainterpreter.
(The interpreter is a progrClll ~ich allows entry and ed! tiB3 of BASICprograms, and executes them line by line W1eneverdesired.) For certain specialized applications, the Microsoft BASIC compiler (BASCOM) also available through Vector
Graphic.
'lbe canpiler allows ~u to convert a BASIC-S0progrClll, originally written and debu;ged using the interpreter, into machine language, Wlich can then be executed at very high speed.
\\hen ~u obtain the canpiler, you will receiver a manual detailing its use, but because it may be relevent to a user of the BASIC-aeinterpreter, Appendix L discusses the BASICcanpiler in brief.
Note that Appendix L lists several features which are present in the interpreter but \tbich are absent or different in the canpiler.
Programmers intending differences.
to compile BASIC-S0 programs must pay attention to these
In a Vector Graphic canputer, BASIC-Seruns in conjuction with the CP/M operating system.
The name of the BASIC-Se interpreter file on the disk supplied by Vector Graphic is -MBASIC.CQtl.
Therefore, in order to call up the interpreter fran the CP/Mexecutive, do the following: First, if MBASIC is not already present on the main CP/Mdiskette, mount the BASIC-Sedisk in drive A.
Then, following the A> prompt, type MaASle and then press the
RETURNkey.
Optionally, you can enter one or more parameters before depressil'Xl RETURN,including the name of the BASICprogram you want to execute, the number of files you want OPENat one time, and the highest memorylocation you want BASICto use.
These options are discussed in
Appendix D.
In this manual, the term -initialization" means the above process, of calling up BASIC-Se,nothil'Xl more.
Of particular interest is the option to immediately execute a BASIC program by typiB3 its nane as a paraneter followil'Xl the word MBASIC. This causes the program to be loaded, and then executed as if a RUNcommandwere typed.
In other words, the system jumps directly into the application program when MBASIC up.
Further, if you are using CP/M2, rather than an earlier version of CP/M, you can configure ~ur system diskette to bypass the CP/M.executive and instead carry out a particular CP/Mcommandor
utility, su::h as calling up MSASIC. You accomplish this by creating an
"auto" command, which you do by running the CONFIG present on the
CP/M2 serialized diskette.
If your auto camnandcontains "MBASIC" by the name of a BASICprogrClllon the same diskette, optionally followed by other parasneters, followed by a RETURN, will bypass all executives and automatically begin executing the BASIC program.
(This assumes MBASIC.CCM
system diskette aloD; with CP/M.) This allows creation of an attractive "turn-key" package.
Appendix 0 explains several other canmands and aspects of BASIC-aethat deal specifically with CP/M. Use it as an integral part of this manual.
Please note the followirJ;J points when usirJ;J this manual:
It is NOTnecessary to create a file tnder the CP/Mexecutive before it can be used by BASIC-aa.
To return to the CP/Mexecutive fran the BASIC-8eexecutive, tyPe SYSTEM followed by the RETURN
Whenusin;r a Vector System B, Memorite II, Vector 3"311l,or other Vector
Graphic system having "memorymappedvideo" and using the option gv Extended
Systems M:>nitor, do NOTpress the LF or LINEFEED a
BASIC line on a second line on the screen.
Instead, the video driver will cause the text to "wrap aro\.md" automatically.
The same is true for any serial terminal that has automatic wrap around.
~en listing progran text or output, BASIC-a"assunes it is outputting to a l32-character widtb printer.
If your system's printer is narrower, it will be able to print lOn;J lines only if the printer or the printer driver software in the operating system has the ability to automatically wrap around at the end of a line.
'1bis is dePendent on the particular pr inter you are using.
References to "printing" in this manual, as in most BASICmanuals, refer to displaying text on the operator's console, which is usually a video screen.
'!be tem "printing" derives fran the original use of Teletype and other hard-copy printin;J terminals.
'!be manual will refer specifically to the "line printer" when referring to output intended for the system's output printer, (sometimes called the "lister"), which is usually a separate peripheral fran the operator's console.
OUtput directed by BASIC-Sillto the
"line printer" is sent by BASIC-aeto CP/M's logical lister output routine, which normally saRis the data out via a channel connected electronically to a printer of some kind.
The t"'lOcanmands that cause BASIC-a"to send data in this way to the "line pr inter" are LLISTand LPRINT.
Reference is made in several places to the console's bell.
This is only relevent if the terminal you are using has a bell.
The Vector Graphic memory-mapPed time has no bell.
APPENDIX C Assembly Language Subroutines
APPENDIX 0 BASIC-SO with the CP/M Operating System
APPENDIX E
APPENDIX I Converting Programs to BASIC-SO
APPENDIX J Summary of Error Codes and Error Messages
APPENDIX K Mathematical Functions
CRAPTER 1
GENE~ INFORMATION ABOUT BASIC-SO
The procedure for initialization will vary with different implementations of BASIC-SO.· Check the appropriate appendix at the back of this manual to determine how BASIC-SO is initialized with your operating system.
1.2
MODES
Q!.
OPERATION
When BASIC-80 is initialized, it types the· prompt wOkw• ftOkftmeans BASIC-SO is at command level, that is, it is ready to accept commands.
At this point, BASIC-SO may be used in either of two modes: the direct mode or the indirect mode.
In the direct mode, BASIC commands and statements are not preceded by line numbers.
They are executed as they are entered.
Results of arithmetic and logical operations may be displayed immediately and stored for later use, but the instructions themselves are lost after execution.
This mode is useful for debugging and for using BASIC as a
·calculator
W for quick computations that do not require a complete program.
The indirect mode is the mode used
Program lines are preceded by line memory.
The program stored in entering the RUN command.
for entering programs.
numbers and are stored in memory is executed by
Program.lines in a BASIC program have ~~e following format
(square brackets indicate optional) : nnnnn BASIC statement[:BASIC statement••• l <carriage return>
At the programmerts option, more than one BASIC statement may be placed on a line, but each statement on·a line must be separated from.the last by a colon.
A BASIC program line always begins with a line number, ends with a carriage return, and may contain a maximum of:
72 characters in SK BASIC-SO
255 characters in Extended and Disk BASIC-SO.
In Extended and Disk versions, it is possible to extend a logical line over more than one physical line by use of the terminal's <line feed> key.
<Line feed> lets you continue typing a logical line on the next physical line without entering a <carriage return>.
(In the SK version, <line feed> has no effect.
Every BASIC program line begins with a line number.
Line numbers indicate the order in which the program lines are stored in memory and are also used as references when branching and editing.
Line numbers must be in the range a to 65529.
In the Extended and Disk versions, a period (.) may be used in EDIT, LIST, AUTO and DELETE commands to refer to the current line.
1•4 CBARACTEll ~
The BASIC-SO character set is comprised of alphabetic characters, numeric characters and special characters.
The alphabetic characters in BASIC-SO are the upper case and lower case letters of the alphabet.
The numeric characters in BASIC-SO are the digits 0 through
9.
The following special characters and terminal keys are recognized by BASIC-SO:
<delete>
<escape>
<line feed>
<carriage return>
<backspace>
Name
BIaiik
Semicolon
Equal sign or assignment symbol
Plus sign
Minus sign
Asterisk or multiplication symbol
Slash or division symbol
Up arrow or exponentiation symbol
Left parenthesis
Right parenthesis
Percent
Number (or pound) sign
Dollar sign
Exclamation point
Left bracket
Right bracket
Comma
Period or decimal point
Single quotation mark (apostrophe)
Colon
Ampersand
Question mark
Less than
Greater than
Backslash or integer division symbol
At-sign
Underscore
Deletes last character typed.
Escapes Edit Mode subcommands.
See Section 2.16.
Moves print position to next tab stop.
Tab stops are every eight columns.
Moves to next physical line.
Terminates input of a line.
Deletes last character typed, and erases it from screen.
Interrupts program execution and returns to
BASIC-SO command level.
Backspace.
Deletes the last character typed.
Tab.
Tab stops are every eight columns.
Halts program continues.
A output.
output second while
Control-o execution restarts
Retypes the line that is currently being typed.
Suspends program execution.
Resumes program execution after a Control-S.
Deletes the line that is currently being typed.
Constants are the actual values BASIC uses during execution.
There are two types of constants: string and numeric.
A string constant is a sequence of up to 255 characters enclosed in double quotation marks •.
alphanumeric
Examples of string constants:
"HELLO"
"$25,000.00"
"Number of Employees"
Numeric constants are positive or negative numbers.
Numeric constants in BASIC cannot contain commas.
There are five types of numeric constants:
2.
Fixed Point constants
Whole numbers between -32768 and
+32767.
Integer constants do not have decimal points.
Positive or negative real numbers, i.e., numbers that contain decL~al points.
3.
Floating Point constants
Positive or negative numbers repre-· sented in exponential form (similar to scientific notation).
A floating point constant consists of an optionally signed integer or fixed point number (the mantissa) followed by the letter E and an optionally signed integer (the exponent).
The exponent must be in the range -38 to +38.
Examples:
235.988E-7 = .0000235988
2359E6 • 2359000000
(Double precision floating point constants use the letter D instead of E.
S~e Section 1.5.1.)
Hexadecimal numbers with the prefix
&H.Examples:
&H76
&H32!'
Octal numbers with the prefix &0 or
&.
Examples:
&0347
&1234
1.5.1
Single ~ Double Precision !2E!~ Numeric constants
In the SK version of BASIC-SO, all numeric constants are single precision numbers.
They are stored with 7 digits of precision, and printed with up to 6 digits.
In .the
Extended and Disk versions, however, numeric constants may be either single precision or double prec~s~on numbers.
With double precision, the numbers are stored with
16 digits of precision, and printed with up to 16 digits.
A single precision constant is any numeric constant that has:
1• seven or fewer digits, or
2.
exponential form using E, or
3.
a trailing exclamation point (1)
A double precision constant is any numeric constant that has:
1.
eight or more digits, or
2.
exponential form using 0, or
3.
a trailing number sign (I)
Examples:
Single Precision constants
46.8
-7.09E-06
3489.0
22.51
345692811
-1.094320-06
3489.0+
7654321.1234
V~iables are names used to represent values that are used in a BASIC program.
~he value of a variable may be assigned explicitly by the programmer, or it may be assigned as the result of calculations in the proqram.
Before a variable is assigned a value, its value is assumed to be zero.
BASIC-80 variable names may be any length, however, in the
8K version, only the first two characters are significant •
.In the Extended and Disk versions, up to 40 characters are significant.
~he characters allowed in a variable name are letters and numbers, and the decimal point is allowed in
Extended and Disk variable names.
The first character must be a letter.
Special type declaration characters are also allowed -- see below.
A variable name may not be a reserved word.
The Extended and Disk versions allow embedded reserved words; the 8K version does not.
If a variable begins with FN, it is assumed to be a call to a user-defined function.
Reserved words include all BASIC-80 commands, statements, function
Variables may represent either a numeric value or a .string.
String variable names are written with a dollar sign ($) as the last character.
For example: A$.
nSALES REPORT".
The dollar sign is a variable type declaration character, that is, it ndeclares· that the variable will represent a string.
In the Extended and Disk versions, numeric variable names may declare inteqer, single or double precision values.
(All numeric values in SX are single precision.) The type declaration characters for these variable names are as follows:
, Integer variable t
1 Single precision variable
Double precision variable
The default type for a numeric variable name is single precision.
Examples of BASIC-SO variable names follow.
In Extended and Disk versions:
PIt
MINIMUM 1
LIMIT' declares a double precision value declares a single precision value declares an integer value
In SX, Extended and Disk versions:
N$
ABC declares a string value represents a single precision value
In the Extended and Disk versions of BASIC-SO, there is a second method by which variable types may be declared.
The
BASIC-SO statements DEFINT, DEFSTR, DEFSNG and OEFDSL may be inclcded in a program to declare the types for certain variable names.
These statements are described in detail in
Section 2.12.
1.6.2
Array Variables
An array is a group or table of values referenced by the same variable name.
Each element in an array is referenced by an array variable that is subscripted with integers or integer expressions.
An array variable name has as many subscripts as there are dimensions in the array.
For example V(10) would reference a value in a one-dimensional array, T(1,4) would reference a value in a two-dimensional array, and so on.
When necessary, BAS~C will convert a numeric constant from one type to another.
The following rules and examples should be kept in mind.
1.
If a numeric constant of one type is set equal to a numeric variable of a different type, the number will be stored as the type declared in the variable name.
(If a string 'variable is set equal to a numeric value o~ vice versa, a "Type mismatch" error occurs.)
Example:
10 A% • 23.42
20 PRINT At
RON
23
2.
During expression evaluation, all of the operands in an arithmetic or relational operation are converted to the same degree of precision, i.e., that of the most precise operand.
Also, the result of an arithmetic operation is returned to this degree of precision.
EXamples:
10
ot •
61/7
20 PRINT Of
The arithmetic was performed in double precision and the
RUN result was returned in Of
.8571428571428571 as a double precision value.
10 0 =- 6#/7
20 PRINT 0
RON
.857143
The arithmetic was performed in double precision and the result was returned to 0 (single precision variable), rounded and printed as a single precision value.
3.
Logical operators (see Section 1.8.3) convert their operands to integers and return an integer result.
Operands must be in the range -32768 to 32767 or an
"Overflow" error occurs.
4.
When a floating point value is converted to an integer, the fractional portion is rounded.
EXample:
10 C'l
:II
55.88
20 PRINT C%
RON
56
5.
If a double precision variable is assigned a single precision value, only the first seven digits, rounded, of the converted number will be valid.
This is because only seven digits of accuracy were supplied with the single precision value.
The absolute value of the difference between the printed double precision number and the original single precision value will be less than 6.3E-8 times the original single precision value.
Example:
10 A • 2.04
20 B. • A
30 PRINT A;S#
RON
2.04
2.039999961853027
An expression may be simply a string or numeric constant, or a variable, or it may combine constants and variables with operators to produce a single value.
Operators perform mathematical or logical operations on values.
The operators provided by BASIC-SO may be divided into four categories:
1.
Arithmetic
2.
Relational
1.8.1
Arithmetic Operators
The arithmetic operators, in order of precedence, are:
Operation
Exponentiation
Negation
Multiplication, Floating
Point Division
X·Y
X/Y
To change the order in which the operations use parentheses.
Operations within performed first.
Inside operations is maintained.
parentheses, the are performed, parentheses are usual order of
Here are some sample algebraic expressions and their BASIC counterparts.
BASIC Expression Algebraic Expression
X+2Y
X--
Z
XY z-
X+Y
-Z
(X2) Y
X y Z
X+Y*2
X-y/z
X*Y/Z
(X+Y)/Z
(XA2)AY
XA(YAZ)
X*(-Y) Two consecutive operators must be separated by parentheses.
1.8.1.1
Integer Division And Modulus Arithmetic -
Two additional operators are-available in Extended and Disk versions of BASIC-SO: Integer division and modulus arithmetic.
Integer division is denoted by the operands are rounded to integers
-32768 to 32767) before the division quotient is truncated to an integer.
baCks lash
(must be in the is performed,
For example:
(')• and
The range the
10\4
:I
2
25.68\6.99
• 3
The precedence of integer division multiplication and floating point division.
is
Modulus arithmetic is denoted by the operator MOD.
It gives the integer value that is the remainder of an integer division.
For example:
10.4 MOO 4
=
2 (10/4=2 with a remaL~der 2)
25.68
MOD 6.99
=
5 (26/7=3 with a remainder 5)
The precedence of modulus arithmetic is just after integer di~lision.
"
1.8.1.2
Overflow And Division
!I
Zero -
If, during the evaluation of an exp-riSsion, a division by zero is encountered, the "Division by zero" error message is displayed, machine infinity with the sign of the numerator is supplied as the result of the division, and execution continues.
If the evaluation of an exponentiation results in zero being raised to a negative power, the "Division by zero" error message is displayed, positive machine infinity is ·supplied as the result of the exponentiation, and execution continues.
If overflow occurs, the "Overflow" error message is displayed, machine infinity with the algebraically correct sign is supplied as the result, and execution continues.
1.8.2
Relational Operators
Relational operators are used to compare two values.
The result of the comparison is either "true" (-1) or "false"
(0).
This result may then used to make a decision regarding program flow.
(See IF, Section 2.26.)
Operator Relation Tested
-
Equality
<> Inequality
Expression
X-Y x<>y
< Less than X<Y
>
<-
Greater than
Less 'thanor equal to x>y x<=y
>Greater than or equal to x>-y
(The equal sign is also used to assign a value to a variable.
See LET, Section 2.30.)
When arithmetic and relational operators are combined in one expression, the arithmetic is always performed first.
'For example, the expression is uue if the value of X plus Y is less than the value of
T-1 divided by Z.
More examples:
IF SIN(X)<O GOTO 1000
IF I MOO
J
<> 0 THEN K=K+1
1.9.3
Loqieal
Opera~ors
Logical opera~ors perform tes~s on multiple relations, bit manipulation, or Boolean operations.
The logical operator returns a bitwise result which is either "true" (not zero) or "false" (zero).
In an expression, logical operations are performed after a:ithmetic and relational operations.
The outcome of a logieal operation is de~ermined as shown in the following table.
The operators are listed in order of precedence.
NOT
X
1
0
NOT X
0
1
AND
X
1
1
0
0 y
1
0
1
0
X AND y
1
0
0
0
OR
0
0
X
1
1
Y
1
0
1
0
X OR Y
1
1
1
0
XOR
0
0
X
1
1
Y
1
0
1
0
X XOR Y
0
1
1
0
IMP
X
1
1
0
0
Y
1
0
1
0
X IMP Y
1
0
1
1
EQV
X
1
Y
1
1 0
0 a a
1
X EQV
1
0
0
1 y
Just as the relational operators can be used to make decisions regarding program flow, logical operators can connect two or more relations and return a true or false value to be used in a decision (see IF, Section 2.26).
For
IF 0<200 AND F<4 TEEN 80
IF I>10 OR K<O THEN 50
IF NOT P THEN 100
Logical operators work by converting their operands to sixteen bit, siqned, two r S complement integers in the range
-32768 to +32767.
(If the operands are not in this range, an error results.) If both operands are supplied as 0 or -1, logical operators return 0 or -1.
The given operation is performed on these integers in bitwise fashion, i.e., each bit of the result is determined by the corresponding bits in the two operands.
Thus, it is possible to use logical operators to test bytes for a particular bit pattern.
For instance, the AND operator maybe used to "mask" all but one of the bits of a status byte at a machine I/O port.
The OR operator may be used to "merge" two bytes to create a particular binary value.
Tbe following examples will help demonstrate how the logical operators work.
63 • binary 111111 and 16 • binary
10000, so 63 AND 16 - 16
15 • binary 1111 and 14 - binary 1110, so 15 AND 14 - 14 (binary 1110)
-1 - binary 1111111111111111 and
8 • binary 1000, so -1 AND 8 • 8
4 • binary 100 and 2 -binary 10, so 4 OR 2 - 6 (binary 110)
10 - binary 1010, so 1010 OR 1010 •
1010 (10)
-1 • binary 1111111111111111 and
-2 • binary 1111111111111110, so -1 OR -2 • -1.
The bit complement of sixteen zeros is sixteen ones, which is the two's complement representation of -1.
The two's complement of any integer is t,hebit complement plus one.
1.S.4
Functional Operators
A function is used in an expression to call a predetermined operation that is to be performed on an operand.
BASIC-SO has "intrinsic" functions that reside in the system, such as
SQR (square root) or SIN, (sine).
All of BASIC-SO's intrinsic functions are described in Chapter 3.
BASIC-SO also allows "user defined" functions that are written by the programmer.
See OEF FN, Section 2.11.
1.S.5
String Operations
Strings may be concatenated using +.
For example:
10 A$-"FILE" : B$."NAME"
20 PRINT A$ + B$
30 PRINT "NEW " + A$ + B$
RON
FILENAME
NEW FILENAME
Strings may be compared using the same relational operators that are used with numbers:
String comparisons are made by taking one character at a time from each string and comparing the ASCII codes.
If all the ASCII codes are the same, the strings are equal.
If the
ASCII codes differ, the lower code number precedes· the higher.
If, during string comparison, the end of one string is reached, the shorter string is said to be smaller.
Leading and trailing blanks are significant.
Examples:
"AA"
<
"AB"
"FILENAME" • "FILENAME"
"X,"
>
"X."
"CL " > "CL"
"kg"
>
" SMYTH"
"KG"
<
"SMYTHE·
B$ < "9/12/7S" t where B$ • "S/12/7S"
Thus, string comparisons can be used to test string values or to alphabetize strings.
All string constants used in comparison expressions must be enclosed in quotation marks.
If an incorrect character is entered as a line is being typed, it can be deleted with the DElete key 'or with
BAC<SPACE •
DElete surrounds the deleted character (s) with backslashes, and
~PACE' has the effect of backspacing over a character and erasing it.
Once a character(s) has been deleted, simply continue typing the line as desired.
To delete.a line that is in the process of being typed, type
Control-U.
A carriage return is executed automatically after the line is deleted.
To correct program lines for a program that is currently in memory, simply retype the line using the same line number.
BASIC-SO will automatically replace the old line with the new line.
More sophisticated editing capabilities are provided in the
Extended and Disk versions of BASIC-SO.
See EDIT, Section
2.16.
To delete the entire program that is currently residing in memory, enter the NEW command.
(See Section 2.41.) NEW is usually used to clear memory prior to entering a new program.
If BASIC-SO de~ects an error that causes program execution to terminate, an error message is printed.
In the SK version, only the error code is printed.
In the Extended and Disk versions, the entire error message is printed.
For a complete list of BASIC-SO error codes and error messages, see Appendix J.
CRAPTER2
BASIc-eo COMMANDS AND STATE.'1EN'I'S
All of the BASIC-eO commands and statements are described in this chapter.
Each description is formatted as follows:
Shows the correct format for the instruction.
See below for format notation.
Lists the versions of BASIc-eo in which ~e instruction is available.
Purpose:
Remarks: Describes in detail how the instruction is used.
Shows sample programs or program segments that demonstrate the use of the instruction.
Format Notation
Wherever the format for a statement or command is given, the following rules apply:
1.
Items in capital letters must be input as shown.
2.
Items in lower case letters enclosed in angle brackets «
»
are to be supplied by the user.
3.
Items in square brackets ([ J) are optional.
4.
All punctuation except angle brackets and square brackets (i.e., commas, parentheses, semicolons, hyphens, equal signs) must be included where shown.
s.
Items followed by an ellipsis (•••) may be repeated any number of times (up to the length of the line).
6.
Items separated by a vertical bar (,) are mutually exclusive; choose one.
AUTO [<line number> [,<increment>]]
Extended, Disk
To generate a line number automatically after every carriaqe return.
ACTO beqins numberinq at <line number> and increments each subsequent line number by
<increment>.
The default for both values is 10.
If <line number> is followed by a comma but
<increment> is not specified, the last increment specified in an AUTO command is assumed.
If AUTO generates a line number that is already beinq used, an asterisk is prin t.edafter the number to warn the user that any input will replace the existing line.
However, typinq a carriaqe return immediately after the asterisk will save the line and qenerate the next line number.
AUTO is terminated by typinq Control-c.
The line in which Control-c is t.ypedis not saved.
Aft.er Control-C is typed, BASIC returns to command level.
Generates line numbers 100,
150,200 •••
Generates line numbers 10,
20, 30, 40 •••
Purpose:
Remarks:.
CALL <variable name>[«argument list»]
Ex1:ended,Disk
To call an assembly lanquaqe subroutine.
The CALL statement is one way to transfer proqram flow to an assembly lanquaqe subroutine.
(See also ~e USR function, Section 3.40)
<variable name> contains an address'that is the startinq point in memory of ~e subroutine.
<variable name> may not be an array variable name.
<argument list> contains the arquments that are passed to ~e assembly lanquaqe subroutine.
The CALL statement qenerates the same callinq sequence used by Microsoft's FORT~~, COBOL and
BASIC compilers.
110 MYROOT-&HDOOO
120 CALL MYROOT(I,J,X)
~N [MERGE] <filename>[,[<line number exp>]
[,ALL][,DELETE<range>]]
Disk
To ca.lla program and pass variables to it from the current program.
<filename> is the name of the program that is called.
Example:
CRAIN "PROG1"
<line number exp> is a line number or an expression that evaluates to a line number in the called program.
It is the starting point for execution of the called program.
If it is omitted, execution begins at the first line.
Example:
CBAIN"PROG1",1000
<line number exp> is not affected by a RENOM command.
With the ALL option, every variable in the current program is passed to the ca~led program.
If the ALL option is omitted, the current program must contain a COMMON statement to list the variables that are passed.
See Section 2.7.
Example:
If the MERGE option is included, it allows a subroutine to be brought into the BASIC program as an overlay.
That is, a MERGE operation is performed with the current program and the called program.
The called program must be an
ASCII file if it is to be MERGEd.
Example:
After an overlay is desirable to delete be brought in.
To option.
Example: brought in, it is usually it so that a new overlay may do this, use the DELETE
CRAJ:NMERGE l'OVIU.AY2 " , 1000,DELETE 1000-5000
The line numbers in <range> are affected by the
BENUM command.
The Microsoft BASIC compiler does not support the ALL, MERGE, and DELETE options to CRAIN.
If you wish to maintain compatibility with the
BASIC compiler, it is recommended that COMMON be used to pass variables and that overlays not be used.
If the MERGE option is omitted, CHAIN does not preserve variable types or user-defined functions for use by the chained proqram.
That is, any OEFINT, OEFSNG, OEFDBL, DEFSTR, or DEFFN statement containing shared variables must be restated in the chained program.
CLEAR[,[<expression1>] [,<expression2>]1
SK, Extended, Disk
To set all numeric variables to zero and all string variables to null; and, optionally, to set the end of memory and the amount of stack space.
<expression1> is a memory location which, if specified, sets the hiqhest location available for use by BASIC-SO.
<expression2> sets aside stack space for BASIC.
The default is 1000 bytes or one-eighth of the available memory, whichever is smaller.
In previous versions of BASIC-SO, <expression 1> set the amount of string space and <expression2> set the end of memory.
BASIC-SO, release 5.0
and later, allocates string space dynamically.
An "Out of string space" error occurs only if there is no free memory left for BASIC to use.
,
..../
\
\
2.5
Intentially left blank.
Purpose:
Remarks:
To conclude I/O to a disk f~le.
<file number> is the number under which the file was OPENed.
A CLOSE with no arguments closes all open files.
\
The association between a particular file and file number terminates upon execution of a
CLOSE.
The file may then be reOPENed using the same or a different file number; likewise, that file number may now be reused to OPEN any file.
A CLOSE for a sequential output file writes the final buffer of output.
The END statement and the NEW command always
CLOSE all disk files automatically.
(STOP does not close disk files.)
See Appendix B.
Purpose:
Remarks:
To pass variables to a CHAINed program.
The COMMON statement is used in conjunction with the CHAIN statement.
COMMON statements may appear anywhere in a program, though it is recommended that they appear at the beginning.
The same variable cannot appear in more than one
COMMON statement.
Array variables are specified by appending "()" to the variable name.
If all variables are to be passed, use CRAIN with the
ALL option and omit the COMMON statement.
100 COMMON A,B,C,O(),G$
110 CHAIN "PROG3",10
8K, E~ended, Disk
To con~inue proqram execu~ion af~er a Con~rol-C has been ~yped, or a STOP or END s~a~emen~ has been executed.
Execution resumes at the point where the break occurred.
If the break occurred after a promp~ from an INPUT s~a~ement, execution continues with the reprinting of ~he promp~ (1 or prompt s~ring).
CONT is usually used in conjunction with STOP for debugging.
When execution is stopped, intermediate values may be examined and changed using direct mode statemena.
E~ecution may be resumed with COt~ or a direct mode GOTO, which resumes execution a~ a specified line number.
With the Extended and Disk versions, CONT may be used to continue execution after an error.
CONT is invalid if the program has been edited during the break.
In 8K BASIC-80, execution canno~ be CONTinued if a direct mode error has occurred during the break.
See example Section 2.61, STOP.
BASIC-SO COMMANDS AND STATEMENTS
2.9
Intentially left blank.
SK, Extended, Disk
To store the numeric 'and string constants that are accessed by the program's READ statement(s).
(See READ, Section 2.54)
DATA statements are nonexecutable and may be placed anywhere in the program.
A DATA statement may contain as many constants as will fit on a line (separated by commas), and any number of DATA statements may be used in a program.
The READ statements access the DATA statements in order (by line number) and the data contained therein may be thought of as one continuous list of items, regardless of how many items are on a line or where the lines are placed in the program.
<list of constants> may QOntain numeric constants in any format, i.e., fixed point, floating point or inte~er.
(No numeric expressions are allowed ~n the list.) String constants in DATA statements must be surrounded by double quotation marks only if they contain commas, colons or significant leading or trailing spaces.
Otherwise, quotation marks are not needed.
The variable type (numeric or string) given in the READ statement must agree with the corresponding constant in the DATA statement.
DATA statements may be reread from the beginning by use of the RESTORE statement (Section 2.57).
See examples in Section 2.54, READ.
DEF FN<name>[«parameter list»]=<function definition>
SK, Extended, Disk
To define and name a function that is written by theuser.
<name> must be a legal variable name.
This name, preceded by FN, becomes the name of the function.
<parameter list> is comprised of those variable names in the function definition that are to be replaced when the function is called.
The items in the list are separated by commas.
<function definition> is an expression that performs the operation of the function.
It is limited to one line.
Variable names that appear in this expression serve only to define the function: they do not affect program variables that have the same name.
A variable name used in a function definition mayor may not appear in the parameter list.
If it does, the value of the parameter is supplied when the function is called.
Otherwise, the current value of the variable is used.
The variables in the parameter list represent, on a one-to-one basis, the argument variables or values that will be given in the function call.
(Remember, in the SK version only one argument is allowed in a function call, therefore the DEF
FN statement will contain only one variable.)
In Extended and Disk BASIC-SO, user-defined functions may be numeric or string: in SK, user-defined string functions are not allowed.
If a type is specified in the function name, the value of the expression is forced to that type before it is returned to the calling statement.
If a type is specified in the function name and the argument type does not match, a "Type mismatch" error occurs.
A DEF FN statement must be executed before the function it defines may be called.
If a function is called before it has been defined, an "Undefined user function" error occurs.
DEF
FN is illegal in the direct mode.
410 DEF FNAB(X,Y)=XA3/YA2
420 T-FNAB (I,J)
Line 410 de£ines the function function is called in line 420.
DEF<type> <range(s) of letters> where <type> is INT, SNG, DBL, or STR
Extended, Disk
To declare variable types as integer, single precision, double precision, or string.
A OEFtype statement declares that the variable names beginning with the letter(s) specified will be that type variable.
However, a type declaration character always takes precedence over a OEFtype statement in the typing of a variable.
If no type declaration statements are" encountered, BASIC-SO assumes all variables without declaration characters are single precision variables.
10 OEFOBL L-P All variables beginning with the letters L, M, N, 0, and P will be 'double precision variables.
All variables beginning with the letter A will be string variables.
10 DEFINT I-N,W-Z
All variables beginning with the letters I, J, K, L, M,
N, W, X, Y, Z will be integer variables.
To specify the starting address of an assembly language subroutine.
<digit> may be any digit from 0 to 9.
The digit corresponds to the number of the USR routine whose address is being specified.
If <digit> is omitted, OEF USRO is assumed.
The value of
<integer expression> is the starting address of the USR routine.
See Appendix C, Assembly
Language Subroutines.
Any number of OEF USR statements may appear in a program to redefine subroutine starting addresses, thus allowing access to as many subroutines as necessary •
•
200 OEF USRO-24000
210 X-USRO{YA2/2.89)
Purpose:
Remarks:
To dele~e program lines.
BASIC-SO always re~urns to command level after a
DELETE is execu~ed.
If <line number> does not exis~, an "Illegal func~ion call" error occurs.
DELETE 40
DELETE 40-100 Dele~es lines 40 through
100, inclusive
Deletes all lines up to and including line 40
D~ <list of subscripted variables>
SK, Extended, Disk
To specify the maximum values for array variable subscripts and allocate storaqe accordinqly.
If an array variable name is used without a D~ statement, the maximum value of its·subscript(s) is assumed to be 10.
If a subscript is used that is qreater than the max~um specified, a
•Subscript out of. ranqe· error occurs.
The minimum value for a subscript is always 0, unless otherwise specified with the OPTION BASE statement (see Section 2.46).
The D~ statement sets all the elements of the specified arrays to an initial value of zero.
10 DIM A(20)
20 FOR I-O TO 20
30 READ A(I)
40 ~ I
Purpose:
Remarks:
To enter Edit Mode at the specified line.
In Edit Mode, it is possible to edit portions of a line without retyping the entire line.
Upon en tering Edi t Mode, BAS IC- 80 types the line number of the line to be edited, then it types a space and waits for an Edit Mode subcommand.
Edit Mode subcommands are used to move the cursor or to insert, delete, replace, or search for text within a line.
The SuDcommands are not echoed.
Most of the Edit Mode subcommands may be preceded by an integer which causes the command to be executed that number of times.
When a preceding integer is not specified, it is assumed to be 1.
Edit Mode suCcommands may be according to the following functions: categorized
1.
Moving the cursor
2.
Inserting text
3.
Deleting text
4.
Finding text s.
Replacing text
6.
Ending and restarting Edit Mode
In the descriptions that follow, <ch> represents any character, <text> represents a string of characters of arbitrary length, [i] represents an optional integer (the default is 1), and
$ represents the Escape key.
Space Use the space bar to move the cursor to the right.
[ilSpace moves the cursor i spaces to the.right. Characters are printed as .you
space over them.
Rubout In Edit Mode, [ilDELete moves the cursor i spaces to the left (backspaces).
Characters are printed as you backspace over them.
2.
Inserting Text
I I<text>$ inserts <text> at the current cursor position.
The inserted characters are printed on the terminal.
To terminate insertion, type
Escape.
If Carriage Return is typed during an
Insert command, the effect is the same as typing
Escape and then Carriage Return.
During an
Insert command, the Delete key on the terminal may be used to delete characters to the left of the cursor.
If an attempt is made to insert a character that will make the line longer than 255 characters, a bell (Control-G) is typed and the character is not printed.
X The X subcommand is used to extend the line.
X moves the cursor to the end of the line, goes into insert mode, and allows insertion of text as if an Insert command had been q iven.
When you are finished extending the line, type Escape or Carriage Return.
3.
Deleting Text
D [i1D deletes i characters to the right of the cursor.
The deleted characters are echoed between backslashes, and the cursor is positioned to the right of the last character deleted.
If there are fewer than i characters to the right of the cursor, iD deletes the remainder of the line.
B deletes all characters to the cursor and then automatically mode.
B is useful for replacing the end of a line.
right of the enters insert statements at
4.
Finding Text
S The subcommand [i]S<ch> searches for the ith occurrence of <ch> and positions the cursor before it.
The character at the current cursor position is not included in the search.
If <ch> is not found, the cursor will stop at the end of
K
C
L
A the line.
All characters passed over during the search are printed.
The subcommand (i]K<ch> is similar to (i]S<ch>, except all the characters passed over in the search are deleted.
The cursor is positioned before <ch>, and the deleted characters are enclosed in backslashes.
The subcommand C<ch> changes the next character to <ch>.
If you wish to change the next i characters, use the subcommand iC, followed by i characters.
After the ith new character is typed, change mode is exited and you will return to Edit Mode.
Typing Carriage Return prints the remainder of the line, saves the changes you made and exits
Edit Mode.
The E subcommand has the same effect as Carriage
Return, except the remainder of the line is not printed.
The Q subcommand returns to BASIC-SO command level, without saving any of the changes that were made to the line during Edit Mode.
The L subcommand lists the remainder of the line
(saving any changes made so far) and repositions the cursor at the beginning of the line, still in Edit Mode.
L is usually used to list the line when you first enter Edit Mode.
The A subcommand lets you begin editing a line over again.
It restores the original line and repositions the cursor at the beginning.
If BASIC-SO receives an unrecognizable command or illegal character while in
Edit Mode, it prints a bell (Control-G) and the command or character is ignored.
When a Syntax Error is encountered during execution of a program, BASIC-SO automatically enters Edit Mode at the line that caused the error.
ror example:
10 K • 2(4)
RON
?Syntax error in 10
10
When you finish editing the line and type carriage Return (or the E subcommand), BASIC-SO reinserts the line, which causes all variable values to be lost.
To preserve the variable values for examination, first exit Edit Mode with the Q subcommand.
BASIC-SO will return to command level, and all variable values will be preserved.
T.oenter Edit Mode on the line you are currently typing, type Control-A.
BASIC-SO responds with a carriage return, an exclamation point (1) and a space.
The cursor will be positioned at the first character in the line.
Proceed by typing an Edit Mode subcommand.
Remember, if you have just entered a line and wish to go back and edit it, the command -EDIT." will enter Edit Mode at the current line.
(The line number symbol "." always refers to the current line.)
To terminate program execution, close all fi~es and return to command level.
END statements may be placed anywhere in the program to terminate execution.
Unlike the STOP statement, END does not cause a BREAK message to be printed.
An END statement at the end .of a program is optional.
BASIC-SO always returns to command level after an END is executed.
Purpose:
Remarks:
ERASE <list of array variables>
SK, Extended, Disk
To eliminate arrays from a program.
Arrays may be redimensioned after they are
ERASEd, or the previously allocated array space in memory may be used for other purposes.
If an attempt is made to redimension an array without first ERASEing it, a ftRedimensioned array· error occurs.
The Microsoft BASIC compiler does not support
ERASE •
•
450 ERASE A,B
460 DIM B (99)
2. 1 9
E!! ~ ~
VARIABLES
When an error hand~ing subroutine is entered, the variable ERR contains the error code for the error, and the variable ERL contains the line number of the line in which the error was detected.
The ERR and ERL variables are usually used in IF •••THEN statements to direct program flow in the error trap routine.
If the statement that caused the error was a direct mode statement, ERL will contain 65535.
To test if an error occurred in a direct statement, use IF 65535 • ERL THEN •••
Otherwise, use
If the line number is not on the right side of the relational operator, it cannot be renumbered by RENUM.
Because ERL and ERR are reserved variables, neither may appear to the left of the equal sign in a LET (assignment) statement.
BASIC-80's error codes are listed in Appendix J.
Extended, Disk
1) To simula~e the occurrence of a BASIC-80 error 7 or 2) ~o allow error codes ~o be defined by the user.
The value of <in~eger expression> mus~ be greater than 0 and less than 255.
If ~he value of <integer expression> equals an error code already in use by BASIC-80 (see Appendix J), the
ERROR statemen~ will simulate the occurrence of that error, and the corresponding error message will be printed.
(See Example 1.)
To define your own error code, use a value tha~ is greater than any used by BASIC-80's error codes.
(It is preferable ~o use the highest available values, so compatibili~y may be maintained when more error codes are added ~o
BASIC-80.) This user-defined error code may then be conveniently handled in an error trap routine.
(See Example 2.)
If an ERROR statement specifies a code for which no error message has been defined, BASIC-80 responds with the message UNPRINTABLE ERROR.
Execution of an ERROR statement for which ~here is no error trap routine causes an error message
~o be printed and execution to halt.
Example 1: LIST
10 S • 10
20 '1'5
30 ERROR S + '1'
40 END
Ok
RUN
String ~oo long in line 30
Ok
ERROR 15
String ~oo long
Ok
(you type this line)
(BASIC-80 types this line)
•
110 ON ERROR GOTO 400
120 INPUT "WHAT IS YOUR BET";B
130 IF B
>
5000 THEN ERROR 210
•
400 IF ERR • 210 THEN PRINT "ROOSE LIMIT IS $5000"
410 IF ERL • 130 THEN RESUME 120
FIELD[.]<file number>,<field width> AS <string variable> •••
Disk
To allocate space for variables in a random file buffer.
To get data out of a random buffer after a GET or to enter data before a PUT, a FIELD statement must have been executed.
<file number> was OPENed.
characters to
For example, is the number under which the file
<field width> is the number of be allocated to <string variable>.
FIELD 1, 20 AS N$, 10 AS ID$, 40 AS ADD$ allocates the first 20 positions (bytes) in the random file buffer to the string variable N$, the next 10 positions to ID$, and the next 40 pos~tions to ADD$.
FIELD does NOT place any data in the random file buffer.
(See LSET/RSET and GET.)
The total number of bytes allocated in a FIELD statement must not exceed the record length that was specified when the file was OPENed.
Otherwise, a "Field overflow" error occurs.
(The default record length is 128.)
Any number of FIELD statements may be executed for the same file, and all FIELD statements that have been executed are in' effect at the same time.
Do not use a FIELDed variable name in an INPUT or
'LET'Statement.
Once a -vir'iiE''le is
FIELDed, it points to the correct place in the random file buffer.
If a subsequent INPUT or
LET statement with that variable name is executed, the variable's pointer is moved to string space.
SK, Extended, Disk
To allow a series of instructions to performed in a loop a given number of times.
be
<variable> is used as a counter.
The first numeric expression (x) is the initial value of the counter.
The second numeric expression (y) is the final value of the counter.
The program lines following the FOR statement are executed until the NEXT statement is encountered.
Then the counter is incremented by the amount specified by STEP.
A check is performed to see if thevalue of the counter is now greater than the final value (y).
If it is not greater,
BASIC-SO branches back to the statement after the FOR statement and the process is repeated.
If it is greater, execution continues with the statement following the NEXT statement.
This is a FOR •••NEXT loop.
If STEP is not specified, the increment is assumed to be one.
If STEP is negative, the final value of the counter is set to be less than the initial value.
The counter is decremented each time through the loop, and the loop is executed until the counter is less than the final value.
The body of the loop is skipped if the value of the loop times the sign of exceeds the final value times the sign step.
initial the step of the
Nested Loops
FOR •••NEXT loops may be nested, that is, a
FOR •••NEXT loop may be placed within the context of another FOR •••NEXT loop.
When loops are nested, each loop must have a unique variable name as its counter.
The -NEXT statement for the inside loop must appear before that for the outside loop.
If nested loops have the same end point, a single NEXT statement may be used for all of them.
om tted, in which case the NEXT statement will match the most recent FOR statement.
If a NEX'I' statement is encountered before its corresponding FOR statement, a -NEX'I'without
FORerror message is issued and execution is terminated.
Example 1: 10 K-10
20 FOR I-1 TO It STEP 2
30 PRINT I;
40 K-K+10
50 PRINT It
60 NEX'I'
RON
1 20
3 30
5 40
7 5-0
9
Ok
60
Example 2: 10 J-O
20 FOR I=1 TO J
30 PRINT I
40 NEX'I' I
In this example, the because the initial the final value.
loop does not execute value of the loop exceeds
Example 3: 10 r-s
20 FOR I-1 TO I+S
30 PRINT I;
40 NEXT
RON
1 2 3 4 5 6 7 S 9 10
Ok
In this example, the loop executes ten times.
The final value for the loop variable is always set before the initial value is set.
(Note:
Previous versions of BASIC-SO set the initial value of the loop variable before setting the final value; i.e. , the above loop would have executed six times.>
GET [t]<file number>[,<record number>]
Disk
To read a record from a random disk file into a random buffer.
<file number> is the number under which the file was OPENed.
If <record number> is omitted, the next record (after the last GET) is read into the buffer.
The largest possible record number is 32767.
Purpose:
Remarks: <line number> subroutine.
is the first
\
A subroutine may be called any number of times in a program, and a subroutine may be called from within another subroutine.
Such nesting of subroutines is limited only by available memory.
The RETURN statement(s) in a subroutine cause
BASIC-SO to branch back to the statement following the most recent GOSUB statement.
A subroutine may contain more than one RETURN statement, should loqic dictate a return at different points in the subroutine.
Subroutines may appear "anywhere in the program, but it is recommended that the subroutine be readily distinguishable from the main program.
To prevent inadvertant entry into the subroutine, it may be preceded by a STOP, END, or GOTO statement that directs program control around the subroutine.
10 GOSUB 40
20 PRINT "BACX FROM SUBROOTINE"
30 END
40 PRINT "SUBROUTINE" 1
S'OPRINT " IN";
60 PRINT " PROGRESS"
70 RETtmN
RUN
SUBROOTINE IN PROGRESS
BACK FROM SUBROUTINE
Ok
To branch unconditionally out of the normal program sequence to a specified line number.
If <line number> is an executable statement, that statement and those following are executed.
If it is a nonexecutable statement, execution proceeds at the first executable statement encountered aftar <line number>.
LIST
10 READ R
20 PRINT "R ·";R,
30 A a
3.14*RA2
40 PRINT "AREA ."~A
50 GOTO 10
60 DATA 5,7,12
Ok
RUN
R • 5
R • 7
R • 12
?Out of data
Ok
AREA •
AREA
=-
AREA in 10
=-
78.5
153.86
452.16
IF <expression> THEN <statement(s}>
[ELSE <statement(s}>
I
<line number>]
IF <expression> GOTO <line number>
[ELSE <statement(s}>
I
<line number>]
SK, Ex~ended, Disk
<line number>
The ELSE clause is allowed only in Extended' and
Disk versions.
To make a decision regarding program flow based on the result returned by an expression.
If the result of <expression> is not zero, the
THEN or GOTO clause is executed.
THEN may be followed by either a line number for branching or one or more statements to be executed.
GOTO is always followed by a line number.
If the result of <expression> is zero, the THEN or GOTO clause is ignored and the ELSE clause, if present, is executed.
Execution continues with the nex~ executable statement.
(ELSE is allowed only in Ex~ended and Disk versions.) Extended and Disk versions allow a comma before THEN.
Nes~inq
2!
B:.
Statements
In the E~ended
IF •••THEN •••ELSE and statements
Disk may be versions, nested.
Nes~ing is limited only by the length of the line.
For example
IF X>Y THEN PRINT IIGREATERIIELSE IF Y>X
THEN PRINT llLESS THAN IIELSE PRINT •• is a legal statement.
If the statement does not contain the same number of ELSE and THEN clauses, each ELSE is matched with the closest unmatched THEN.
For example
IF A=B THEN IF a=c THEN PRINT II
ELSE PRINT IIAOC" will not print "A<>CII when A<>B.
If an IF •••THEN statement is followed by a number in the direct mode, an IIUndefined error results unless a statement with specified line number had previously entered in the indirect mode.
line line II the been
When using IF to test equality for a value that is the result of a floating point computation, remember that the internal representation.of the value may not be exact.
Therefore, the test should be against the range over which the accuracy of the value may vary.
For example, to test a computed variable A against the value
1.0, use:
This test returns true if the value of A is 1.0
with a relative error of less than 1.0E-6.
Example 1: 200 IF I THEN GETtl,I
This statement GETs record number I if I is not zero.
Example 2: 100 IF(I<20)*(I>10) THEN OS-1979-1:GOTO 300
110 PRINT "OOT OF RANGE"
In this example, a test determines if I is greater than 10 and less than 20.
If I is in this range, DB is calculated and execution branches to line 300.
If I is not in this range, execution continues with line 110.
This statement causes printed output to go either to the terminal or the line printer, depending on the value of a variable (IOFLAG).
If IOFLAG is zero, 'output goes to the line printer, otherwise output goes to the terminal.
8K, Extended, Disk
To allow input from the terminal during program execution.
When an INPUT statement is encountered, program execution pauses and a question mark is printed to indicate the program is waiting for data.
If
<"prompt string"> is included, the string is printed before the question mark.
The required data is then entered at the terminal.
If INPUT is immediately followed by then the carriage return typed by input data does not echo a carriage feed sequence.
a semicolon, the user to return/line
The data that is entered is assigned to variable(s) given in <variable list>.
number of data items supplied must be the as the number of variables in the list.
items are separated by commas.
the
The same
Data
The variable names in the list may be numeric or string variable names (including subscripted variables).
The type of each data item that is input must agree with the type specified by the variable name.
(Strings input to an INPU'r statement need not be surrounded by quotation marks. )
Responding to INPUT with too many or too few items, or with the wrong type of value (numeric instead of string, etc.) causes the messsage
"?Redo from start" to be printed.
No assignment of input values is made until an acceptable response is given.
In the 8K version, INPUT is illegal in the direct mode.
10 INPUT
20 PRINT
30 END x
X "SQUARED IS" XI\2
RUN
?
5 (The 5 was typed in by the user in response to the question mark.)
5 SQUAlmD IS 25
Ok
LIST
10 PI-3.14
20 INPUT "WHAT IS THE RADIUS";R
30 A-PI*RI\2
40 PRINT "THE AREA OF THE CIRCLE IS";A
50 PRINT
60 GaTO 20
Ok
RUN
WHAT IS THE RADIUS?
7.4
(User types 7.4)
THE AREA OF THE CIRCLE IS 171.946
WHAT IS THE RADIUS?
etc.
INPUTt<file number>,<variable list>
Disk
To read data items from a sequential disk file and assign them to program variables.
<file number> is the number used when the file was OPENed for input.
<variable list> contains the variable names that will be assigned to the items in the file.
(The variable type must match the type specified by the variable name.)
With INPUTt, no question mark is printed, as with INPUT.
The data items in the file should appear just as they would if data were being typed in response to an rNPUT statement.
With numeric values, leading spaces, carriage returns and line feeds are ignored.
The first character encountered that is not a space, carriage return or line feed is assumed to be the start of a number.
The number terminates on a space, carriage return, line feed or comma.
If BASIC~80 is scanning the sequential data file for a string item, leading spaces, carriage returns and line feeds are also ignored.
The firs~ character encountered that is not a space, carriage return, or line feed is assumed to be the start of a string item.
If this first character is a quotation mark ("), the string item will consist of all characters read between the first quotation mark and the second.
Thus, a quoted string may not contain a quotation mark as a character.
If the first character of the string is not a quotation mark, the string is an unquoted string, and will terminate on a comma, carriage or line feed (or after 255 characters have been read).
If end of file is reached when a numeric or string itam is being INPUT, the item is terminated.
Purpose:
Remarks: If a KILL statement is given for a file that is currently OPEN, a "File already open" error occurs.
KILL is used for all types of disk files: program files, random data files and sequential data files.
[LET] <variable>-<expression>
SK, Extended, Disk
To assign the value of an expression to a variable.
Notice the word LET is optional, i.e., the equal sign is sufficient when assigning an expression to a variable name.
110 LET 0-12
120 LET E-12A2
130 LET F-12A4
140 LET SUM-D+E+F
110 0-12
120 E-12A2
130 F=-12A4
140 SUM=D+E+F
LINE INPUT[;] [<"prompt string">;]<string variable>
Extended, Disk
To input an entire line (up to 254 characters) to a string variable, without the use of delimiters.
The 'prompt string is a str~ literal that is printed at the terminal before input is accepted.
A question mark is not printed unless it is part of the prompt string.
All input from the end of the prompt to the carriage return is assigned to <string variable>.
If LINE INPUT is immediately followed by a semicolon, then the carriage return typed by the user to end the input line does not echo a carriage return/line feed sequence at the terminal.
A LINE INPUT may be escaped by.typing Control-C.
BASIC-SO will return to command level and type
Ok.
Typing CONT resumes execution at the LINE
INPUT.
Example:
LINE INPUTt<file number>,<string variable>
Disk
To read an entire line (up to 254 characters), without delimiters, from a sequential disk data file to a string variable.
<file number> is the number under which the file was OPENed.
<string variable> is the variable name to which the line will be assigned.
LINE
INPUT.
reads all characters in the sequential file up to a carriage return.
It then skips over the carriage return/line feed sequence, and the next LINE INPUT' reads all characters up to the next carriage· return.
(If a line feed/carriage return sequence is encountered, it is preserved.)
LINE INPUT. is especially useful a data file has been broken into
BASIC-80 program saved in ASCII read as data by another program.
if each line of fields, or if a mode is being
10 OPEN "O",1,"LIST"
20 LINE INPUT
It
CUSTOMER INFORMATION? ";C$
30 PRINT .1, C$
40 CLOSE 1
50 OPEN "I",1,"LIST"
60 LINE INPUT t 1, C$
70 PRINT C$
80 CLOSE 1
RUN
CUSTOMER INFORMATION? LINDA JONES
LINDA JONES
Ok
234,4 MEMPHIS
234,4 ME.'-1PHIS
LIST «line number>[-[<line number>]]]
Extended, Disk
To list all or part of the program currently in memory at the terminal.
BASIC-80 always returns to command level after a
LIST is executed.
Format 1: If <line number> is omitted, the proqram is listed beqinning at the lowest line number.
(Listing is terminated either by the end of the program or by typing Control-C.) If
<line number> is included, the 8X version will list the program beginning at that liner and the Extended and Disk versions will list only the specified line.
Format 2: This format allows the following options:
1.
If only the first number is specified, that line and all higher-numbered lines are listed.
2.
If only the second number is specified, all lines from the beginning of the program through that line are listed.
3.
If both numbers are specified, the entire range is listed.
Lists the program currently in memory.
In the 8K version, lists all programs lines from
500 to the end.
In Extended and Disk, lists line 500.
LIST 150-
LIST -1000
Lists all lines from 150 to the end.
Lists all lines from the lowest number through 1000.
LIST 150-1000 Lists lines 150 through
1000, inclusive.
To list all or part of the program currently in memory at the line printer.
LLIST assumes a 132-character wide printer.
BASIC-SO always returns to command level after an LLIST is executed.
The options for LLIST are the same as for LIST, Format 2.
LLIST and LPRINT are not included in implementations of BASIC-SO.
See the examples for LIST, Format 2.
Purpose:
Remarks:
LOAD <filename>[,R]
Disk
To load a file from disk into memory.
<filename> is the name that was used when the file was SAVEd.
(With CP/M, the default extension .BAS is supplied.)
LOAD closes all open files and deletes all variables and proqram lines currently residing in memory before it loads the designated program.
However, if the "R" option is us
7 d wi th LOAD, the program is RUN after it
J.S
LOADed, and all open data files are kept open.
'l'hus, be used to chain several programs (or segments of the same program).
Information may be passed between the programs using their disk data files.
LPRINT USING <ftfor.matstringft>~<list of expressions>
Extended, Disk
To print data at the line printer.
Same as PRINT and PRINT USING, except output goes to the line printer.
See Section 2.49 and
Section 2.50.
LPRINT assumes a 132-character-wide printer.
LPRINT and LLIST are not included in implementations of BASIC-aO.
LSET <string variable> • <string expression>
RSET <string variable> • <string expression>
To move data from memory to a random file buffer
(in preparation for a POT statement).
If <string expression> requires fewer bytes than were FIELDed to <string variable>, LSET left-justifies the string in the field, and RSET right-justifies the string.
(Spaces are used to pad the extra positions.) If the string is too long for the field, characters are dropped from the right.
Numeric values must be converted to strings before they are LSET or RSET.
See the
MKI$, MKS$, MKD$ functions, Section 3.25.
150 LSET A$-MKS$(AMT)
160 LSET D$-OESC($)
See also Appendix B.
LSET or RSET may also be used with string variable to left-justify or a string in a g~ven field.
For program lines a non-fielded right-justify example, the
110 A$-SPACE$(20)
120 RSET A$=N$ right-justify the string N$ in a 20-character field.
This can be very handy for formatting printed output.
To merge a specified disk file into the program currently in memory.
<filename> is the name used when the file was
SAVEd.
(With CP/M, the default extension .BAS
is supplied.) The file must have been SAVEd in
ASCII format.
(If not, a "Bad file mode" error occurs.)
If any lines in the disk file have the same line numbers as lines in the program in memory, the lines from the file on disk will replace the corresponding lines in memory.
(MERGEing may be thought of as "inserting" the program lines on disk into the program in memory.)
BASIC-SO always returns to command level after executing a MERGE command.
MERGE "NUMBRS"
where n and
<string exp1> expressions.
m are integer expressions and and <string exp2> are string
Extended, Disk
To replace a portion of one string with another string.
The characters in <string exp1>, beginning at position n, are replaced by the characters in
<string exp2>.
The optional m refers to the number of characters from <string exp2> that will be used in the replacement.
If m is omitted, all of <string exp2~ is used.
However, regardless of whether m is omitted or included, the replacement of characters never goes beyond the original length of <string exp1>.
10 A$="KANSAS CITY, MO"
20 MID$(A$,14)="KS"
30 PRINT A$
RUN
KANSAS CITY, KS
MID$ may also be used as a function that returns a substring of a given string.
See Section
3.24.
PU.rJ?ose:
Remarks :
To change the name of a disk file.
<old filename> must exist and <new filename> must not exist; otherwise an error will result.
After a NAME command, the file exists on the same disk, in the same area of disk space, with the newname.
Ok
NAME
II
ACCTS " AS
II
LEDGER"
Ok
In this example, the file that was formerly named ACCTS will now be named LEDGER.
To delete the proqram currently in memory and clear all variables.
NEW is entered at command level to clear memory before entering a new program.
BASIC-SO always returns to command level after a NEW is executed.
8K, Extended, Disk
To set "thenumber of nulls to be printed at the end of each line.
For 10-character-per-second tape punches,
<integer expression> should be >-3.
When tapes are not being punched, <integer expression> should be 0 or 1 for Teletypes and
Teletype-compatible CRTs.
<integer expression> should "be 2 or 3 for 30 cps hard copy printers.
The default value is o.
Ok
NULL 2
Ok
100 INPUT X
200 IF X<SO GaTO 800
•
•
•
Two null characters will be printed after each line.
Extended, Disk
To enable error trapping and specify the first line of the error handling subroutine.
Once error trapping has been enabled all errors detected, including direct mode errors (e.g.,
Syntax errors), will cause a jump to the specified error handling subroutine.
If <line number> does not exist, an ·Undefined line" error results.
To disable error trapping, execute an ON EUOR GOTO o.
Subsequent errors will print an error message and halt execution.
An ON ERROR GOTO 0 statement that appears in an error trapping subroutine causes BASIC-SO to stop.and print the error message for the error that caused the trap.
It is recommended that all error trapping subroutines execute an ON
ERROR GOTO 0 if an error is encountered for which there is no recovery action.
If an error occurs during execution of an error handling subroutine, the BASIC error message is printed and execution terminates.
Error trapping does not occur within the error handling subroutine.
10 ON ERROR GOTO 1000
ON <expression> GOTO <list of line numbers>
'ON <expression> GOSUB <list of line numbers>
SX, Extended, Disk
To branch to one of several specified line numbers, depending on the value returned when an expression is evaluated.
The value of <expression> determines number in the list will be used for
For example, if the value is three, line number in the list will be the which line branching.
the third destination of the branch.
(If the value is a the fractional portion is rounded.) non-integer,
In the ON •••GOSUB statement, each line number in the list must be the first line number of a subroutine.
If the value of <expression> is negative, zero or greater than the number of items in the list, an "Illegal function call" error occurs.
OPEN <mode>, [il<file number>,<filename>,[<reclen>l
Disk
Purpose:
Remarks: A disk file must be OPENed before any disk operation can be performed on that f~le.
allocates a buffer for I/O to the file determines the mode of access that will be with the buffer.
I/O
OPEN
~d used
<mode> is a string expression whose character is one of the following: o specifies sequentia~ output mode
I
R specifies sequential input mode specifies random input/output mode
<file number> is an integer expression whose value is between one and fifteen.
The number is then associated with the file for as long as it is OPEN and is used to refer other disk I/O statements to the file.
<filename> is a string expression containing a name that conforms to your operating system's rules for disk filenames.
<reclen> is an integer expression which, if included, sets the record length for r~dom files.
The default record length is 128 bytes.
See also page A-3.
A file can be OPENed for sequential input or random access on more than one file number at a time.
A file may be OPENed for output, however, on only one file number at a time.
OPTION BASE n where n is 1 or 0
Extended, Disk
To declare the subscripts.
The default base is O.
If the statement is executed, the lowest value an array subscript may have is one.
Purpose:
Remarks:
OUT I,J where: I and J are integer expressions in the range 0 to 255.
aK,
Extended, Disk
To send a byte to a machine output port.
The integer expression I is the port number, and the integer expression J is the data to be transmitted.
POKE I,J where I and J are integer expressions
Purppse:
Remarks:
To write a byte into a memory location.
The integer expression I is the address of the memory location to be POKEd.
The integer expression J is the data to be POKEd.
J must be in the range 0 to 255.
In the 8X version, I must be less than 32768.
In the Extended and
Disk versions, I must be in the range 0 to
65536.
With the 8X version, data may be POKEd into memory locations above 32768 by supplying a negative number for I.
The value of I is computed by subtracting 65536 from the desired address.
For example, to POKE data into location 45000, I • 45000-65536, or -20536.
The complementary funct.ionto POKE is PEEX.
The argument to PEEX is an address from which a byte is to be read.
See Section 3.27.
POKE and PEEX are useful for efficient data storage, loading assembly language subroutines, and passing arguments and results to and from assembly language subroutines.
Purpose:
Remarks:
To output data at the terminal.
If <list of expressions> is omitted, a blank line is printed.
If <list of expressions> is included, the values of the expressions are printed at the terminal.
The expressions in the list may be numeric and/or string expressions.
(Strings must be enclosed in quotation marks.)
The position of each printed item is determined by the punctuation used to separate the items in the list.
BASIC-SO divides the line into print zones of 14 spaces each.
In the list of expressions, a comma causes the next value to be printed at the beginning of the next zone.
A semicolon.causes the next value to be printed immediately after the last value.
Typing one or more spaces between expressions has the same effect as typing a semicolon.
If a comma or a semicolon terminates the list of expressions, the next PRINT statement begins printing on the same line, spacing accordingly.
If the list of expressions terminates without a comma or a semicolon, a carriage return is printed at the end of the line.
If the printed line is longer than the terminal width, BASIC-SO goes to the next physical line and continues printing.
Printed numbers are always followed by a space.
Positive numbers are preceded by a space.
Negative numbers are preceded by a minus s~gn.
Single precision numbers that can be represented with 6 or fewer digits in the unsealed format no less accurately than they can be represented in the scaled format, are output using the unsealed format.
For example, 10A(-6) is output as
.000001
and 10A(-7) is output as 1E-7.
Double precision numbers that ean be represented with
16 or fewer digits in the unsealed format no less accurately than they can be represented in the sealed format, are output using the unsealed format.
For example, 10A(-16) is output as
.0000000000000001
and 10A(-17) is output as
10-17.
A question mark may be used in place of the word
PRINT in a PRINT statement.
Example 1: 10 X=S
20 PRINT X+S, X-S, X*(-S}, XJ\S
30 END
RUN
10 0 -2S
Ok
312S
In this example, the commas in the PRINT statement cause each value to be printed at the beginninq of the next print zone.
Example 2: LIST
10 INPUT X
20 PRINT X "SQUARED IS" XJ\2 "AND";
30 PRINT X "COBED IS" XJ\3
40 PRINT
SO GOTO 10
Ok
RUN
? 9
9 SQUARED IS 81 AND 9 CUBED IS 729
?
21
21 SQUARED IS 441 AND 21 CUBED IS 9261
In this example, the semicolon at the end of line 20 causes both PRINT statements to be printed on the same line, and line 40 causes a blank line to be printed before the next prompt.
Example 3: 10 FOR X
:II
1 TO S
20 J=J+S
30 K=K+10
40 ?J;K;
SO NEXT X
Ok
RUN
S 10 10 20 1S 30 20 40 2S SO
Ok
In this example, the semicolons in the PRINT statement cause each value to be printed immediately after the preceding value.
(Don't forget, a number is always followed by a space and positive numbers are preceded by a space.)
In line 40, a question mark is used instead of the word PRINT.
Remarks and
Examples:
PRINT USING <"format string">;<list of expressions>
Extended, Disk
To print.strings or numbers using a specified format.
<list of expressions> is comprised of the string expressions or numeric expressions that are to be printed, separated by semicolons.
<"format string">, enclosed in quotation marks, is comprised of special formatting characters.
These formatting characters (see below) determine the field and the format of the printed strings or numbers.
String Fields
"!"
When PRINT USING is used to print strings, one of three formatting characters may be used to format the string field:
Spec~fies that only the first character in the given string is to be printed.
"\n spaces\" Specifies that 2+n characters from the string are to be printed.
If the backs lashes are typed with no spaces, two characters will be printed; with one space, three characters will be printed, and so on.
If the string is longer than the field, the extra characters are ignored.
If the field is longer than the string, the string will be left-justified in the field and padded with spaces on the right.
Example:
10 A$-"LOOX":B$-"OUT"
30 PRINT USING "!";A$;B$
40 PRINT USING "\ \" ;A$';
SO PRINT USING "\ \";A$;B$;"!!"
RON
LO
LOOKOUT
LOOK OUT !!
"&"
Specifies a variable length string field.
the field is specified with
When
"&If, the string is output exactly as input.
Example:
10 A$a"LOOK":B$-"OUT"
20 PRINT USING "!";A$;
30 PRINT USING "&";B$
RUN
LOUT
When PRINT USING is used to print numbers, the following special characters may be used to format the numeric field:
A number sign is used to represent each digit position.
Digit positions are always filled.
If the number to be printed has fewer digits than positions right-justified specified, the number will be
(preceded by spaces) in the field.
A decimal point may be inserted at any position in the field.
If the format string specifies that a digit is to precede the decimal point, the digit will always be printed (as 0 if necessary).
Numbers are rounded as necessary.
PRINT USING
0.78
"#1.+.-;.78
PRINT USING
987.65
".II.tt";987.654
PRINT USING
10.20
"ti.it
";10.2,5.3,66.789,.234
5.30
66.79
0.23
In the last example, three spaces were inserted at the end of the format string to separate the printed values on the line.
A plus sign at the beginning or end of the format string will cause the sign of the number
(plus or minus) to be printed before or after the number.
$$.
**$
A minus sign at the end of the format field will cause negative numbers to be printed with a trailing minus sign.
PRINT USING "+tt.ti
";-68.95,2.4,55.6,-.9
-68.95
+2.40
+55.60
-0.90
PRINT USING "tt.ti";-68.95,22.449,-7.01
68.9522.45
7.01-
A double asterisk at the beginning of the format string causes leading spaces in the numeric field to be filled with asterisks.
The
** also specifies positions for two more digits.
PRINT USING "**i.t
";12.39,-0.9,765.1
*12.4
*-0.9
765.1
A double dollar sign causes a dollar sign to be printed to the immediate left of the formatted number.
The $$ specifies two more digit positions, one of which is the dollar sign.
The exponential format cannot be used with $$.
Negative numbers cannot be used unless the minus sign trails to the right.
PRINT USING "$$llt.#i";456.78
$'456.78
The **$ at the beginning of a format string combines the effects of the above two symbols.
Leading spaces will be asterisk-filled and a dollar sign will be printed before the number.
**$ specifies three more digit positions, one of which is the dollar sign.
PRINT USING "**$#i.#t";2.34
***$2.34
A comma that is to the left of the decimal point in a for.matting string causes a comma to be printed to the left of every third digit to the left of the decimal point.
A comma that is at the end of the format string is printed as part of the string.
A comma specifies another digit position.
The comma has no effect if used with the exponential (AAAA) format.
PRINT USING "itii,.ii";1234.5
1,234.50
PRINT USING "iiii.ii,";1234.5
1234.50,
AAAA Four carats (or up-arrows) may be placed after the digit position characters to specify exponential format.
The four carats allow space for E+xx to be printed.
Any decimal point position may be specified.
The significant digits are left-justified, and the exponent is adjusted.
Unless a leading + or trailing + or is specified, one digit position will be used to the left of the decimal point to print a space or a minus sign.
.
PRINT USING "tt.tiAAAA";234.S6
2.3SE+02
PRINT USING ".iiitAAAA-";888888
.8889E+06
PRINT USING "+.ttAAAA";123
+.12E+03
An underscore in the format string causes the next character to be output as a literal character.
PRINT USING" 1il.##_1";12.34
112.341
The literal character itself may be an underscore by placing "__ " in the format string.
If the number to be printed is larger than the specified numeric field, a percent sign is printed in front of the number.
If rounding causes the number to exceed the field, a percent sign will number.
be printed in front of the rounded
PRINT USING "#I.ii":111.22
'111.22
PRINT USING ".#''';.999
'1.00
If the number of digits specified exceeds 24, an
"Illegal function call" error will result.
Purpose:
Remarks:
PRINTi<filenumber>,[USING<"format string">1]<list of exps:
Disk
To write data to a sequential disk file.
<filenumber> is the number used when the file was OPENed for output.
<"format string"> is comprised of formatting characters as described in Section 2.50, PRINT USING.
The expressions in <list of expressions> are the numeric and/or string expressions that will be written to the file.
PRZNTt does not compress data on the disk.
An image of the data is written to the disk, just as it would be displayed on the terminal with a
PRINT statement.
For this reason, care should be taken to delimit the data on the disk, so that it will be input correctly from the disk.
In the list of expressions, numeric should be delimited by semicolons.
expressions
For example,
(If commas are used as delimiters, the extra blanks that are inserted between print fields will also be written to disk.)
String expressions must be separated by semicolons in the list.
To format the string expressions correctly on the disk, use explicit delimiters in the list of expressions.
For example, let A$="CAMERA"
The statement and 5$=-"93604-1".
would write CAMERA93604-1 to the disk.
Because there are no delimiters, this could not be input as two separate strings.
To correct the problem, insert explicit delimiters into the
PRINTi statement as follows:
which can be read back variables.
If the strings themselves contain semicolons, significant leading blanks, returns, or line feeds, write them surrounded
CHR$(34).
by explicit quotation commas, carriage to disk marks,
For example, let A$-"CAMERA, AUTOMATIC"
B$-" 93604-1".
The statement and would input "CAMERA" to
"AUTOMATIC 93604-1" to B$.
To strings properly on the disk, quotes to the disk image using statement
A$ and separate these write double
CHR$ (34).
'The
"CAMERA, AUTOMATIC"" and the statement would input "CAMERA, AUTOMATIC" to
" 93604-1" to B$.
The PRINTt statement may also be used with the
USING option to control the format of the disk file.
For example:
PRINT#1,USING"$$###.##,";J;K;L
PUT [i]<file number>[,<record number>]
Disk
To write a record from a random buffer to a random disk file.
<file number> is the number under which the file was OPENed.
I"f<record number> is omitted, the record will have the next avai~able record number (after the last PUT).
The largest possible record number is 32767.
See Appendix B.
RANDOMIZE «expression>]
Extended, Disk
If <expression> is program execution printing omitted, and asks
BASIC-80 for
Random Number Seed (0-65529)?
a suspends value by
If ~e random number generator is not reseeded, the RND function returns ~e same sequence of random numbers each time the program is RUN.
To change the sequence of random numbers every time the program is RUN, place a RANDOMIZE statement at the beginning of the program and change the argument with each RON.
10 Rk'mOMIZE
2.0
FOR I-1 TO 5
30 PRINT RND J
40 NEXT I
RON
Random Number Seed (0-65529)? 3 (user types 3)
.88598
.484668
.586328
.119426
.709225
Ok
RUN
Random Number Seed (0-65529)?
4 (user types 4 for new sequence)
.803506
.162462
.929364
.292443
.322921
Ok
RON
Random Number Seed (0-65529)?
3 (same sequence as first RUN)
.88598
.484668
.586328
.119426
.709225
Ok
With the BASIC Compiler, the prompt given by
RANDOMIZE is:
Random Number Seed (-32768 to 32767)?
8K, Extended, Disk
To read values from a DATA statement and assign them to variables.
(See DATA, Section 2.10.)
A READ statement must always be conjunction with a DATA used statement.
in
READ statements assign variables to DATA statement values on a one-to-one basis.
READ statement variables may be numeric or string, and the values read must agree with the variable types specified.
If they do not agree, a ~Syntax error" will result.
A single READ statement may access one or more
DATA statements (they will be accessed in order), or several~.
statements may access the same DATA statment.
If the num}:)er of variables in <list of variables> exceeds the numJ::)er an
OUT OF DATA messaqe is printed.
If the number of variables specified is fewer than the number of elements in the DATA statement (s), subsequent
READ statements will beqin reading data at the first unread element.
If there are no subsequent READ statements, the extra data is ignored.
To reread DATA statements from the RESTORE statement (see
2.57) the start, use
RESTORE, Section
•
80 FOR 1=1 TO 10·
90 READ A(I)
100 NEXT I
110 DATA 3.08,5.19,3.12,3.98,4.24
120 DATA 5.08,5.55,4.00,3.16,3.31
Thia proqram.segment READs the values
DATA statements into the array execution, the value of A(1) will be so on.
from the
A.
3.08,
After and
Example 2: LIST
10 PRINT "CITY", "STATE", " ZIP"
20 READ C$,S$,Z
30 DATA "DENVER,", COLORADO, 80211
40 PRINT C$,S$,Z
Ok
RON '
CITY
DENVER,
Ok
STATE
COLORADO
ZIP
80211
This program READs string and numeric data from the DATA statement in line 30.
SK, ~ended, Disk
To allow explanatory remarks to be inserted in a program.
REM statements are not executed but are output exactly as entered when the program is listed.
REM statements may be branched into (from a GaTO or GOSUB statement), and execution will continue with the first executable statement after the
REM statement.
In the Extended and Disk versions, remarks may be added to the end of a line by preceding the remark with a single quotation mark instead of
:REM •
•
120 REM CALCULATE AVERAGE VELOCITY
130 FOR I-1 TO 20
140 SUM-SUM + VeIl
120 FOR I-1 TO 20
130 SUM-SUM+V (I)
140 NEXT I
Purpose:
Remarks:
RENUM [[<new number>] [,[<old number>] [,<increment>]]]
Extended, Disk
To renumber program lines.
<new number> is the first line number to be used in the new sequence.
The default is 10.
<old number> is the line in the current program where renumbering is to begin.
The default is the first line of the program.
<increment> is the increment to be used in the new sequence.
The default is 10.
RENCH also changes all line number references following GOTO, GOSUB, THEN, ON •••GOTO,
ON •••GOSUB and ERL statements to reflect the new line numbers.
If a nonexistent line number appears after one of these statements, the error message "Undefined line xxxxx in yyyyy" is printed.
The incorrect line number reference
(xxxxx) is not changed by RENUM, but line number yyyyy may be .changed.
RENUM cannot be used to change the order of program lines (for example, RENUM 15,30 when the program has three lines numbered 10, 20 and 30) or to create line numbers greater than 65529.
An "Illegal function call" error will result.
Renumbers the entire program.
The first new line number will be 10. Lines will increment by 10.
RENUM 30G,,50 Renumbers the entire program. The first new line number will be 300.
Lines will increment by 50.
RENUM 1000,900,20 Renumbers the lines from
900 up so they start with line number 1000 and increment by 20.
Example:
8K, Extended, Disk
To allow DATA statements to be reread from a specified point.
After a RESTORE statement is executed, the next
READ statement accesses the first item in the first DATA statement in the program.
If <line number> is specified, the next READ statement accesses the first item in the specified DATA statement.
10
20
30
40
READ A,B,C
RESTOBE
READ D,E,F
DATA 57, 68, 79
•
•
•
RESUME
RESUME 0
To continue program execution after an error recovery procedure has been performed.
Anyone of the four formats shown above may be used, depending upon where execution is to resume:
RESUME
or
RESUME 0
Execution resumes at the statement which caused the error.
Execution resumes at the statement immediately following the one which
.caused the error.
RESUME <line number> Execution resumes at
<line number>.
A RESUME statement that is not in an error trap routine causes a "RESUME without error" message to be printed.
10 ON ERROR GOTO 900
900 IF (ERR-230) AND (ERL=90) THEN PRINT ftTRY
AGAIN" :RESUME 80
Purpose:
Remarks:
RON [<line number>]
SX Ex~ended, Disk
To execu~e the program currently in memory.
If <line number> is specified, execution begins on that line.
Otherwise, execution begins at the lowest line number.
BASIC-SO always returns to command level after a RUN is executed.
Purpose:
Remarks:
RON <filename> [,R]
Disk
To load a file from disk into memory and run it.
<filename> is the name used when the file was
SAVEd.
The default ex~ension .BAS is supplied.
RON closes all open current contents of designated program.
option, all data files files and deletes memory before loading
However, with the remain OPEN.
the the
"R"
RON "NEWFIL",R
Purpose:
Remarks:
SAW <filename> [,A
I
,P]
Disk
To save a program file on disk.
<filename> is a quoted string that conforms to your operating system's requirements for filenames.
(With CP/M, the default extension
.BAS is supplied.) If <filename> already exists, the file will be written over.
Use the A option to save the file in ASCII format.
Otherwise, BASIC saves the file in a compressed binary format.
ASCII format takes more space on the disk, but some disk access requires that files be in ASCII format.
For instance, the MERGE command requires an ASCII format file, and some operating system commands may require an ASCII format file.
Use the P option to protect the file by saving it in an encoded binary for.mat.
When a protected file is later RUN (or LOADed), any attempt to list or edit it will fail.
SAW"COM2",A
SAWnpROG",P
See also Appendix B.
SK, Extended, Disk
To terminate program execution and return to command level.
STOP statements may be used anywhere in a program to terminate execution.
When a STOP is encountered, the following message is printed:
Unlike the END statement, the STOP' statement does not close files.
BASIC-SO always returns to command level after a
STOP is executed.
Execution is resumed by issuing a CONT command (see Section 2.S).
10 INPUT A, B , C
20 K-AA2*5.3:L-BA3/.26
30 STOP
40 M-C*K+100:PRINT M
RON
? 1,2,3
BREAK IN 30
Ok
PRINT L
30.7692
Ok
CONT
115.9
Ok
Purpose:
Remarks: Any type variable may be S~ped (integer, single precision, double precision, string), but the two variables must be of the same type or a
"Type mismatch n error results.
LIST
10 A$-" ONE n': B$-" ALL " : C$-
It
FOR"
20 PRINT A$ C$ B$
30 SWAP A$, B$
40 P~NT A$ C$ B$
RON
Ok
ONE FOR ALL
ALL FOR ONE
Ok
Purpose:
Remarks: As an aid in debugging, the TRON statement
(executed in either the direct or indirect mode) enables a trace flag that prints each line number of the program as it is executed.
The numbers appear enclosed in square brackets.
The trace flag is disabled with the TROFF statement
(or when a NEW command is executed).
TRON
Ok
LIST
10 K-10
20 FOR J-1 TO 2
30 L-K + 10
40 PRINTJ1K,L
SO K=K+10
60 NEXT
70 END
Ok
RUN
[10][20][30][40] 1 10 20
[SO] [60][30][40] 2 20 30
[SO] [60][70]
Ok
TROFF
Ok
WAIT <port number>, I[,J] where I and J are integer expressions
SK, Extended, Disk
To suspend program execution while monitoring the status of a machine input port.
The WAIT statement causes execution to be suspended until a specified machine input port develops a specified bit pattern.
The data read at the port is exclusive ORIed with the integer expression J, and then AND Ied with I.
If the result is zero, BASIC-SO loops back and reads the data at the port again.
If the result is nonzero, execution continues with the next statement.
If J is omitted, it is assumed to be zero.
It is possible to enter an infinite loop with the WAIT statement, in which case it will be necessary to manually restart the machine.
•
[<loop statements>]
To execute a series of statements in a loop as long as a given condition is true.
If <expression> is not zero (i.e., true), <loop statements> are executed until the WEND statement is encountered.
BASIC then returns to the WHILE statement and checks <expression>.
If it is still true, the process is repeated.
If it is not true, execution resumes with the statement following the WEND statement.
WHILE/WEND loops may be nested to any level.
Each WEND will match the most recent WHILE.
An unmatched WHILE statement causes a "WHILE without WEND" error, and an unmatched WEND statement causes a "~ieNDwithout WEILE n er~or.
90 'SUBBLE SORT ARRAY A$
100 FLIPS-1 'FORCE ONE PASS
110 WHILE FLIPS
115
120
130
FLIPS-O
FOR I-1 TO J-1
IF A$(I»A$(I+1) THEN
SWAP A$(I),A$(I+1):FLIPS-1
140
150 WEND
WIDTH [LPRINT] <integer expression>
Extended, Disk
To set the printed line width in number of characters for the terminal or line printer.
If the LPRINT option is omitted, the line width is set at the terminal.
If LPRINT is included, the line width is set at the line printer.
<integer expression> must have a value in the range 15 to 255.
The default width is 72 characters.
If <integer expression> is 255, the line width is "infinite," that is, BASIC never inserts a carriage return.
However, the position of the cursor or the print head, as given by the POS or
LPOS function, returns to zero after position
255.
Purpose:
Remarks:
W~TE[<list of expressions>]
Disk
To output data at the 'terminal.
If <list of expressions> is omitted, a blank line is output.
If <list of expressions> is included, the values of the expressions are· output at the terminal.
The expressions in the list may be numeric and/or string expressions, and they must be separated by commas.
When the printed items are output, each item will be separated from the last by a comma.
Printed strings will be delimited by quotation marks.
After the last item in the list is printed, BASIC inserts a carriage return/line feed.
~TE outputs numeric values using the same format as the PRINT statement, Section 2.49.
10 A-SO:B-90:C$=TRAT'S ALL
20 ~TE A,B,C$
RUN
SO, 90,nTRAT'S ALLn
Ok
Purpose:
Remarks:
WRXTE#<file number>,<list of expressions>
Disk
To write data to a sequential file.
<file number> is the number under which the file was OPENed in "0" mode.
The expressions in the list are strinq or numeric expressions, and ~~ey must be separated by commas.
The difference between WRITE' and PRINT; is that
WRITE; inserts commas between the items as they are written to disk and delimits st:inqs with quotation marks.
Therefore, it is not necessary for the user to put ·explicit delimiters in the list.
A carriaqe return/line feed sequence is inserted after the last item in the list is written to disk.
Let A$-" CA&.'mRA n statement:
WRITE,1,AS,B$ writes the followinq imaqe to disk:
The in~insic fun~ions provided by BASIC-SO are presented in this chapter.
The functions may be called from any proqram without further definition.
Arquments to functions are always enclosed in parentheses.
In the formats qiven for the functions in this chapter, the arquments have been abbreviated as follows:
X and Y
I and J
X$ and Y$
Represent any numeric expressions
Represent inteqer expressions
Represent strinq expressions
If a floatinq point va~ue is supplied where an inteqer is required, BASIC-SO wil~ round the fractional portion and use the resultinq inteqer.
SK, Extended, Disk
Returns the absolute value of the expression X.
PRINT ABS(7*(-S»
35
Ok
8K, Extended, Disk
Returns a numerical value that is the ASCII code of the first character of the string X$.
(See
Appendix L for ASCII codes.) If X$ is null, an ftIllegal function callft error is returned.
10 X$ • ftTEST ft
20 PRINT ASC (X$)
RUN
Ok
84
See the CRR$ function conversion.
aR, Extended, Disk
Returns the arctangent of X in radians.
Result is in the range -pi/2 to pi/2.
The expression X may be any numeric type, but the evaluation of
ATN is always performed in single precision.
10 INPUT X
20 PRINT ATN (X)
RUN
?
3
1.24905
Ok
10 A =454.67
20 PRINT A;CDBL(A)
RUN
454.67
454.6700134277344
Ok
Returns a string whose one element has ASCII code I.
(ASCII codes are listed in Appendix L.)
CHR$ is commonly used to send a spec~al character to the terminal.
For instance, the
BEL character could be sent (CHR$(7») as a preface to an error message, or a form feed could be sent (CHR$(12)) to clear a CRT screen and return the cursor to the home position.
PRINT CHR$ (66)
B
Ok
See the ASC function conversion.
Extended, Disk
Converts X to an integer by rounding . the fractional portion.
If X is not in the range
-32768 to 32767, an "Overflow" error occurs.
PRINT CINT(4S.67)
Ok
46
See the CDSL and CSNG functions for converting numbers to the double precision and single precision data type.
See also the FIX and INT functions, both of which return integers.
8K, Extended, Disk
Returns tile cosine of X calculation of COS(X) is precision.
in radians.
The performed in single
10 X • 2*COS(.4)
20 PRINT X
RUN
1.84212
Ok
10 Ai • 975.3421.
20 PRINT Ai; CSNG(A#)
RUN
975.3421" 975.342
Ok
See the C!NT and CDSL functions for converting numbers to tileinteger and double precision data types.
CVI«2-byte string»
CVS«4-byte string»
CVD«S-byte string»
Disk
Convert string values to numeric values.
Numeric values that are read in from a random disk file must be converted from strings back into numbers.
CVI converts a 2-byte string to an integer.
CVS converts a 4-byte string to a single precision number.
CVD converts an S-byte string to a double precision number •
•
70 FIELD #1,4 AS N$, 12 AS B$, •••
SO GET #1
90 Y=CVS(N$)
See also MKI$, MKS$, MKD$, Section 3.25
and
Appendix B.
Returns -1 (true) if the end of a sequential file has been reached.
Use EOF to test for end-of-file while INPUTting, to avoid "Input· past end" errors.
10 OPEN "I",1,"DATA"
20 C=O
30 IF EOF(1) THEN 100
40 INPUT if 1 ,M (C)
50 C=C+1:GOTO 30
8K, Extended, Disk
Returns e to the power of X.
X must be
<a87.3365.
If EXP overflows, the "Overflow" error message is displayed, machine infinity with the appropriate sign is supplied as the result, and execution continues.
10 X
=
5
20 PRINT EXP (X-1)
RUN
54.5982
Ok
Returns the truncated integer part of X.
FIX (X) is equivalent to SGN(X)*INT(ABS(X».
The major difference between FIX and INT is that FIX does not retu-~ the next lower number for negative X.
PRINT FIX(58.75)
58
Ok
PRINT FIX(-58.75)
-58
Ok
FRE (0)
FRE (X$)
Arguments to PRE are dummy arguments.
If ~~e argument is 0 (numeric), FRE returns 1:11enumber of bytes in memory not being used by BASIC-SO.
If the argument is a string, FRE returns the number of free bytes in string space.
PRINT FRE(O)
14542
Ok
Returns hexadecimal a rounded to evaluated.
string which represents value of the decimal argument.
an integer before HEX$(X)
X the is is
10 INPUT X
20 A$
:It
HEX$ (X)
30 PRINT X "DECIMAL IS " A$ " HEXADECIMAL"
RON
?
32
32 DEC~
Ok
IS 20 HEXADECIMAL
SK, Extended, Disk
Returns the byte read from port I.
I must be in the range 0 to 255.
INP is the complementary function to the OUT statement, Section 2.47.
Action: Returns a string of X characters, read from the terminal or from file number Y.
If the terminal is used for input, no characters will be echoed and all control characters are passed through except Control-C, which is used to interrupt the execution of the INPUT$ function.
Example 1: 5' LIST THE CONTENTS OF A SEQUENTIAL FILE IN
HEXADECIMAL
100PEN"I",1,"OATA"
20 IF EOF(1) THEN 50
30 PRINT HEX${ASC{INPUT${1,.1»):
40 GOTO 20
50 PRINT
60 END
•
100 PRINT "TYPE P TO PROCEED OR S TO STOP"
110 X$=INPUT$(1)
120 IF X$="p lI
THEN 500
130 IF X$=
II
S" THEN 700 ELSE 100
Extended, Disk
Searches for the first occurrence of string Y$ in X$ and returns the position at which the match is found.
Optional offset I sets the position for starting the search.
I must be in therange 0 to 255.
If I>LEN(X$) or if X$ is null or if Y$ cannot be found, INSTR returns O.
If Y$ is null, INSTR returns I or 1.
X$ and Y$ may be string variables, string expressions or string literals.
10 X$ • "ABCDEB"
20 Y$ ="B"
30 PRINT INSTR(X$,Y$);INSTR(4,X$,Y$)
RUN
2 6
Ok
SK, Extended, Disk
Returns the largest integer <=X.
PRINT INT (99.89)
99
Ok
PRINT INT(-12.11)
-13
Ok
See the FIX and CINT functions which also return integer values.
SK, Extended, Disk
Returns a string comprised of the leftmost I characters of X$.
I must be in the range 0 to
25'5. If I is greater than LEN (X$), the entire string (X$) will be returned.
If I-O, the null string (length zero) is returned.
10 A$ - "BASIC-SO"
20 B$ • LEFT$ (A$,5)
30 PRINT B$
BASIC
Ok
Returns the number of characters in X$.
Non-printing characters and blanks are counted.
10 X$
=-
"PORTLAND, OREGON"
20 PRINT LEN (X$)
16
Ok
With random disk files, Loe returns the next record number to be used if a GET or PUT
(without a record number) is executed.
With sequential files, LOC returns the number of sectors (128 byte blocks) read from or written to the file since it was OPENed.
8K, Extended, Disk
Returns the natural logarithm of X.
X must be greater than zero.
PRINT LOG (45/7)
1.86075
Ok-
Returns the current position of the line printer print head within the line printer buffer.
Does not necessarily give the physical position of the print head.
X is a dummy argument.
SK, Extended, Disk
Returns a string of length J characters from X$ beginning with the Ith character.
I and J must be in the range 0 to 255.
If J is omitted or if there are fewer than J characters to the right of the Ith character, all rightmost characters beginning with the Ith character are returned.
If I>LEN(X$), MID$ returns a null string.
LIST
10 A$="GOOD ••
20 B$_nMORNING EVENING AFTERNOON"
30 PRINT A$;MID$(B$,9,7)
Ok
RUN
GOOD EVENING
Ok
MKI$«integer expression»
MKS$«single precision ~~ression»
MKD$«double precision expression»
Disk convert numeric values to string values.
Any numeric value that is placed in a random file buffer with an LSET or RSET statement must be converted to a string.
MKI$ converts an integer to a 2-byte string.
MKS$ converts a single precision number to a 4-byte string.
MKD$ converts a double precision number to an a-byte string.
90 AMTw(K+T)
100 FIELD #1, 8 AS D$, 20 AS N$
110 LSET D$ • MKS$(AMT)
120 LSET N$ • A$
130 POT #1
See also CVI, CVS,
B.
evo,
Section 3.9 and Appendix
Returns a string which represents the octal value of the decimal argument.
X is rounded to an integer before OCT$(X) is evaluated.
PRINT OCT$(24)
30
Ok
See the HEX$ conversion.
I for
Returns the byte (decimal integer in the range a to 255) read from memory location I.
With the
SK version of BASIC-SO, I must be less than
3276S.
To PEEK at a memory location above
3276S, subtract 65536 from the desired address.
With Extended and Disk BASIC-aO, I must be in the range a to 65536.
PEEK is the complementary function to the POKE statement, Section 2.4S.
Returns the current cursor position.
leftmost position is
The o.
X is a dummy argument.
Re~urns the rightmos~ I charac~ers of s~ring X$.
If I-LEN(X$), re~urns X$.
If I-O, the null s~ring (length zero) is re~urned.
10 A$-HDISK BASIC-SO·
20 PRINT RIGHT$ (A$,S)
RUN
BASIC-SO
Ok
SK, Ex~ended, Disk
Returns a random number be~ween 0 and 1• The same sequence of random numbers is qenera~ed each ~ime the program is RUN unless the random number generator is reseeded (see RANDOMIZE,
Section 2.53).
However, X<O always restarts the same sequence for any given X.
X>O or X omitted generates the nex~ random number in the sequence.
X=O repeats the last number generated.
10 FOR I-1 TO 5
20 PRINT INT(RND*100);
30 NEXT
RUN
24 30 31 51 5
Ok
If X>O, SGN(X) returns 1.
It
X-O, SGN(X) returns O.
It X<O, SGN(X) returns -1.
ON SGN(X)+2 GOTO 100,200,300 branches to 100 if
X is negative, 200 if X is 0 and 300 if X is positive.
SK, Extended, Disk
Returns the sine of X in calculated in
COS(X)-S~(X+3.14159/2).
radians.
single
PRINT SIN (1.5)
.997495
Ok
SIN (X) is precision.
SK, Extended, Disk
Returns a string of spaces of length X.
The expression X is rounded to an integer and must be in the range 0 to 255.
10 FOR I • 1 TO 5
20 X$
=
SPACE$ (I)
30 PRINT X$;I
40 NEXT I
RUN
1
2
3
4
5
SK, Extended, Disk
Prints I blanks on the terminal.
SPC may only be used with PRINT and LPRINT statements.
I must be'in the range 0 to 255.
PRINT "OVER" SPC(15) "THERE"
OVER THERE
Ok
SK, Extended, Disk
Returns the square root of X.
X must be >-0.
10 FOR X
20 PRINT
30 NEXT
RUN
10
15
20
25
Ok
• 10 TO 25 STEP 5
X, SQR(X)
3.16228
3.87298
4.47214
5
Returns a string representation of the value of
X.
5 REM ARITHMETIC FOR KIDS
10 INPUT "TYPE A NUMBER"; N
20 ON LEN(STR$(N» GOSUB 30,100,200,300,400,500
STRING$(I,J)
STRING $ (I,X$)
Returns a string of length I whose characters all have ASCII code J or the first character of
X$.
10 X$
=
STRING$(10,45)
20 PRINT X$ "MONTHLY REPORT" X$
RUN
----------MONTHLY REPORT----------
Ok
Action: .Spaces
to position I on the terminal.
If the current print position is already beyond space
I, TAB goes to that position on the next line.
Space 0 is the leftmost position, and the rightmost position is the width minus one.
I must be in the range 0 to 255.
TAB may only be used in
PRINT and LPRINT statements.
10 PRINT "NAME" TAB (25) "AMOUNT" : PRINT
20 READ A$,B$
30 PRINT A$ TAB(25) B$
40 DATA "G. T. JONES","$25.00"
RUN
NAME AMOUNT
G. T. JONES
Ok
Returns the t.angent.
TAN (X) is calculated in single prec1s10n.
If TAN overflows, the "Overflow" error message is displayed, machine infinit.ywith the appropriat.e
sign is supplied as t.he result., and execut.ion
continues.
SK, Extended, Disk
Calls the user's assembly language subroutine with the argument X.
<digit> is allowed in the
Extended ~~d Disk versions only.
<digit> is in the range 0 t.o9 and corresponds t.othe digit.
supplied with the DEF USR st.atement for that routine.
If <digit> is omitted, USRO is assumed.
See Appendix c.
40
50
60
B =T*SIN(Y)
C = USR(B/2)
D
=
USR(B/3)
Re~urns the numerical value of s~inq X$.
If the firs~ character of X$ is no~ +, -, &, or a
10 READ NAME$,CITY$,STATE$,ZIP$
20 IF VAL(ZIP$)<90000 OR VAL(ZIP$»96699 THEN
PRINT NAME$ TAB(25) "OUT OF STATE"
30 IF VAL(ZIP$»-90801 AND VAL(ZIP$)<-90815 THEN
PUNT NAME$ TAB (25) "LONG BEACH"
See the STR$ func~ion for numeric to s~inq conversion.
Format 1: Returns the address of the first byte of data identified with <variable name>.
A value must be assigned to <variable name> prior to execution of VARPTR.
Otherwise an "Illegal function call" error results.
Any type variable name may be used (numeric, string, array), and the address returned will be an integer in the range 32767 to -32768.
If a negative address is returned, add it to 65536 to obtain the actual address.
VARPTR is usually used to obtain the.address
of a variable or array so it may be passed to an assembly language subroutine.
A function call of the form VARPTR(A(O» is usually specified when passing an array, so that the lowest-addressed element of the array is returned.
All simple variables should be assigned before calling VARPTR for an array, because the addresses of the arrays change whenever a new simple variable is assigned.
Format 2: Returns the starting address of the disk I/O buffer assigned to <file number>.
In Standalone Dis~ BASIC, VARPTR(i<file number» returns the first byte of the file block.
See
Appendix H.
The execution of BASIC programs written under Microsoft
BASIC, release 4.51
and earlier may be affected by some of the new features in release 5.0.
Before such programs, check for the following: attempting to run
1• New reserved words: CALL, CHAZN, COMMON, WHILE,
WEND, WRITE, OPTION BASE, RANDOMIZE.
2.
Conversion from floating point to integer values results in rounding, as opposed to truncation.
This affects not only assignment statements (e.g.,
Ii-2.5
results in Ii-3), but also affects function and statement evaluations (e.g., TAB(4.5) goes to the 5th position, A(1.5) yeilds A(2), and X=11.5
MOO 4 yields 0 for X).
The body of a FOR •••NEXT loop is skipped if initial value ~f the loop times the sign of step exceeds the final value times the sign of step.
See Section 2.22.
the the the
4.
Division by zero and overflow no longer produce fatal errors.
See Section 1.8.1.2.
5.
The RND function has been changed so that RND with no argument is the same as RND with a positive argument.
The RND function generates the same sequence of random numbers with each RUN, unless
RANDOMIZE is used.
See Sections 2.53
and 3.30.
6.
The rules for PRINTing single precision and double precision numbers have been changed.
See Section
2.49.
7.
String space is allocated dynamically, and the first argument in a two-argument CLEAR statement sets the end of memory.
The second argument sets the amount of stack space.
See Section 2.4.
8.
Responding to INPUT with too many or too few items, or with the wrong type of value (numeric instead of string, etc.), or with a carriage return causes the message R?Redo
from startR to be printed.
No assignment of input values is made until an acceptable response is given.
9.
There ·are two new field formatting characters for use with PRINT USING.
An ampersand is used for variable length string fields, and an underscore signifies a literal character in a format string.
10.
If the expression supplied with t~e WIDTH statement is 2SS, BASIC uses an RinfiniteR line width, that is, it does not insert carriage returns.
WIDTH
LPRINT may be used to set the line width at the line printer.
See Section 2.66.
11.
The at-sign and underscore are no longer used as editing characters.
12.
Variable names are significant up to 40 characters and can contain embedded reserved words.
However, reserved words must now be delimited by spaces.
To maintain compatibility with earlier versions of
BASIC, spaces will be automatically inserted between adjoining reserved words and variable names.
WARNING: This insertion of spaces may cause the end of a line to be truncated if the line length is close to 2SS characters.
13.
BASIC programs may be saved in a protected binary format.
See SAVE, Section 2.60.
In CP/M' BASIC-SO, release 5.0, a number of additions have been made to disk I/O capability:
1.
After a GET statement, INPUTi and LINE INPUTt may be done to read characters from the random file buffer.
PRINTt,
.PRINTt USING, and WRITEt may also be used to put characters in the random file buffer before a PUT statement.
In the case of'WRITEt, BASIC-SO pads the buffer with spaces up to the carriage return.
Any attempt to read or write past the end of the buffer causes a "Field overflow" error.
2.
/S:<max record size> may be added at the end of the command line to set the maximum record size for use with random files.
The default record size is 128 bytes.
A new feature has been added to the INPUT statement.
A comma may be used instead of a semicolon after the prompt string to suppress the question mark.
For example, the statement
INPUT "ENTER BIRTHDATE",B$ will print the prompt with no question mark.
APPENDIX B
BASIC-SO Disk I/O
Disk I/O procedures for the beginning BASIC-SO user are examined in this appendix.
If you are new to BASIC-SO or if you're getting disk related errors, read through these procedures and program examples to make sure you're using all the disk statements correctly.
Wherever a filename is required in a disk command or statement, use a name that conforms to your operating system's requirements for filenames.
The CP/M operating system will append a default extension .BAS to the filename given in a SAVE, RUN, MERGE or LOAD command.
Here is a review of the commands and statements used in program file manipulation.
Writes to disk the program that is currently residing in memory.
Optional A writes the program as a series of ASCII characters.
(Otherwise, BASIC uses a compressed binary format.)
Loads the program from disk into memory.
Optional R runs the program immediately.
LOAD always deletes the current contents of memory and closes all files before LOADing.
If R is included, however, open data files are kept open.
Thus programs can be chained or loaded in sections and access the same data files.
RUN "filename" loads the program from disk into memory and runs it.
RUN deletes the current contents of memory and closes all files before loading the program.
If the R option is included, however, all open data files are kept open.
Loads the program from disk into memory but does not delete the current contents of memory.
The program line numbers on disk are merged with the line numbers in memory.
If two lines have the same number, only the line from the disk program is saved.
After a MERGE command, the "merged" program resides in memory, and BASIC returns to command level.
Deletes the file from the disk.
"filename" may be a program file, or a sequential or random access data file.
To change the name of a disk file, execute the NAME statement, NAME
"oldfile" AS "newfile".
NAME may be used with program files, random files, or sequential files.
If you wish to save a program in an encoded binary format, use the "Protect" option with the SAVE command.
For example:
SAVE "MYPROG",P
A program saved this way cannot be listed or edited.
There are two types of disk data files ~~at may be created and accessed by a BASIC-SO program: sequential files and random access files.
B.3~1 Sequential Files
Sequential files are easier to create than random files but are limited in flexibility and speed when it comes to accessing the data.
The data that is written to a sequential file is stored, one item after another
(sequentially), in the order it is sent and is read back in the same way.
The statements and functions that are used with sequential files are:
PRINT# INPUT#
PRINT# OSING LINE INPUT#
The following program steps are required to create a sequential file and access the data in the file:
2.
Write data to the file using the PRINT# statement.
(WRITE. maybe used instead.)
3.
To access the data in the file, you must CLOSE the file and reOPEN it in "I" mode.
OPEN "I",,1,"DATA"
4.
Ose the INPUTi statement to read data from the sequential file into the program.
Program B-1 is a short program that creates a sequential file, "DATA", from information you input at the terminal.
10 OPEN "O",#1,"DATA"
20 INPUT "NAME";NS.
2S IF NS."DONE" THEN END
30 INPUT "DEPARTMENT";D$
40 INPUT "DATE HIRED";H$
50 PRINTt1,N$;",";D$;",";H$
60 PRINT:GOTO 20
RUN
NAME? MICKEY MOUSE
DEPARTMENT? AODIO!VISUAL
AIDS
DATE HIRED? 01/12/72
NAME? SHERLOCK HOLMES
DEPARTMENT?
RESEARCH
DATE HIRED? 12/03/65
NAME? EBENEEZER SCROOGE
DEPA.~~n?
ACCOUNTING
DATE HIRED? 04/27/78
NAME? StJPERMANN
OEPARTMENT? ~.AINTENANCE
OATE HIRED? 08/16/78
Now look at Program B-2.
It accesses the file "DATA" that was created in Program B-1 and displays the name of everyone hired in 1978.
10 OPEN "I",t1,"OATA"
20 INPUTt1,N$,D$,H$
30 IF RIGHT$ (H$,2).n7S" THEN PRINT N$
40 GOTO 20
RUN
EBENEEZER SCROOGE
SUPER MANN
Input past end in 20
Ok
Program B-2 reads, sequentially, every item in the file.
When all the data has been read, line 20 causes an "Input past end" error.
To avoid getting this error, insert line
1S which uses the EOF function to test for end-of-file:
A program that creates a sequential file can also write formatted data to ~~e disk with the PRINT# USING statement.
For example, the statement
PRINT#1,USING"#ttt.tt,";A,B,e,o could be used to write numeric data to disk without explicit delimiters.
The comma at the end of the format string serves to separate the items in the disk file.
The Loe function, when used with a sequential file, returns the number of sectors that have been written to or read from the file since it was OPENed.
A sector is a 128-byte block of data.
B.3.1.1
Adding
~!£ ~
Seauential File -
If you have a sequential file residing on disk and later want to add more data to the end of it, you cannot simply open the file in "0" mode and start writing data.
As soon as you open a sequential file in "0" mode, you destroy its current contents.
The following procedure can be used to add data to an existing file called "~AMES".
7.
Now there is a file on disk called "NAMES" that includes all the previous data plus the new data you just added.
Program B-3 illustrates this technique.
It can be used to create or add onto a file called NAMES.
This program also illustrates the use of LINE INPUTt to read strings with embedded commas from the disk file.
Remember, LINE INPUT# will read in characters from the disk until it sees a carriage return (it does not stop at quotes or commas) or until it has read 255 characters.
10 ON ERROR GOTO 2000
20 OPEN "I", t 1, "NAMES'·
30 REM IF FILE EXISTS, WRITE IT TO '·COPY"
40 OPEN
II
0" , i 2 ,"COpy'·
50 IF EOF (1) THEN 90
60 LINE INPUTi1,A$
70 PRINTt2,A$
80 GOTO 50
90 CLOSE .1
100 KILL -NAMES"
110 REM ADD NEW ENTRIES TO FILE
120 INPUT "NAME" ;N$
130 IF N$-"" THEN 200 'CARRIAGE RETURN EXITS INPUT LOOP
140 LINE INPUT "ADDRESS?
"iA$
150 LINE INPUT "BIRTHDAY?
"iB$
160 PRINTt2,N$
170 PRINTt2,A$
180 PRINTt2,B$
190 PRINT:GOTO 120
200 CLOSE
205 REM CHANGE FILENAME BACK TO ··NAMES"
210 NAME "COpy" AS "NAMES ,.
2000 IF ERR-53 AND ERL=20 THEN OPEN "0",t2,IICOPY":RESUME 120
2010 ON ERROR GOTO 0
The error trappinq routine in line not exist" error in line 20.
statements that copy the file are created as if it were a new file.
2000 traps
If this a "File happens, does the skipped, and "COpy'· is
Creating and accessing random files requires more program steps than sequential files, but there are advantages to using random files.
One advantage is that random files require less room on the disk, because BASIC stores them in a packed binary format.
(A sequential file is stored as a series of ASCII characters.)
The biggest advantage to random files is that data can be accessed randomly, i.e., anywhere on the disk -- it is not necessary to read through all the information, as with sequential files.
This is possible because the information is stored and accessed in distinct units called records and each record is numbered.
The statements and functions that are used with random files are:
MKI$
MKS$
MKD$
CVI
CVS
CVD
B.3.2.1
Creating A Random File -
The following program steps-ari required to create a random file.
OPEN the file for random access ("R" mode).
This example specifies a record length of 32 bytes.If
the record length is omitted, the default is 128 bytes.
Use the FIELD statement to allocate space in the random buffer for the variables that will be written to the random file.
FIELD i1 20 AS N$,
4 AS A$, 8 AS P $
Use LSET to move the data into the random buffer.
Numeric values must be made into strings when placed in the buffer.
To do this, use the
"make" functions: MKI$ to make an integer value into a string, MKS~ for a single precision value, and MKD$ for a double precision value.
~SET N$=X$
LSET A$=MKS $ (AMT)
LSET P$=TEL$
Write the data from the buffer to the disk using the PUT statement.
Look at Program B-4.
It takes information that is input at the terminal and writes it to a random file.
Each time the
PUT statement is executed, a record is written to the file.
The two-digit code that is input in line 30 becomes the record number.
Do not. use a variable in st.at.ement..
point.er
point.
for int.o
FIELDed an INPUT st.ring
or LET
This causes the that. variable to st.ring
space inst.ead
of buffer.
the random file
10 OPEN "R"i1,"FILE"
20 FIELD .1,20 AS N$, 4 AS A$, 8 AS P$
30 INPUT "2-0IGIT COOE";COOE\
40 INPUT "NAME" ;X$
SO INPUT "AMOUNT";AMT
60 INPUT "PHONE";TEL$:PRINT
70 LSET N$=X$
80 LSET A$-MKS$(AMT)
90 LSET P$=TEL$
100 PUT t1,CODE\
110 GOTO 30
5.3.2.2
Access A Random File -
The following program st.eps are required t.o access a random file:
Use" the FIELD st.atement.t.o
allocat.e space in the random buffer for t.he variables that will be read from the file.
NOTE:
In a program that. performs both input. and out.put.on the same random file, you can oft.en use just one
OPEN st.atement and one FIELD st.at.ement.
FIELD #1 20 AS N$,
4 AS A$, 8 AS P$
Use the GET statement to move the desired record into the random buffer.
The data in the buffer may now be acessed by the program.
Numeric values must be converted back to numbers using the
"convert" functions: CVI for integers, CVS for single precision values, and CVD for double precision values.
N$
CVS(A$)
Program B-5 accesses the random file "FILE" that was created in Program B-4.
By inputting the three-digit code at the termina~, the information associated with that code is read from ~e file and displayed.
10 OPEN "R",t1,nFILE"
20 FIELD '1, 20 AS N$, 4 AS A$, 8 AS P$
30 INPUT "2-DIGIT CODE";CODE%
40 GET .1, CODE%
50 PRINT N$
60 PRINT USING "$$t#t.#t";CVS(A$)
70 PRINT P$:PRINT
80 GOTO 30
The LOC function, with random files, record number." The current record last record number that was used in a
For example, the statement returns the "current number is one plus the
GET or PUT statement.
ends program execution if the current record number in filet1 is higher than 50.
Program B-6 is an inventory program that illustrates random file access.
In this program, the record number is used as the part number, and it is assumed the inventory will· contain no more than 100 different part numbers.
Lines
900-960 initialize the data file by writing CHR$(255) as the first character of each record.
This is used later (line
270 and line 500) to determine whether an entry already exists for that part number.
Lines 130-220 display the different inventory functions that the program performs.
When you type in the desired function number, line 230 branches to the appropriate subroutine.
I
PROGRAM B-6 - INVENTORY
I
120 OPEN "R",#1,"rNVEN.DAT",39
125 FIELDt1,1 AS F$,30 AS 0$, 2 AS Q$,2 AS R$,4 AS P$
130 PRINT:PRINT "FUNCTIONS:":PRINT
135 PRINT 1, '!INITIALIZE FILE"
140 PRINT2,"CREATE A NEW ENTRY"
150 PRINT 3,"OISPLAY rNVENTORY FOR ONE PART"
160 PRINT 4,"ADO TO STOCK"
170 PRINT 5,"SUBTRACT FROM STOCK"
180 PRINT. 6,"OISPLAY ALL ITEMS BELOW REORDER LEVEL"
220 PRINT: PRINT: INPUT" FUNCTION" ;FUNCTION
225 IF (FUNCTION<1)OR(FUNCTION>6) THEN PRINT "BAD FUNCTION NUMBER":GOTO 131
230 ON FUNCTION GOSUB 900,250,390,480,560,680
240 GOTO 220
250 REM BUILD NEW ENTRY
260 GOSUB 840
270 IF ASC (F$)<>255 THEN INPUT"OVERWRITE" ;A$: IF A$<>"Y" THEN RETURN
280 LSET F$=CHR$(O)
290 INPUT "OESCRIPTION";DESC$
300 LSET O$=OESC$
310 INPUT "QUANTITY IN STOCK";Q%
320 LSET Q$-MKI$(Q%) .
330 INPUT "REORDER LEVEL";R%
340 LSET R$=MKI$(R%)
350 INPUT "UNIT PRICE";P
360 LSET P$-MKS$(P)
370 PUTt1,PART%
380 RETURN
390 REM DISPLAY ENTRY
400 GOSUB 840
410 IF ASC(F$)=255 THEN PRINT "NULL ENTRY":RETORN
420 PRINT USING "PART NUMBER .t#";PART%
4:30 PRINT 0$
440 PRINT USING
450 PRINT USING
460 PRINT USING
"QUANTITY
"REORDER LEVEL i##t#";CVI(R$)
"UNIT PRICE
ON HAND ttttt";CVI{Q$)
$$##.ii";CVS(P$)
470 RETURN
4-80 REM ADO TO STOCK
4:90 GOSOB840
500 IF ASC(F$)=255 T~ PRINT "NULL ENTRY":RETORN
5tO PRINT O$:INPUT "Q~ANTITY TO ADO ";A%
520 Q%-CVI(Q$)+A% \
530 LSET Q$=MKI$(Q%)
540 PUTt1,PART%
550 RETURN
560 REM REMOVE FROM STOC.'"{
570 GOSOB 840
580 IF ASC (F$)=255 THEN PRINT "NULL ENTRY": RETURN
590 PRINT 0$
600 INPUT "QUANTITY TO SUBTRACT";S%
610 Q%=CVI(Q$)
620 IF (Q%-5%)<0 THEN PRINT "ONLY";Q%i" IN 5TOCI<":GOTO 600
630 Q%=Q%-5%
640 IF Q%=<CVI{R$) THEN PRINT "QUANTITY NOW";Q%i" REORDER LEVEL";CVI{R$)
650 LSET Q$=MKI$(Q%)
660 PUTt 1 ,PART%
670 RETURN
680 REM DISPLAY ITEMS BELOW REORDER LEVEL
690 FOR I=1 TO 100
710 GET.1,I
720 IF CVI(Q$)<CVI(R$) THEN PRINT 0$;" QUANTITY";CVI(Q$) TAB(50)
If
REORDER LEVEL"; CVI (R$)
730 NEXT I
740 RETURN
840 INPUT "PART NUMBER";PART%
850 IF(PART%<1)OR(PART%>100)
ELSE GETt1,PART%:RETURN
THEN PRINT "BAD PART NUMBER":GOTO
890 END
900 REM INITLALIZE
910 INPUT "ARE YOU SURE";B$:IF B$<>"Y" THEN RETURN
920 LSET F$=CHR$(255)
930 FOR I=1 TO 100
940 POT.1,I
950 NEXT I
960 RETORN
840
All versions of BASIc-ao have prov~s~ons for interfacing with assembly language subroutines.
The USR Function allows assembly language subroutines to be called in the same way
BASIC's intrinsic functions are called.
The addresses of the DEINT,
GIVABF, MAKIN'l' and FRCINT routines are stored in locations that must be supplied individually for different implementations of BASIC.
Memory space must be set aside for an assembly language subroutine- before it can be loaded.
During initialization, enter the highest memory location minus the amount of memory needed for the assembly language subroutine(s).
BASIC uses all memory available from its starting location up, so only the topmost locations in memory can be set aside for user subroutines.
When an assembly language subroutine is called, the stack pointer is set up for 8 levels (16 bytes) of stack storage.
If more stack space is needed, BASIC's stack can be saved and a new stack set up for use by the assembly language subroutine. BASIC's stack must be restored, however, before returning from the subroutine.
The assembly language subroutine may be loaded into memory by means of the system monitor, or the BASIC POKE statement, or (if the user has the MACRO-SO or FORTRAN-SO package) routines may be assembled with MACRO-SO and loaded using
LINK-SO.
C.2
USR FUNCTION CALLS -
!!
BASIC
The starting address of the assembly language.
subroutine must be stored in USRLOC, a two-byte location in memory that is supplied individually with different implementations of
BASIC-80.
With 8K BASIC, the starting address may be POKEd intoUSRLOC.
Store the low order byte first, followed by the high order byte.
The function USR will call the routine whose address is in
USRLOC.
Initially USRLOC contains the address of ILLFUN, the routine that gives the "Illegal function call" error.
Therefore, if USR is called without changing the address in
USRLOC, an MIllegal function call" error results.
where the argument is a numeric expression.
To obtain the argument, the assembly language subroutine must call the routine DEINT.
DEINT places the argument into the D,E register pair as a 2-byte, 2's complement integer.
(If the argument is not in the range -32768 to 32767, an "Illegal function call" error occurs.)
To pass the result back from an assembly language subroutine, load the value in register pair [A,B], and call the routine GrvABF.
If GrvABF is not called, USR(X) returns
X.
To return to BASIC, the assembly language subroutine must execute a RET instruction.
For example, here is an assembly language subroutine that multiplies the argument by 2:
USRSUB: CALL
XCHG
DAD H
DEINT
MOV A,R
MOV B,L
JMP GrvABF
:put arg in D,E
;move arg to H,L
;H,L=H,L+H,L imove result to A,B
Note that valid results will be obtained from this routine for arguments in the range -16384<=x<=16383.
The single instruction JMP GrvABF has the same effect as:
CALL GIVABF
RET
To return additional values to the program, load them into memory and read them with the PEEK function.
There are several methods by which a program may call more than one USR routine.
For example, the starting address of each routine may be POKEd into USRLOC prior to each USR call, or the argument to USR could be an index into a table of USR routines.
In the Extended and Disk versions, the format of the USR function is where <digit> is from 0 to 9 and the argument is any numeric or string expression.
<digit> specifies which USR routine is being called, and corresponds with the digit supplied in the DEl' USR statement for that routine.
If <digit> is omitted, USRO is assumed.
The address given in the DEF USR statement determines the starting address of the subroutine.
When the USR function call is made, register A contains a value that specifies the type of argument that was given.
The value in A may be one of the following:
Value in A
!m!.
g!
Argument
2 Two-byte integer (two's complement)
3 String
4 Single precision floating point number
Double precision floating point number
8
If the argument i~ a number, the [H,L] register pair points to the Floating Point Accumulator (FAC) where the argument is stored.
FAC-3 contains the lower 8 bits of the argument and
FAC-2 contains the upper 8 bits of the argument.
FAC-2 contains the middle 8 bits of mantissa and
FAC-1 contains the highest 7 bits of mantissa with leading 1 suppressed (implied).
Bit 7 is the sign of the number (O=positive, 1-negative).
FAC point is the exponent minus 128, and the binary is to the left of the most significant bit of the mantissa.
If ~e argument is a double precision floating point number:
FAC-7 through FAC-4 contain four more bytes of mantissa (FAC-7 contains the lowest 8 bits).
If the to 3 string
255).
8 bits argument is a string, the [D,El register pair points bytes called the "string descriptor." Byte 0 of the descriptor contains the length of the string (0 to
Bytes 1 and 2, respectively, are the lower and upper of the string starting address in string space.
CAUTION: If the argument is a string literal in the program, the string descriptor will point to program text.
Be careful not to alter or destroy your program this way.
To avoid unpredictable results, add +"
II to the string literal in the program.
Example:
This will copy the string literal into string space and will prevent alteration of program text during a subroutine call.
Usually, the value returned by a USR function is the same type (integer, string, single precision or double precision) as the argument that was passed to it.
However, calling the
MAKINT routine returns the integer in [H,LJ as the value of the function, forcing the value returned by the function to be integer.
To execute MAKINT, use the following sequence to return from the subroutine:
POSH
LBLD
X'l'HL
LXI
PUSH
LHLD
PCHL
SUB1 :
• •
H xxx
.
H xxx
•
.
1save value to be returned
1get address of MAKINT routine
;save return on stack and
;get back [H,Ll
1return
Also, the argument of the function, regardless of its type, may be forced to an integer by callinq ~~e FRCINT routine to get the integer value of the argument in [H,LJ.
Execute the following routine:
H ;get address of subroutine
;continuation
;place on stack
;get address of FRCINT
\~.
Extended and Disk BASIC-80 user made' with the CALL statement.
the same as that in Microsoft's compilers.
function calls may also be
The calling sequence used is
FORTRAN, COBOL and BASIC
A CALL statement with no arguments generates a simple "CALL" instruction.
The corresponding subroutine should return via a simple "RET." (CALL and RET are 8080 opcodes - see an 8080 reference manual for details.)
A subroutine CALL with arguments results in a somewhat more complex calling sequence.
For. each argument in the CALL argument list, a parameter is passed to the subroutine.
That parameter is the address of the low byte of the argument.
Therefore, parameters always occupy two bytes each,regardless of type.
The method of passing the parameters depends upon the number of parameters to pass:
1.
If the number of parameters is less than or equal to 3, they are passed in the registers.
Parameter
1 will be in aL, 2 in DE (if present), and 3 in BC
(if present).
2.
If the number of parameters is greater than 3, they are passed as follows:
3.
Parameters 3 through n in a contiguous data block.
BC will point to the low byte of this data block (i.e., to the low byte of parameter
3) •
Note that, with this scheme, the subroutine must know how many parameters to expect in order to find them.
Conversely, the calling program is responsible for passing the correct number of parameters.
There are no checks for correct number or type of parameters.
If the subroutine expects more than 3 parameters, and needs to transfer them to a local data area, there is a system subroutine which will perform this transfer.
This argument transfer routine is named $AT (located in the FORT~~ library, FORLIB.REL), and is called with HL pointing to the local data area, BC pointing to the third parameter, and A containing the number of arguments to transfer (i.e., the total number of arguments minus 2).
The subroutine is
responsible for saving the first two parameters before calling $AT.
For example, if a subroutine expects 5 parameters, it should look like:
P1 ;SAVE PARAMETER 1 SHLD
XCHG
SHLD
MVI
LXI
CALL
P2
A,3
H,P3
$AT
;SAVE PARAMETER
;POINTER
;TRANSFER
TO LOCAL
2
;NO. OF PARAMETERS
THE OTHER
LEFT
AREA
3 PARAMETERS
P1:
P2:
P3:
•
[Body of subroutine]
•
RET
OS
OS
OS
;RETURN
;SPACE
TO CALLER
;SPACE FOR PARAMETER
FOR PARAMETER
;SPACE FOR PARAMETERS
1
2
3-5
01300
01400
01500
01600
01700
01800
01900
02000
02100
02200
02300
00100
00200
00300
00400
00500
00600
00700
00800
00900
01000
01100
01200
.
,
i[B,C]
; (H,L]
; [A]
$AT:
AT1 :
ARGUMENT TRANSFER
POINTS TO 3RO PARAM.
POINTS TO LOCAL STORAGE FOR PA.~ 3
CONTAINS THE i OF PARAMS TO XFER (TOTAL-2)
ENTRY
XCHG
MOV
MOV
MOV
L,'nC
MOV
INX
XCHG
MOV
INX
MOV
INX
XCHG
OCR
JNZ
RET
M,C
B
M,B
B
A
AT1
$AT
H,B
L,C
C,M
H
B,M
H i[B,C]
=
PARAM ADR i[H,L] POINTS TO LOCAL STORAGE iSTORE PARAM IN LOCAL AREA iSINCE GOING BACK TO AT1
;TRANSFERRED ALL PA.~S?
iNO, COpy MORE
;YES, RETURN
When accessing parameters in a subroutine, don't forget that they are pointers to the actual arguments passed.
It is entirely up to the programmer to see to it that the arguments in the calling program match innumber,~, and lenath with the parameters expecte by the subroutine.
This applies to BASIC subroutines, as well as those written in assembly language.
Assembly language subroutines can be written to handle interrupts. All interrupt handling routines should save the stack, register A-L and the PSW.
Interrupts should always be re-enabled before returning from the subroutine, since an interrupt automatically disables all further interr~pts once it is received.
The user should be aware of which interrupt vectors are free in the particular version of
BASIC that"has been supplied.
Note to CP/M users: in CP/M
BASIC, all interrupt vectors are free.)
The CP/M version of BASIC-80 (11BASIC) is
5 1/4 inch Vector Graphic compatible diskette.
file is MBASIC.COM.
recommended.)
(A 28K or larger supplied on a
The name of the
CP/M system is
To run MBASIC, bring up CP/M and type the following:
A>MBASIC <carriage return>
The system will reply: xxxx Bytes Free
BASIC-SO Version 5.0
(CP/M Version)
Copyright 1978 (C) by Microsoft
Created: dd-mmm-yy
Ok
MBASIC is the same as Disk BASIC-80 as described in this manual, with the following exceptions:
The initialization dialog has been replaced by a set of options which are placed after the MEASIC command to CP/M.
The format of the command line is:
If <filename> is present, MBASIC proceeds as if a RUN
<filename> command were typed after initialization is complete.
A default extension of .BAS is used ~~ none is supplied and the filename is less than 9 characters long.
This allows BASIC programs to be executed in batch mode using the SUBMIT facility of CP/M.
Such programs should include a SYSTEM statement (see below) to return to CP/M when they have finished, allowing the next program in the batch stream to execute.
If /F:<number of files> is present, it sets the number of disk data files that may be open at anyone time during the execution of a BASIC program.
Each file data block allocated in this fashion requires 166 bytes of memory.
If the /F option is omitted, the number of files defaults to 3.
The /M:<highest memory location> option sets' the highest memory location that will be used by MEASIC.
In some cases it is desirable to set the amount of memory well below the
CP/M's FDOS to reserve space ?or
assembly language subroutines.
In all cases, <highest memory location> should be below the start of FDOS (whose address is-contained in locations 6 and 7).
If the /M option is omitted, all memory up to the start of FDOS is used.
\
Both <number of files> and
<highest memory location> are numbers that may be either decimal, octal (preceded by
&0) or hexadecimal (preceded by &H).
Use all memory and 3 files, load and execute PAYROLL.BAS.
Use all memory and 6 files, load and execute INVENT.BAS.
Use first 32K of memory and
3 files.
A>MBASIC DATACK/F:2/M:&B9000
Use first 36K of memory, 2 files, and execute DATACK.BAS.
D.2
B..!.2!
FILES
Disk.filenames follow the normal CP/M nam~ng conventions.
All filenames may include A: or B: as the first two characters to specify a disk drive, otherwise the currently selected drive is assumed.
A default extension of .BAS is used on LOAD, SAVE, MERGE and RUN <filename> commands if no
"." appears in the filename and the filename is less than 9 characters long.
To print the names of files residing on the current disk.
If <filename> is omitted, al~ the files on the currently selected drive will be listed.
<filename> is a string formula which may contain question marks (?) to match any character in the filename or extension.
An asterisk (*) as the first character of the filename or extension will match any file or any extension.
FILES
FILES "*.BAS"
FILES "B:*.*"
FILES "TEST? BAS"
To close all disk files and write the directory information to a diskette before it is removed from.a disk drive.
~ways execute a RESET command before removing a diskette from a disk drive.
Otherwise, when the diskette is used again, it will not have the current directory information written on the directory track.
RESET closes all open files on all drives and writes the directory track. to every diskette with open files.
Returns the number of records present in the last extent read or written.
If the file does not exceed.one extent (128 records), then LOF returns the true length of the file.
0.6
!2E.
With CP/M, the EOF function may be used with random files.
If a GE'!'
This may be used to find the size of a file using a binary search or other algorithm.
1.
CSAVE and CLOAn are not implemented.
2.
To return to CP/M, use the SYSTEM command or statement.
SYSTEM closes all files and then performs a CP/M warm start.
Control-C always returns to MBASIC, not to CP/M.
3.
FRCIN'!' MAKIN'!' is at 105 hex.
If you have programs written in a BASIC other than BASIC-SO, some minor adjustments may be necessary before running them with BASIC-SO •
.
are some specific things to look for when converting BASIC programs.
Delete all statements that are used to declare the length of strings.
A statement such as DIM A$(I,J), which dimensions a string array for J elements of length I, should be converted to the BASIC-SO statement
DIM A$ (J) •
Some BASICs use a comma or ampersand for string concatenation.
Each of these must be changed to a plus sign, which is the operator for
BASIC-SO string concatenation.
In BASIC-SO, the MID$, RIGHT$, and LEFT$ functions substrings of strings.
Forms such as A$(I) character in A$, or A$(I,J) to take a substring of to position J, must be changed as follows: are used to take to access the Ith
A$ from position I
X$=A$ (I)
X$=A$(I,J)
BASIC-SO
X$=MID$(A$,I,1)
X$=MID$(A$,I,J-I+1)
If the substring reference is on the left side of an assignment and X$ is used to replace characters in A$, convert as follows:
8K BASIC-SO
A$(I)=X$
A$(I,J)=X$
A$=LEFT$ (A$,I-1)+X$+McrO$ (A$,I+1)
A$=LEFT$(A$,I-1)iX$iMIO$(A$,J+1)
A$(I)=X$
A$(I,J)=X$
MIO$(A$,1,1)=X$
MID$(A$,I,J-I+1)=X$
to set Band C equal to zero.
BASIC-SO would interpret the second equal sign as a logical operator and set B equal to -1 if C equaled O.
Instead; convert this statement to two assignment statements:
Some BASICs use a backslash
('1
to separate multiple statements on a line.
With BASIC-SO, be sure all statements on a line are separated by a colon (:).
I.4
~ FUNCTIONS
Programs using the MAT functions available in some BASICs must b rewritten using FOR ••• NEXT loops to execute properly.
~
NF
00
FC
NEXT without FOR
A variable in a NEXT correspond to any unmatched FOR statement statement previously variable •.
does not executed,
Syntax error
A line is encountered that contains some incorrect sequence of characters (such as unmatched parenthesis, misspelled command or statement, incorrect punctuation, etc.).
4 .
Out of data
A READ statement is executed when there are no DATA statements with unread data remaining in the program.
5
Return without GOSUB
.A RETURN statement is encountered for which there is no previous, unmatched GOSUB statement.
Illegal function call
A parameter that is out of range is passed to a math or string function.
An FC error may also occur as the result of:
1.
a negative subscript
2.
a negative or zero argument with LOG
4.
a negative mantissa with a non-integer exponent
5.
a call to a USR function for which the starting address has not yet been given
6.
an improper argument to MID$, LEFT$,
RIGHT$, INP, OUT, WAIT, PEEK, POKE, TAB,
SPC, STRING$, SPACE$,
ON •••GOTO.
INSTR, or
Overflow
The result of a calculation is too large to be represented in BASIC-80's number format.
If underflow occurs, the result is zero and execution continues without an error.
Out of memory
A program is too large, has too many FOR loops or GOSUBs, too many variables, or expressions that are too complicated.
Undefined line
A line reference in a GOTO,
IF •••THEN •••ELSE or DELETE is nonexistent line.
GOSUB, to a
Subscript out of
An array element subscript that the array, or subscripts.
range is referenced either with is outside the dimensions with the wrong number a of of
Red~ensioned array
Two DIM statements are given for the same array, or a DIM statement is given for an array after the default dimension of 10 has been established for that array.
Division by zero
A division by zero is encountered in an expression, or the operation of involution results in zero being raised to a negative power.
Machine infinity with the sign of the numerator is supplied as the result of the division, or positive machine infinity is supplied as the result of the involution, and execution continues.
Illegal direct
A statement that is illegal in direct mode is entered as a direct mode command.
Type mismatch
A string variable name is assigned a numeric value or vice versa; a function that expects a numeric argument is given a string argument or vice versa.
Out of string space
String variables cause BASIC to exceed the amount of free memory remaining.
BASIC will allocate string space dynamically, until it runs out of memory.
String too long
An attempt is made to create a string more than 255 characters long.
String formula too complex
A string expression is too long or too complex.
The expression should be broken into smaller expressions.
Can't continue
An attempt is made to continue a program that:
1.
has halted due to an error,
2.
has been modified during a break in execution, or
19
20
22
23
Ondefined user function
A OSR function is called before the function definition (OEF statement> is given.
Extended ~ ~ Versions Only
No RESUME
An error trapping routine is entered but contains no RESUME statement.
RESUME without error
A RESUME statement is encountered before an error trapping routine is entered.
Unprintable error
An error message is error condition usually caused by error code.
not which available exists.
an ERROR wi th an for the
This is undefined
Missing operand
An expression contains an operator with no operand following it.
Line buffer overflow
.lU1
attempt is made to' input a line that has too many characters.
26
29
30
FOR without NEXT
A FOR was encountered without a matching
NEXT.
WHILE without ~lD
A WHILE statement does not have a matching
WEND.
WEND without WHILE
A WEND was encountered without a matching
WHILE.
50
52
53
57
58
Field overflow
A FIELD statement is attempting to allocate more bytes than were specified for the record length of a random file.
Internal error
An internal malfunction
BASIC-SO.
Report under which the message has occurred in Disk the conditions appeared.
Bad file number
A statement or comm~~d references a file with a file number that is not OPEN or is out of the range of file numbers specified at initialization.
File not found
A LOAD, KILL or OPEN statement references a file that does not exist on the current disk.
Bad file mode
An attempt is made to use PUT, GET, or LOF with a sequential file, to LOAD a random file or to execute an OPEN with a file mode other than I, 0, or R.
File already open
A sequential output mode file that is already given for a file that is
OPEN is issued for a open; or a KILL is open.
Disk I/O error
An I/O error occurred on a disk I/O operation.
rt is a fatal error, i.e., the operating system cannot recover from the error.
File already exists
The filename specified in a NAME statement is identical to a filename already in use on ~~e disk.
61
62
63
64
66
Disk full
All disk storage space is in use.
Input past end
An INPUT statement is exeucted after all the data in the file has been INPUT, or for a null (empty) file.
To avoid this error, use the EOF function to detect the end of file.
Bad record number
In a PUT or GET statement, the record number is either greater than the maximum allowed
(32767) or equal to zero.
Bad file name
An illegal form is used for the filename with
LOAD, SAVE, KILL, or OPEN (e.g., a filename with too many characters).
Direct statement in file
A direct statement is encountered while
LOADing an ASCII-format file.
The LOAD is terminated.
Too many ,files
·An attempt is made to create a new file
(using SAVE or OPEN) when all 255 directory entries are full.
Functions that are not intrinsic to BASIC-80 may be calculated as follows:
BASIC-80 Equivalent
SECANT
COSECANT
COTANGENT
INVERSE SINE
INVERSE COSINE
INVERSE SECANT
INVERSE COSECANT
INVERSE COTANGENT
HYPERBOLIC SINE
HYPERBOLIC COSINE
HYPERBOLIC TANGENT
HYPERBOLIC SECANT
HYPERBOLIC COSECANT
HYPERBOLIC COTANGENT
INVERSE HYPERBOLIC
SINE
INVERSE HYPERBOLIC
COSINE
INVERSE HYPERBOLIC
TANGENT
INVERSE HYPERBOLIC
SECANT
INVERSE HYPERBOLIC
COSECANT
INVERSE HYPERBOLIC
COTANGENT
SEC(X)-1/COS(X)
CSC(X)=1/SIN(X)
COT (X)=1/TAN(X)
ARCSIN(X)=ATN(X/SQR(-X*X+1»
ARCCOS(X)=-ATN (X/SQR(-X*X+1»+1.5708
ARCSEC(X)=ATN(X/SQR(X*X-1»
+SGN(SGN(X)-1)*1.5708
ARCCSC(X)=ATN(X/SQR(X*X-1»
+(SGN(X)-1)*1.5708
ARCCOT(X)=ATN(X)+1.5708
SINH (X)= (EXP (X)-EXP(-X»/2
COSH(X)=(EXP(X)+EXP(-X»/2
TANH(X)=EXP(-X)/EXP(X)+EXP(-X»*2+1
SECH(X)=2/(EXP(X)+EXP(-X»
CSCH(X)=2/(EXP(X)-EXP(-X»
COTH(X)=EXP(-X)/(EXP(X)-EXP(-X»*2+1
ARCSINH(X)=LOG(X+SQR(X*X+1»
ARCCOSH(X)=LOG(X+SQR(X*X-1)
ARCTANH(X)=LOG«1+X)/(1-X»/2
ARCSECH(X)=LOG«SQR(-X*X+1)+1)/X)
ARCCSCH(X)=LOG«SGN(X)*SQR(X*X+1)+1)/X
ARCCOTH(X)=LOG«X+1)/(X-1»/2
The Microsoft BASIC Compiler package contains the following software: BASIC Compiler, MACRO-SO assembler, and LINK-BO loader.
The following manuals are also supplied: BASIC-BO
Reference Manual, BASIC Compiler User's Manual, Utility
Software Manual.
The crtility Software Manual is the reference manual for MACRO-SO and LI!~-SO.
The BASIC
Compiler crser's Manual describes the use of the compiler, its command format, compilation switches and error messages.
The BASIC language that is used with the Microsoft BASIC
Compiler is the same as decribed in this manual for Disk
BASIC-SO with the following exceptions:
The Compiler interacts with the console only to read compiler commands.
These specify what files are to be compiled.
There is no "direct mode," as with the BASIC-SO interpreter.
Commands that are usually issued in the direct mode with the BASIC-SO interpreter are not implemented on the Compiler.
The following statements and commands are not implemented and will generate an error message:
AO'l'O
EDIT
LOAD
FILES
CLEAR
LIST
!v!ERGE
CLOAD
LLIST
NEW
CSAVE
RENOM
CHAIN
CONT
RUN
COMMON
DELETE
SAVE
RESET
Because there is no direct mode for typing in programs or edit mode for editing programs, use Microsoft's EDIT-SO Text
Editor or BASIC-SO interpreter for creating and editing programs.
If you use the interpreter, be sure to SAVE the file with the A (ASCII format) option.
The compiler cannot accept a physical line that is more than
127 characters in length.
A logical statement, however, may contain as may physical lines as desired.
Use line feed to
start a new physical line within a logical statement.
To reduce the size of the compiled program, there are no program line numbers included in the object cod
7 generat
7 d by the compiler unless the /D, IX, or /E switch ~s set ~n the compiler command.
Error messages, therefore, contain the address where the error occurred, instead of a line number.
The compiler listing and the map generated by
LINK-SO are used to identify the line that has the error.
It is always a good idea to debug programs using the
BASIC-SO interpreter before attempting to compile them.
See the BASIC Compiler Oser's Manual for more information.
Most programs that run on the Microsoft BASIC-SO interpreter will run on the BASIC Compiler with little or no change.
However, it is necessary to note differences in the use of the following program statements:
CALL
The <variable name> field must contain an External recognized by LINK-SO as routine must be supplied language subroutine or symbol, i.e., one that is a in the CALL statement global symbol.
This by the user as an assembly a routine from the
FORTRAN-SO library.
2.
CHAIN and COMMON
The CHAIN and COMMON statements are not implemented on the compiler.
They will generate a fatal error.
The CHAIN and COMMON statements will be implemented in a future release of the BASIC compiler.
However, their implementation will be different from the BASIC-SO interpreter's version.
The
COMMON statement will be similar to FORTRAN'S
COMMON statement.
3.
DEFINT/SNG/DBL/STR
The compiler does not "execute" DEFxxx statements; it reacts to the static occurrence of these statements, regardless of the order in which program lines are executed.
A DEFxxx statement takes effect as soon as its line is encountered.
Once the type has been defined for a given variable, it remains in effect until the end of the program or until a different DEF~~ statement wi~~ that variable takes effect.
4.
OSRn Functions
OSRn functions are significantly different from the interpreter versions.
The argument to the OSRn
function is ignored and an integer result is returned in the HL registers.
It is recommended that USRn functions be replaced by the CALL statement.
s.
DIM and ERASE
The DIM statement is similar to the DEFxxx statement in that it is scanned rather than executed.
That is, DIM takes effect when its line is encountered.
If the default dimension (10) has already been established for an array variable and that variable is later encountered in a DL~ statement, a "Redimensioned array" error results.
There is no ERASE statement in the compiler, so arrays cannot be erased and redimensioned.
An
ERASE statement will produce a fatal error.
Also note that the values of the subscripts in a
D~ statement must be integer constants; they may not be variables, arithmetic expessions, or floating point values.
For example,
DIMA1(I)
DIM A1 (3+4)
6.
END
During execution of a compiled program, an END statement closes files and returns control to the operating system.
The compiler assumes an END statement at the end of the program, so "running off the end" produces proper program termination.
7.
ON ERROR GOTO/RESUME <line number>
If a program contains ON ERROR GOTO and RESUME
<line number> statements, the /E compilation switch must be used.
If the RESUME NEXT, RESUME, or
RESUME 0 form is used, the /X switch must also be included.
See the BASIC Compiler User's Manual for an explanation of these switches.
8.
REM
REM statements or remarks starting with a single quotation mark do not take up time'or space during execution, and so may be used as freely as desired.
STOP
The STOP statement.
returns to statement is identical to the END
Open files are closed and control the operating system.
TRON/TROFF
In order to switch must ignored and use TRON/TROFF, the /0 compilation be used.
Otherwise, TRON and TROFF are a warning message is generated.
11.
FOR/NEXT and WHILE/WEND
FOR/NEXT and WHILE/WEND loops must be statically nested.
12.
Double Precision Transcendental Functions
SIN, COS, TAN, SQR, LOG, and EXP return doubIe precision results if given a double precision argument.
Exponentiation with double precision operands will return a double precision result.
turing expression evaluation, the operands of each operator are converted to the same type, that of the most precise operand.
For example, causes J% to be converted to single precision and added to
Al.
This result is converted to double precision and added to Qt.
The Compiler is more limited than the interpreter in handling numeric overflow.
For example, when run on the interpreter the following program
I%-20000
J%-20000
K%--30000
M%-I%+J%-K% yields 10000 for M%.
That is, it adds I% to J% and, because the number is too large, it converts the result into a floating point number.
K% is then coverted to floating point and subtracted.
The result of 10000 is found, and is converted back to integer and saved as M%.
The compiler, however, must make type conversion decisions during compilation.
It cannot defer until the actual values are k.'"1own.Thus, the compiler would generate code to perform the entire operation in integer mode.
If ~~e /0 switch were set, the error would be detected.
Otherwise, an incorrect answer would be produced.
In order to produce optimum efficiency in ~~e compiled program, the compiler may perform any number of valid algebraic transformations before generating the code.
For
I%=20000
J%=-18000
K%=20000
M%aI%+J%+K% could produce an incorrect result when run.
If the compiler actu~lly performs the arithmetic in the order shown, no overflow occurs.
However, if the compiler performs I%+K% first and then adds J%, an overflow will occur.
The compiler follows the rules for operator precedence and parenthetic modification of such precedence, but no other guarantee of evaluation order can be made.
In order to produce the fastest and most compact object code possible, make maximum use of integer variables.
For example, this program
FOR I=1 TO 10
A(I)~O
NEXT I can execute approximately 30 times faster by simply substituting RI%" for "I".
It is especially advantageous to use integer variables to compute array subscripts.
The generated code is significantly faster and more compact.
(
(
--;,1
APPENDIX M
ASCII Character Codes
ASCII
Code Character
ASCII
Code
ASCII
Code Character
000
001
002.
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
026
027
028
029
030
031
032
033
034
035
018
019
020
021
022
023
024
025
036
037
038
039
040
041
042
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
059
060
061
062
063
064
065
066
067
068
069
070
051
052
053
054
055
056
057
058
043
044
045
046
047
048
049
050
••
)
(
#
$
%
& ,
HT
U
VT
F!'
CR
SO
SI
DLE
DC1
NUL
SOB
STX
ETX
EOT
ENQ
ACK
BEL
BS
DC2
DC3
DC4
NAK
SYN
ETB
CAN
EM
SUB
ESCAPE
FS
GS
RS
OS
SPACE
!
II
Character
+-
,
6
7
8
2
3
4
5
@
?
·
·
<
9
·
,
==
>
/
·
0
1
G
H
I
J
K
L
M
N
0
P
Q
R
S
T
0
D
E
F
A a
C
086
087
088
089
090
091
092
093
094
095
104
105
106
107
108
109
110
111
112
113
096
097
098
099
100
101
102
103
114
115
116
117
118
119
120
121
122
123
124
125
126
127
A$CII codes are in decimal
U==Line Feed, FF=For.m Feed, CR=Carriage Return, DEL=Rubout h i j k
1 m n a b c d e f g
0
P q r s t u v w x
{ z
,
Y
}
DEL
\
]
Z
[
A
, <
V
W
X y
ABS
Addition • • • • • • • • • •
ALL
Arctangent • • • • • • • • •
Array variables
Arrays ••••••••••
ASC
ASCII codes ••••••••
ASCII format • •• • ••
Assembly language subroutines
3-2
1-10
2-4, 2-9
3-3
1-7, 2-9, 2-18, L-4
1-7,2-7, 2-11~ 2-24
3-2
3-2, 3••
2-4, 2-49, 2-77,
2-3, 2-16, 2-59,
L-1
3-21,
3-23, C-1, L-2 .
3-3, L-3
CALL •••
Carriage return
Cassette tape
CDBL • • • • • • •
CHAIN •
Character set
CHR$
CINT •
CLEAR cr..OAD
CLOAD* • • • • • •
. cr..OA.O?
• • • • • •
CLOSE
Command level
COMMON ••
Concatenation
Constants
CON'r
Control characters
Control-A •
COS
CP/M •
CSAv.E
CSAVE* •.•
CSNG ••
0
CVD
CVI
CVS
• 2-3, C-5, L-2
• 1-3, 2-36, 2-41 to 2-42,
2-83 to 2-85
• 2-7, 2-11
• 3-3
• 2-4, 2-9, L-2
• 1-3
• 3-4
• 3-4
• 2-6, A-1
• 2-7
• 2-7
• 2-7
• 2-8, a-3, a-8
• 1-1
• 2-4, 2-9, L-2
• 1-14
• 1-4
• 2-10, 2-41
• 1-4
• 2-22
• 3-5, L-3
2-46, 2-49, 2-76 to 2-77, a-1, 0-1
2-11
2-11
• 3-5
3-6, a-8
3-6, B-8
• 3-6, B-8
DEF FN •
DEF OSR
DEFDBL •••
DEFINT •••
DEFSNG • • • • • •
DEFSTR • • • • • •
DEINT
DELETE • • • • • •
DIM
Direct mode • • •
Division • • • • •
Double precision •
EDIT ••
Edit mode
END
EOF
EM.SE
ERL
ERR
ERROR
Error
Error
Error codes messages t~apping
••
•
•
Escape • • • .--.
EXP
Exponentiation •
Expressions ••
FIELD
FILES
FIX
FOR ••• NEXT
FRCINT _
FRE
Functions
GOSUB
GOTO •
HEX $
Hexadecimal
IF ••• GOT0
IF ••• THEN
IF •••THEN •••ELSE •
Indirect mode ••
INP
INt'OT
• • •
INPUT $
INPUTi
INSTR
INT
Integer • •• •
Integer division •
LEFT $
LEN
LET
LINE INPUT •
LINE INPUT#
Line numbers
Line printer •
Lines
LIST • • • • • •
LLIST
LOAD ••••••
LaC
LOF
LOG
L~gical operators
Loops.
• •
LPOS •
LPRINT • • • • •
LPRINT USING • •
LSET • • • • • •
MAKINT •
MBASIC •
MERGE
MID$ • • • •
Ml(D$
Ml(I$ •
Ml(S$ •
MOD operator • • • •
Modulus arithmetic •
NAME •
Negation •
NEW
NULL •••
Numeric constants
Numeric variables
CCT$ • • • •
OetaJ.
•• •
ON E~Oil GOTO
ON ••• GOSUB •
ON ••• GO'I'O
OPEN ••••
Operators
OP'I'ION BASE
OO'r
Overflow •
Overla.y
•
Paper tape • •
PUX •••••
poa •• - • • •
POS
PlUN'r
PlUNT USING
PRIN'Xt .- • • •
PRIN'J!t USING •
1-4
1-7
3-14
1-5, 3-14
2-54, L-3
2-55
2-55
2-8, 2-28, a-8
1-9, 1-11
2-57
2-58
1-11, 3-7,
2-4
2-53
2-59,
2--59,
2.-83,
2-60,
2-62.,
3-15
3-15
3-15
A-1
A-2
2-66,
2-66,
A-3,
A-3,
P.ENOM
RESET imSTOilE
RESma: •
RtrOml •
RIGa'l'$ •
P.N'O
RSET ••
Rubout •
RUN
TAB
Tab
TAN
TROFF
TP.ON
• osa
OSRLOC •
VAL
Variables ~~.
WAIT •
WEND •
WI".:
WIDTH
WIDTH w:U'l'!:
SQi
Snl
Sinqle
SPACZ$
SPC
SQR
•
?racisicn
•
STOP •
S'n$ •
Strinq
St:'i."lq constants functions
St:'inq o;:erato:s
Strinq space •
Strinq va:i~les
S'l'It.L."1G$ •• •
Subroutines ••
Subsc=i:t3 • • •
Subuac:iion • •
SWAP • • • • • •
SY STE.'!
• • • • •
3-1i
3-1 i, t-3 i-3, 2-i5,
3-18
3-18
3-19, t-3
• 2-10, 2-23, 2-32, 2-i8, L-3
• 3-19
• 1-4
• 3-6, 3-10 to 3-11, 3-13,
3-16, 3-19, 3-22, I-1
• 1-14
• 2-6, 3-8, A-1, 3-9
• 1-i, 2-15, 2-4i to 2-42
• 3-20
• 2-3, 2-32, 2-35, C-1
• 1-1, 2-18, 2-51, t-3
1-10
• 2-19
• 0-4
Stiahnuť
Reklama