Реклама
Реклама
Prime Computer
User Guide
For
BASIC
Interpretive Language
PRIME COMPUTER. INC.. 145 PENNSYLVANIA AVENUE. FRAMINGHAM. MA. 01701
MAN 1813
BASIC
INTERPRETIVE LANGUAGE
USER GUIDE
Revision A
May 1975
PRIME
COMPUTER, ING.
[145 Pennsylvania Ave., Framingham, Mass., 01701]
First Printing May 1974 MAN 1813
Revision A May 1975
Copyright 1975 by
Prime Computer, Incorporated
145 Pennsylvania Avenue
Framingham, Massachusetts 01701
Performance characteristics are
subject to change without notice.
11
CONTENTS
Page
SECTION 1 STRUCTURE OF A BASIC PROGRAM 1-1
STATEMENTS 1-1
STATEMENT FORMAT 1-1
STATEMENT EXECUTION 1-1
ENTERING BASIC 1-1
MODES OF OPERATION 1-1
CONVERSATIONAL MODE 1-2
ENTERING PROGRAM STATEMENTS
STORAGE OF STATEMENTS
REPLACING A STATEMENT
DELETING A STATEMENT
SUMMARY OF BASIC PROGRAM EDITING PROCEDURES
HE
PB RE HS UN
EXECUTING A PROGRAM 1-5
BATCH MODE 1-5
EXAMPLES OF FILE COMMAND 1-5
LOADING AND RUNNING PROGRAMS 1-6
EXAMPLES OF LOAD COMMAND 1-6
IMMEDIATE MODE 1-7
COMMANDS 1-8
LOAD COMMAND 1-8
FILE COMMAND 1-8
LIST COMMAND 1-9
RUN COMMAND 1-9
NEW COMMAND 1-10
CLEAR COMMAND 1-10
CONTINUE COMMAND 1-10
RESTARTING BASIC 1-11
RESTARTING FROM DOS/VM 1-11
RESTARTING FROM DOS 1-11
ERROR MESSAGES 1-12
111
CONTENTS
SECTION 2 TYPES OF DATA
NUMERIC VALUES
RANGE OF NUMERIC VALUES
STRING VALUES
SCALAR VARIABLES
NUMERIC SCALAR VARIABLES
STRING SCALAR VARIABLES
ARRAY VARIABLES
ARRAY DECLARATION
ARRAY BOUNDS, DEFAULT BOUNDS, AND STORAGE ALLOCATION
ARRAY ELEMENT REFERENCES
RELATIONSHIP OF NAMES
SECTION 3 EXPRESSIONS AND FUNCTIONS
EXPRESSIONS
NUMERIC EXPRESSIONS
ORDER OF EXPRESSION EVALUATION
USE OF PARENTHESES
STRING EXPRESSIONS
RELATIONAL EXPRESSIONS
EXAMPLES OF RELATIONAL EXPRESSION USE
EVALUATION OF RELATIONAL EXPRESSIONS
STRING VALUES IN RELATIONAL EXPRESSIONS
FUNCTIONS
SYSTEM FUNCTIONS
EXAMPLES OF USE OF SYSTEM FUNCTIONS
USER FUNCTIONS
SECTION 4 FILES
DEFINITION
PROGRAM FILES
DATA FILES
1V
Page
2-1
à AAA NAAA AN
Fa Fa Ps CY OS NN DD HH
CA CA CN
a ON +4
don
'
pi
> Hp
1
p=
CONTENTS
Page
SECTION 4 (Cont)
FILE NAMES 4-2
FILE NUMBERS 4-2
FILE EXPRESSIONS 4-3
SECTION 5 STATEMENTS 5-1
BREAK 5-2
CALL 5-3
DATA 5-4
DEF 5-5
DEFINE FILE/DEFINE READ FILE 5-6
FILE MODES 5-6A
RECORD SIZE 5-7
DIM 5-8
END 5-9
FOR 5-10
GOSUB 5-13
GOTO 5-14
IF 5-15
INPUT 5-17
LET 5-19
NEXT 5-20
ON 5-21
ON END 5-21
POSITION 5-22
PRINT 5-23
PRINTING NUMERIC EXPRESSIONS 5-23
PRINTING STRING EXPRESSIONS 5-24
COMMA SEPARATOR 5-25
COLON SEPARATOR 5-25
TAB REQUEST 5-26
PRINT LIST TERMINATION 5-26
PRINT USING 5-27
FORMAT FIELDS 5-27
NUMERIC FIELDS 5-27
STRING FIELDS 5-31
PRINTING SPECIAL CHARACTERS 5-33
READ 5-34
READ FILE 5-35
CONTENTS
SECTION 5 (Cont)
READ * FILE
REM
RESTORE
RETURN
REWIND
STOP
TRACE
WRITE FILE
READ AFTER WRITE CHECK
WRITE USING
SECTION 6 ARRAY MANIPULATIONS AND ARRAY STATEMENTS
ARRAY REDIMENSIONING
INITIALIZATION STATEMENTS
ARRAY INITIALIZATION WITH REDIMENSIONING
ARRAY ASSIGNMENT
ARRAY ADDITION
ARRAY SUBTRACTION
ARRAY MULTIPLICATION
SCALAR MULTIPLICATION
PRODUCTS OF ARRAY
TRANSPOSE OPERATIONS
MAT READ
MAT READ FILE
MAT READ * FILE
MAT WRITE FILE
MAT INPUT
MAT PRINT STATEMENT
SECTION 7 INTERFACE CONVENTIONS
RELATING CALL TO SUBROUTINE
MODIFYING COMMAND FILE
RUNNING PROGRAM WITH CALL STATEMENTS
APPENDICES
vi
I
>
OV ON ON ON OO OS OO OO OO OX OO O
|
Hs pi pt pd LO OO CO I ON ON ON UT UT Ge ВО A
о HH © ©
~J
|
jad
i
OH
FOREWORD
BASIC is easy to learn and easy to use. The rules of form and usage
are simple. This manual describes the Prime BASIC language processor
and demonstrates how it is used to solve problems and cope with features
common to computers. It is suitable for (1) people who know BASIC and
want to know what Prime's BASIC is like and (2) experienced programmers.
The tyro is advised to supplement this book with a primer on BASIC.
Prime BASIC is an extended subset resembling the BASIC developed at
Dartmouth College. It provides users with the ability to write programs
and get meaningful results from the computer in a relatively short
time. With a few hours of instruction and/or practice, most people
can produce worthwhile BASIC programs and obtain useful data from
em.
Section 1 describes the structure of a BASIC Program, gives
a few general rules about writing BASIC program
statements, and tells how to enter BASIC and how
to input, edit, and RUN programs.
Section 2 describes in detail how numeric and string data are
represented in BASIC, and gives limits of numeric and
string data values.
Section 3 describes both numeric and string expressions,
expression operators, and expression evaluation.
Section 4 describes the organization, and the input and output
of program and data files.
Section 5 describes the statements available in the BASIC
language. The function and syntax of each statement
is described and examples of each statement are
given along with the description.
Section 6 describes the statements available to manipulate
matrices and vectors.
Section 7 describes how to interface called FORTRAN or PMA
language programs.
Appendix A gives some sample programs using the BASIC language.
Appendix B lists the error messages returned by the BASIC
language processor and the definitions of those
error messages.
Appendix C is a quick summary of all the features of BASIC.
Appendix D describes a utility program to renumber BASIC programs.
Appendix E describes the memory requirements for various versions
of Prime BASIC.
VERSIONS OF BASIC
On the master disk (i.e., that disk supplied to the Prime customer with
all the current software), there are three versions of the BASIC
language interpreter: BASIC, LBASIC, and DBASIC.
The version named BASIC contains a subset of the BASIC language that does
not include MAT functions or PRINT USING functions. It is intended for
user's who may have memory limitations or who may only want a simple form
of BASIC. LBASIC is a full version of the BASIC interpreter that
includes MAT functions and PRINT USING functions. DBASIC is a full
version of BASIC that takes advantage of Prime's double-precision
floating point arithmetic capabilities.
All versions of BASIC on the master disk may be copied to the users
command directory (CMDNCO) or to a user designated UFD and renamed
"BASIC" by use of the operating system's FUTIL and CNAME commands,
(Refer to the Disk and Virtual Memory Operating Systems User Guide).
DOUBLE PRECISION BASIC
Prime BASIC has been revised to include double precision floating point
representation. BASIC with double precision floating point is imple-
mented using floating point hardware; thus, coding that references
floating point operations is both in line and efficient.
All constants, variables, and array elements are represented in floating
point format with a 48-bit mantissa and a 16-bit exponent. This
representation allows numbers to have an accuracy up to 14.2 decimal
places. With double precision floating point, it is possible to repre-
sent a number up to:
9,999,999,999,999
or a dollar sum up to:
$99,999,999,999.99
without resorting to the use of scientific format.
To use the double precision version of BASIC, type the command:
DBASIC
viii
Use of this version of BASIC, other than for the extensions
outlined, is identical to the use of BASIC described in this manual.
RELATED PUBLICATIONS
The following Prime documents should be available for reference:
Disk and Virtual Memory Operating Systems User Guide
Program Development Software User Guide
ix
SECTION 1
STRUCTURE OF A BASIC PROGRAM
STATEMENTS
A BASIC program consists of a series of sequentially ordered
statements.
Statement Format
Each statement is preceded by an integer called the statement
number. This number serves as both a statement sequence number as
well as a line identifier. An example of a BASIC statement is:
100 PRINT 'AARDVARK'
Each statement must be contained on one line. The length of a line
is dependent on the number of characters that can be typed before a
carriage return is needed to prevent the line from overflowing.
BASIC will accept lines up to 120 characters in length.
Statement Execution
When a program written in the BASIC language is run, the statements
are executed in order of statement number (unless a statement such as
GOTO affects the normal order).
ENTERING BASIC
To enter BASIC from operating system command level, type:
BASIC
The system then replies:
GO
>
The character '>' indicates that the BASIC processor is awaiting a
command, and is printed as a prompt.
MODES OF OPERATION
The Prime BASIC language processor consists of a command processor,
a statement editor and a BASIC language interpreter.
1-1
After entering BASIC from operating system command level, GO 1s
typed. The user may:
1. Input, edit, and RUN programs written in the BASIC
language (conversational mode);
2. Execute existing programs written in BASIC language and
stored on disk or paper tape (batch mode);
3. Execute BASIC statements as they are typed at the terminal
(immediate mode).
CONVERSATIONAL MODE
Entering Program Statements
To enter a statement, type the statement number followed by the body
of the statement. All statements must be terminated by a carriage
return.
Statement Numbers: Statement numbers are integers that range from
T to 9999. They do not have to be in cardinal sequence (i.e.,
1, 2, 3...n-1,n), but they must be in an ordered sequence (e.g., 10,
12, 15, 20...n). It is recommended that statements be numbered by
increments of 10 (100, 110, 120, 130...). Then, if a statement must
be inserted between 10 and 20, for example; it can be numbered 15,
and it is inserted between 10 and 20.
For example:
110 PRINT 'NAME', N$
120 PRINT 'ADDRESS', A$
130 PRINT 'CITY'. C$
To insert lines between 110 and 120, and 120 and 130, in order to
make the output more readable, the user need only type:
115 PRINT
125 PRINT
at his terminal. The resulting program sequence is as follows:
110 PRINT 'NAME', N$
115 PRINT
120 PRINT 'ADDRESS', A$
125 PRINT
130 PRINT 'CITY', C$
1-2
Body of Statement: In the conversational mode, each statement starts
after its statement number with a full or partial English word. This
word denotes the type of the statement.
Examples of BASIC statements are:
100 REM THIS IS A REMARK
110 LET X = 2
120 PRINT X
Blanks: Blanks (spaces) have no significance except in string constants.
Generally, spaces are used to make the program more readable. For
example:
110 LET X = 3.14
110 LET X= 3.14
110 LETX=3.14
are equivalent. Thus, BASIC statements are free-formatted and the
user may employ spaces at will to format BASIC program text.
Special Characters: The following characters have special meaning:
TT
removes the character previously typed.
? removes all previous characters on a line.
CARRIAGE RETURN Terminates a source statement.
This convention is consistent with the operating system and the
system Editor, (refer to the Disk and Virtual Memory Operating
System User Guide and the Program Development Software User Guide).
Storage of Statements
When the CARRIAGE RETURN is received by the BASIC language
processor, the statement is stored into the program storage area.
Statements may be entered in any order, but their execution occurs
in the order of their statement number.
1-3
Replacing a Statement
If a statement is entered with the same number as a statement
already in the program storage area; the previous statement is
removed, and the new statement is placed in the storage area
instead.
Example:
Existing statement is:
110 LET XI = Y**2
Assume a new statement is typed as follows:
110 LET XI = Yr2
The second statement rumbered 110 replaces the first statement.
Deleting a Statement
To remove an existing statement without replacing it, type the
statement number followed by a CARRIAGE RETURN. Example:
110
deletes statement numbered 110.
Sumary of BASIC Program Editing Procedures
To input a statement, type:
unused statement number, followed by statement, followed by
CARRIAGE RETURN.
To insert a statement, type:
a statement using a statement number between the two
statements surrounding the insertion.
To replace a statement, type:
a new statement with a statement number that is identical
with the number of the statement to be replaced.
To delete a statement, type:
the statement number, followed by a CARRIAGE RETURN.
1-4
EXECUTING A PROGRAM
To run all BASIC statements in the program storage area, the user
types:
RUN
This causes the BASIC language processor to interpret and execute
the program comprised of the statements in the program storage area.
BATCH MODE
In addition to input from a terminal, statements may be input to the
BASIC processor from source files on disk, or from off-line storage
devices such as paper tape, magnetic tape, or cards.
Data to be processed during RUN time may come either from the program
itself (DATA statements), from the terminal (via use of INPUT
statements), or from files on disk. Output data from a program
written in BASIC may either be printed at the terminal or placed in
a file on the disk.
Batch mode requires the reading and writing of files via the use of
the LOAD and FILE commands.
After a BASIC program is written, it may be saved in the User File
Directory (UFD) via a FILE command. (For information on the UFD,
see the Prime Disk and Virtual Memory Operating Systems User Guide.)
The syntax of the FILE command internal to BASIC is:
FILE 'FILENAME'
or
FILE 'FILENAME', Si, 52
where FILENAME is the symbolic name of the file to be created or updated
enclosed in single quotes. The single quotes are delimiters necessary
to BASIC and are not part of the file name. The file FILENAME is
updated; however, the contents of the BASIC program storage area remain
unchanged. FILENAME may also be a parenthesized device name (see the
DEFINE FILE statement discussion in Section 5). The optional argument
S1 specifies the first statement number of the BASIC program to be
filed. If Sl is omitted, its default value is 1. The optional argu-
ment S2 is the last line to be filed. If S2 is omitted, its default
value is 9999. All statements having statement numbers in the inclu-
sive range S1 through S2 are output to the specified file or device.
Examples of FILE Command В
FILE 'RANDXX'
creates a file named RANDXX in the UFD.
1-5
FILE '(PTP)', 100, 200
creates a file for output to the paper tape punch consisting of all
the statements in the program storage area with statement numbers
between 100 and 200 inclusive. The contents of the program storage
area remain unchanged,
Loading and Running Programs
To load and run a BASIC program that has been previously edited and
saved in a file, the user loads the program by using the LOAD
command, and executes the program by issuing a RUN command immediately
after issuing the LOAD command. |
The syntax of the LOAD command is:
LOAD FILENAME'
or
LOAD 'FILENAME', Sl
where FILENAME is the name of a file in the UFD or a symbolic device
specification and the single quotes are delimiters required by BASIC.
The optional argument S1 is a statement number specifying that all
statements in the loaded source files are to be biased by the specified
statement number value, in order to avoid conflict with any program
already loaded. If S1 is omitted, statements in the program storage
area are numbered the same as the corresponding statements in the file.
The RUN command may have been written as the last line of the source
file by use of the system editor. In this case, the initial LOAD
command causes the program to be both loaded and run.
Examples of LOAD Command
The command line:
LOAD 'RANDXX'
loads the previously saved file RANDXX into the program storage area.
LOAD '(PTR)', 1000
loads a file from the paper tape reader, and starts numbering the
stored statements at statement number 1000.
After the program, or programs are stored using the LOAD command,
the user executes all statements stored by typing:
RUN
1-6
The following is an annotated example of some trivial programs
written in BASIC. In shows simple editing of a series of program
statements in conversational mode and the loading and running of
programs using BATCH mode concepts. The use of the BASIC FILE,
NEW, LIST and LOAD commands is also illustrated. User input 1s
underlined.
OK» BASIC
GO
>10 REM START BASIC 1s invoked and a simple
>20 PRINT ‘“AARDVAARK program is typed in by the user
>30 END
>FILE “AARD” -€——lo save this program as a file
>NEV << To clear program storage area
>30 PRINT “SYZYGY”
>40 END <<—— Typing a new program
>FILE “SYZYGY”
>WIT < To exit from BASIC
OKs ese
OK», BASIC
>LOAD “AARD”
>LOAD ”SYZYGY”
>1L 157
10 REM START
20 PRINT “AARDVAARK”
30 PRINT “SYZYGY”
40 END
>RUN -<€——T0 execute program
AARDVAARK
SYZYGY Output from user program
At a later time BASIC is entered and
the filed programs are loaded
To list the contents of the program
storage area.
nn AT IT n
& ra LIND qu
"9
1-6A
IMMEDIATE MODE
Immediate mode allows a user to type BASIC statements with no state-
ment number and thereby obtain immediate results. Such statements
are not stored in the program storage area. For example:
PRINT "XYZ"
causes the string XYZ to be printed at the terminal.
The immediate mode capability gives the user a super-calculator
with a rich choice of functions, automatic decimal point handling,
and up to 286 variables, as well as arrays available for partial
answer storage.
One use of immediate mode is to use the BASIC subsystem as a desk
calculator. For example:
X = 256*12
PRINT X
returns the product of 256 and 12.
The PRINT statement is a particularly useful immediate mode command.
For example:
LET X1 = 1.05
PRINT SIN (X1#* 3,14959/180)
causes the appropriate value of the SIN function to be issued.
The immediate mode is useful at times for debugging programs written
in BASIC. For example, if the user has made use of the BREAK statement
(Section 5) to halt a program at some point, typing:
PRINT J2
prints the value of the variable J2 at the point that the execution
of the program was interrupted.
Similarly, it is possible to use the PRINT statement to print the
value of any and all variables at a point of interruption.
1-7
COMMANDS
The BASIC language processor provides a number of commands to be used
with the operating system and to initialize storage areas. Of these,
use of RUN, FILE and LOAD have been previously discussed.
These commands are usually executed in immediate mode, but they may be
part of a program statement.
The syntax and function of system commands are described in the follow-
ing paragraphs:
LOAD COMMAND
Syntax
LOAD 'FILENAME'
or
LOAD 'FILENAME', S1
'FILENAME' - is a string constant that specifies
the file to be created (or parenthe-
sized device specified). The single
quotes are delimiters required by BASIC.
S1 - 1s a relocation constant that is added to
every statement number in the program,
written in BASIC, to be loaded.
Function
The specified file (of BASIC Source Statements) is loaded into the
BASIC program storage area.
The loaded program is merged with any program already loaded. For
examples, see the previous section entitled "Examples of Load Command'.
FILE COMMAND
Syntax
FILE 'FILENAME'
or
FILE 'FILENAME', S1
or
FILE 'FILENAME', S1, 52
'FILENAME' - (is the same as described for
LOAD, above.)
S1 (optional) = first line to be filed (default = 1).
S2 (optional) = last line to be filed (default = 9999).
1-8
Function
All statements whose statement numbers are in the inclusive range
S1 through S2 are output to the specified disk file or output
device. Output is in the order of their statement numbers.
Example.
FILE 'NEWPRO'
LIST COMMAND
Syntax
LIST
or
LIST S1
or
LIST 51, 52
Sl = first line to be listed (default = 1).
S2 = last line to be listed {default = 9999).
Function
The LIST command prints output at the terminal. The LIST command
provides a means to print all or part of the previously edited state-
ments for the user's inspection.
Examples:
LIST
LIST 100, 250
RUN COMMAND
Syntax
RUN
or
RUN S1
S1 = statement number specifying the first statement
to be executed (default is the first statement
in the program).
1-9
Function
RUN clears all variables, allocates arrays from DATA statements,
and starts program execution.
NEW COMMAND
Syntax
Function
The NEW command deletes all existing program statements and de-
allocates all arrays and variables.
CLEAR COMMAND
Syntax
CLEAR
Function
The CLEAR command de-allocates all arrays and variables. Any
existing statements are not deleted.
CONTINUE COMMAND
Syntax
CONTINUE
Function
The CONTINUE command restarts program execution at the point that it
was last interrupted by a BREAK, STOP or END statement.
1-10
RESTARTING BASIC
Restarting from DOS/VM
The user may desire to QUIT from running a BASIC program (e.g., to
avoid printing unwanted output), and then return to running under
control of BASIC. Naturally, it is desirable not to lose any inform-
ation in the program storage area or cause any unspecified operations.
For DOS/VM, the correct manner to achieve this result is to type the
following sequence of system command lines:
CONTROL-P (Quit by pressing terminal CTL
and P Keys simultaneously).
START 1002
Restarting from DOS
Under DOS, to QUIT from running a BASIC program, momentarily set
Sense Switch 1. The running program is interrupted and contro;
returns to BASIC command mode.
Return from INPUT
The user may type the sequence:
CONTROL-C To return from BASIC INPUT statement
execution to conversational mode
(Refer to Section 5).
1-11
ERROR MESSAGES
Statements are syntactically checked as they are entered. Errors that
can only be detected within the context of the entire program are
detected at run time. An example of a syntax error is:
100 PRINT 'SUM OF A § B IS: X
The closing ' mark is missing and this would be detected immediately
upon entry. An example of a context error is an undefined statement
number in a GOTO statement.
If an error is detected during statement input, a two-line error is
printed at the terminal. The first line is the source statement in
error. The second line consists of first, a vertical arrow positioned
under the last character that BASIC examined before detecting the
error, and then a two-character error code. These codes are listed as
source (S) errors in the table in Appendix B.
Errors detected during program input cause the line in error to be
removed from the program.
During program exectuion (RUN time), detected errors cause a one-line
message to be printed as follows:
ERROR XX LINE 385
where XX is the error code. These codes are listed as execution (E)
errors in the table in Appendix B.
Errors detected during program execution also cause a pause to
occur. Typing:
CONTINUE
causes processing to continue with the next statement,
1-12
SECTION 2
TYPES OF DATA
Two types of data are supported by Prime BASIC: numeric and string.
BASIC allows constants and variables of both types.
NUMERIC VALUES
A numeric value is a floating point number. Depending on the version
of BASIC being used, it may be single or double precision.
A numeric constant is written as a signed decimal number. It may
contain a decimal point, and it may be followed by an exponent.
The exponent field is optional and is written as the letter E
followed by an optionally signed decimal integer.
If the decimal point is omitted, it is assumed to be located immedi-
ately to the right of the last significant digit (right-most digit).
If the sign of either the numeric constant or the decimal integer
exponent is omitted, it is assumed to be positive.
Examples:
12
1.2
-6.666
-7
2.5E-2 (.025)
2.5E+12 (2.5 * (10)12)
-7.3E-2 (-.073)
SES (500000)
2-1
Range of Numeric Values
For single-precision values; all constants, variables and array
elements are represented in floating point format with a 24-bit
mantissa and an 8-bit exponent. This representation allows numbers
to have accuracy up to 6.2 decimal digits, and the exponent of a
single-precision numeric value may range between -38 and +38. (10 to
the -38 power, or 10 to the +38 power).
With single-precision format, it is possible to represent a number up
to: 999,999 or a dollar sum up to: $9,999.99 without resorting to
scientific format.
For double-precision values; all constants, variables, and array
elements are represented in floating point format with a 48-bit
mantissa and a 16-bit exponent. This representation allows a number
to have an accuracy up to 14.2 decimal places.
With double-precision floating point, it is possible to represent a
number up to: 9,999,999,999,999 or a dollar sum up to: $99,999,999,999.99.
2-1A
STRING VALUES
A string value is a string of ASCII characters.
A string constant is written as a set of 0 or more contiguous ASCII
characters enclosed in delimiting single quotation marks
(or apostrophes). A string constant can contain any ASCII character
except: CARRIAGE RETURN, ?, or ". The maximum length
(number of characters) of a string value is a function of the line
size of the terminal or upon the available memory. Generally, this
is large enough to be of no problem to the user. It is suggested
that for convenience no string be greater than 80 characters.
Examples:
"THIS IS A CHARACTER STRING CONSTANT"
'DATE/ TIME/YEAR!
'! (null string)
112345"
SCALAR VARIABLES
A scalar variable is implicitly defined when it is used in a
mr fa
BASIC program. The type of scalar variable (i.e., numeric or
string) is determined by the form of the variable name.
Numeric Scalar Variables
The name of a numeric scalar variable is a single letter (A-Z), or 1t
is a single letter (A-Z) followed by a single digit (0-9). Each
variable represents a single numeric value; there are 286 possible
numeric scalar variables. A numeric scalar variable is initialized
automatically to 0 at the start of the BASIC program that defines
it.
Examples of Numeric Scalars:
X
Al
G3
2-2
Example of Use of Numeric Scalars:
20 LET Cl 3.14157
22 LET ‘X C1#2
String Scalar Variables
The name of a string scalar variable consists of a single letter
followed by a dollar sign. A string scalar variable represents a
character string of variable length. String variables are initial-
ized to a null (zero length) string at the start of the BASIC
program that defines it. The length of a string variable is auto-
matically set to the length of the string that is assigned to 1t.
Example of String Scalar Variable:
B$
Examle of Use:
100 LET B$ = "BALANCE IS:'
ARRAY VARIABLES
An array is an ordered set of values. All elements of an array
(array variables) have the same data type (i.e., either numeric or
string). The elements of an array are stored in contiguous
locations in storage and are referenced by an array subscript.
Arrays are stored in colum major order.
An array name is represented by a single letter followed by the
parenthesized list of one or two bounds.
An array element is designated by an array subscript that is either
one number (bound) in parentheses (one-dimension), or two numbers
(bounds) in parentheses and separated by commas (two-dimensions).
An array with one-dimension may be operated on as a vector; with two
dimensions, it may also be operated on as a matrix (See Section 6).
Examples:
A (6)
A (2, 3)
2-3
A (0,0)
A (0,1)
A (0,2)
A (0,3)
A (1,0)
A (1,01)
A (1,2)
A (1,3)
Conceptually, the array A (2,3) is:
A (2,0)
A (2,1)
A (2,2)
A (2,3)
Table 2-1. Example Array A (2,3)
Logically, the array A (2,3) maps into storage as shown in the
following table:
Relative
Location Element
0001 A (0,0)
0002 A (1,0)
0003 A (2,0)
0004 A (3,0)
0005 A (0,1)
0006 A (1,1)
0007 A (2,1)
0008 A (3,1)
0009 A (0,2)
00010 A (1,2)
00011 A (2,2)
00012 A (3,2)
Table 2-2. Array Mapped into Memory
Array Declaration
An array can be explicitly defined in a DIM statement, or implicitly
defined by its use in the program.
DIM statements, if used, may appear anywhere in the program,
since BASIC locates and interprets all DIM statements before
execution starts.
Examples:
DIM A (5)
defines a one-dimensional array of 6 locations A, A (0) through
A (5).
2-4
DIM A (2, 3)
defines a two-dimensional array of 3 colums and 2 rows, A (0,0
through A (2,3).
NOTE: The entire chart shown in Table 2-1 is the array
specified by the DIM statement, DIM A (2,3). Those
elements of the array that do not have zero subscripts
(e.g., A (1,2); A (1,3); A (2,1); A (2,2); A (2,3) define
the matrix A. This matrix may be manipulated via the MAT
statements described in Section 6.
If the DIM statement is omitted (i.e., an array is undeclared), the
array dimensions are established in any MAT statement encountered;
otherwise the array is either a one-dimensional array of no more than
10 elements (e.g., A(10)), or a two-dimensional array of bounds 10 by
10 (e.g., A(10,10)), depending on how the array is referenced.
Use of an array in a MAT statement can cause the array to be defined
either as a vector or matrix depending on the other arrays used in
the statement (refer to Section 6).
Array Bounds, Default Bounds, and Storage Allocation
The original bounds of an array are established by the DIM statement that
defines the array, by the first MAT statement that references the array,
or the impiicit value ((10) or (10,10)). The original bounds of an
array specify the total amount of storage allocated for the array. The
MAT statement can reduce the size of an array, but the MAT statement
cannot increase the size of the array beyond that of the original
definition. though the dimensions of an array may be changed, the
storage allocation for the array does not change during execution of
the BASIC program.
Array Element References
Numeric Arrays: The name of a numeric array is a single letter
(A-Z). When a single element of an array is initialized to any
value, the remaining elements of numeric arrays are initialized to 0.
String Arrays: The name of a string array is a single letter followed
by a dollar sign, $. The elements of a string array are variable-
length character strings. These character strings may all be of
different lengths. Elements of a string array are initialized to a
null value when the array is established.
A reference to an array element consists of the array name followed
by a parenthesized list of one or two subscripts; i.e., A (S1) от
А (51, S2), where A is the array and S1 and S2 are positive numeric
expressions (see Section 3 for a discussion of expressions).
2-5
Examples of Numeric Arrays:
A(5)
A(2,4)
A(K, J) where K and J are numeric scalar
variables
A(I+1, J/2)
A (I+J, 3*K-2)
If the value of a subscript expression is fractional, the value of
the subscript is truncated to an integer before it is used to locate
the specified array element.
The value of any array subscript expression mist be within the range
of the corresponding array dimension.
Examples of String Arrays:
А$ (5)
А$ (1+1, 3*K-2/J)
A$ (A (I) /4)
Relationship of Names
A string variable and a string array may have the same name in a
program. Likewise, a numeric variable and a numeric array may have the
same name. However, these names all refer to entirely different
entities. The context in which the name is used is the determining
factor. For example:
10 B$ = 'BBEBB'
20 DIM B$ (7)
25 B=2
30 DIMB (7)
are different variables even though the names are apparently the
same. B$ references a string scalar variable; B$ (7) references
a string array of 8 elements (0-7); B references a numeric scalar
variable and B (7) references a numeric array.
2-6
SECTION 3
EXPRESSIONS AND FUNCTIONS
The first part of this section describes the arithmetic and string
expressions that may be constructed in the Prime BASIC language.
The second part describes functions, both user defined functions,
and system functions provided by BASIC, such as SIN, LOG, etc.
EXPRESSIONS
BASIC expressions are constructed from operators and operands. An
operand may be a constant, a scalar variable, subscripted array
element, or a function reference.
Operators that require two operands are called binary operators.
Operators that require one operand are called unary operators.
BASIC defines two types of expressions: numeric and string.
Numeric operands must not be used with string operators and string
operands must not be used with numeric operators. There is no
conversion between numeric and string values. The user must define
explicit conversion functions to convert from one data type to
another.
Numeric Expressions
BASIC defines two unary operators and five binary operators that
operate on numeric operands to produce a numeric value.
Operator Meaning Example
+ unary plus +1
- unary minus -I
+ addition I+J
- subtraction I-J
* multiplication I * J
/ division I/J
+ exponentiation I 4 2
Table 3-1. Numeric Operators
The operators listed in Table 3-1 have their normal arithmetic
meaning. The operations are performed in floating-point arithmetic.
3-1
The user is cautioned that if he uses the system editor to create
a BASIC source program, then escape conventions must be observed
to produce some of the symbols desired. For example, using the
system editor, the exponentiation operator (*) must be escaped by
typing a double vertical arrow (e+).
Order of Expression Evaluation
A numeric expression is evaluated in the order of operator priority.
This is determined by rules of precedence in the BASIC langauge
processor. These rules of precedence are:
Precedence Operator
3 $
2 unary (+,-), *, /
1 +, -
Operators with higher precedence are evaluated before operators with
lower precedence.
Operators with. equal precedence are evaluated from left to right.
Example:
A+B-C*D* ErFrG
is interpreted as:
(A + В) - ((С * D) * ((E+F)* G))
Use of Parentheses
Parentheses can be used to control the order of expression evaluation.
The operation inside of the parentheses is evaluated first.
Example:
(А + В) / 2
The addition, A + B, is performed, then the division by 2 is
performed, even though / has higher precedence than binary +.
String Expressions
String expressions in BASIC are constructed using the concatenation
operator (+). This operator combines two string values to produce
3-2
a string having a value of the characters of the first string
immediately followed by the characters in the second string.
Examples:
A$ + BS
'HELLO' + U$ + 'WELCOME TO PRIME DOS VM'
'АВС' + В$
ОХ $ (1-1) + '01' + 5$
Relational Expressions
BASIC defines six relational operators that may be used in either
numeric or string expressions, as long as data types are not mixed.
The relational operators are shown in the following table:
Operator Meaning
Examples
X<Y
10 => 01
D<>1
X$ <Y$
A$ >B$
C$ = D$
A$ <= B§ + C$
AS =< YS
A$ >= C$
C$ => B$
A$ <> '!
Al >< AZ + A3 A$ >< В$
< less than
> greater than
= equal
<x less than or equal
== less than or equal
>= greater than or equal
=> greater than or equal
<> not equal
>< not equal
Table 3-2. Relational Operators
Examples of Relational Expression Use
20
30
IF SIN (ABS (K - 3.14) - 1) = (I+1) - 1 THEN 200
IF S$ <> "T4 THEN 450
3-5
Evaluation of Relational Expressions
The relational expressions are true if the expressions satisfy
the given expression. Examples:
120 IF X =< Y THEN 900
150 IF B$ = 'END' THEN 9999
160 IF B$>A$ THEN 120
String Values in Relational Expressions
When string values are compared in relational expressions, character
ordering is determined by ASCII code. If the strings being compared
are of different lengths, the shorter of the two strings is extended
by adding spaces to the right until the strings are of the same
length; then, the strings are compared. Use of string values in
relational expressions are given in statements 150 and 160 in the
previous set of examples.
FUNCTIONS
BASIC provides system functions and allows the user to provide
user-defined functions. A function reference consists of a function
name followed by a parenthesized arguement list containing one or
more arguments. Function arguments are evaluated before the function
is evaluated.
Arguments used in a function reference must match the number and
data type of arguments expected by the function.
Function references are evaluated at the point that their value
is required. They do not affect the order of operator evaluation.
System Functions
The following list gives the numeric and string functions provided
as system functions by the BASIC language processor. In all of the
descriptions in the list, X represents any numeric expression, I
and J represent any integers, and A$ represents any string expression.
3-4
SIN(X)
COS (X)
TAN (X)
ATN(X)
LOG (X)
EXP (X)
SQR(X)
ABS (X)
SGN (X)
INT (X)
RND (X)
LEN (AS)
computes the sine of X, X expressed in radians
computes the cosine of X, X expressed in radians
computes the tangent of X, X expressed in radians
computes the arctangent of X, result is in radians
computes the natural logarithm (base e) of X
computes e raised to the X power
computes the square root of X
computes the absolute value of X
returns a value based on the sign of X as follows:
X<0 SENO) =-1
X=0 SGN(X) = 0
X> 0 SGN(X) = 1
If X >=0, returns the greatest integer >= X. If
X <0, returns the least integer >= X.
If X< 0, uses X to initialize the random number
generator, and returns X as the function value.
If X>0, uses X to initialize the random number
generator, and returns a value in the range zero to
one. If X = 0, returns a random number in the
range zero < result < 1.
returns the length (number of characters) of the
«= += ловит A
STI Lig AS .
SUB (A$,I,J) returns a substring that is composed of characters
OT
SUB(A$, I)
I-J of string A$. If J is not specified, the result
is a one character substring consisting of character
I of string AS.
3-5
Examples of Use of System Functions
INT: One use of the INT function is to round numbers. Example:
INT (2.9 + .5) = INT (3.4) = 3
The INT function can also be used to round any specific numeric
value to any specific number of decimal places. Examples:
INT (10*X1 + .5) /10
rounds X1 to 1 decimal place.
INT (100 * X1 + .5) /100
rounds X1 to 2 decimal places.
RND: To produce twenty three-digit random integers, edit and run
the following BASIC program:
1) REM PROGRAM TO PAINT RANDOM NUMBERS OF 3-DIGITS OR LESS.
20 FOR I=1 TO го
SU БЕТ LIZRNDCI)
35 LET LI=INTCL*1999)
40 PRINT LI
50 NEXT I
69 END
EXAMPLE OF NUTPUT
RUN
211
352
301
716
673
176
235
247
353
163
373
399
13
266
473
6l
645
906
212
699
END AT LINE 60
The following example is a program that illustrates a use of each
of the system functions previously described; it is followed by
sample output so the user can get an idea of the results from using
the system functions.
150
110
120
150
14
150
160
170
180
1970
2GU
210
22
230
240
250
260
27ü
280
290
300
310
320
330
340
350
360
370
361
396
400
410
420
430
460
451)
461)
470
REM
REM
REM
REM
20 Г”
Mm m
X =
y
Y
Z
REM
REM
REM
51
Se
55
54
55
CA
Ce
C3
Ca
C5
T1
Te
T3
T4
TS
A
Al
AS
A4
AS
AN EN WON 00 PO HB $0 DU 69 OB SN QE 66 MU Hn
EXAMPLE TO SHOW USE OF SYSTEM FUNCTIONS
MLG 11-29-74
Vv = „01745
1 DEGREE IN RADIANS
„52359
. 78540
1.04719
1.57079
wsX,Y,72 ENUIVALANTS 30,45,60,90 DEGREES RESPECTIVELY
TRIGONEMETRIC FUNCTIONS CALCULATIONS
SIN (Vv)
SIN (W)
SIN (X)
SIN (Y)
SIN (7)
COS CV)
COS (WwW)
cos (x)
cus (Y)
COS (7)
TAN (Y)
TAN (WW)
ТАМ (Хх)
ТАМ (У)
ТАМ (2)
АТМ (11)
ATN(T?)
ATAN T3)
ATNCT4)
ATNCTS)
PRINT "DEGREES"','SIN"','COS",'TAN",'ARCTAN"
PRINT
PRINT 1,S1,C1,T1,A1
PRINT Зы» 52 „СТР АС
PRINT 45,53,03,T3,h3
3-6A
4 8
491
SCO
510
92
530
54U
554
560
570
250
590
OUU
610
520
630
640
650
ó6U
670
680
690
700
714
720
730
740
750
7600
773
78U
79
800
810
&2U
830
24
«50
560
871)
280
89
900
G14
920
930
940
950
960
970
98J
PRINT
FRINT
REM
REM
REM
?
L
E
о о ££ MM ™ Xx
I
P S
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
REM R
REM
PRINT
PRINT
PRINT
PRINT
21
Ze
25
"ouf
60» 5 & „Сб яТ би 4
20+,S5,C5,T5,A5
ARITHMETIC FUNCTIONS (LOG ETC)
„20
06 (X)
XP (Xx)
SQRCX)
ABSCX)
NT (CX)
GN (XD
"NUMBER ="
"LOG(X)'",L
'EXP',E
"SQUARE RCIT'.,G
„X
"ABS CX) "2," INTCX)'",'SIGN(X)"
Asl1,P
ANDOM NUMBER FUNCTIONS
"RANDOM NUMBER FUNCTIONS'
"RNDCO)",'RNDCN)"','RND(-N)"
RNO (17)
RND (1)
RND(-1)
PRINT 21,722,173
PRINT
КЕМ $5
КЕМ
X$ =
PRINT
PRINT
TRING FUNCTIONS
"EVALUATION OF STRING EXPRESSIONS '
"VALUE UF A GIVEN STRING:'
PRINT X3
PRINT
L1 =
PRINT
LEN(XS)
"LENGTH OF STRING:"
PRINT L1
PRINT
PRINT
BS =
'SURSTRING POSITIONS 21-31:'"
SUBCX5,21,31)
PRINT Bt
ORINT
END
Sample Output:
HUMBER =
LANAS
EXP
SRUARE FOOT
RANDOR NUMBER
RADA
Mo
ps
pa
No
=}
Lal
1. 74421E-
. 43
10
LO
Li
Li
ful
=}
fi
=)
pr
(CH
CU
J
0
oo
fo
Ha
1
fu)
m
a
Ja
1 1
ha
CC
ou
о
X
Ju
THT 2
FUNCTIONS
RHO CH
С)
I
a . 229547
(7,
=}
Fa
ja
EN
id
m
|
TI
{Ty
SIGH = 2
FCC =
. 2411273
3-6C
ARCTAN
1. 745E-62
Sample Output: (Cont)
VALUE OF A GIVEN STRING:
EVALUATION OF STEIMG ESFRESSTIONS
LEMGTH OF STRING:
же e
=>
— =
SUESTEIMG FUSITIOUNS 21-21:
ESFRESSION
ERC AT LIME 16
3-6D
User Functions
In addition to the system functions, BASIC allows the user to
define functions. These functions are local to the BASIC program
that contains them.
The name of a user-defined numeric function consists of the
letters EN followed by a single letter.
Example:
FNA (X)
A reference to a user defined function consists of the name of
the function followed by a parenthesized argument expression.
A user defined function is defined by use of the DEF statement
(see Section 5). For example:
120 DEF FNA (XZ) = 3.14 * Xi+Z
A user defined function reference may be included as an operand
in an expression. Example:
170 LET Al = 3.14 / FNA (X1)
The argument of a user-defined function may be an arithmetic
expression. The expression in the function reference argument
is evaluated, and the value of the expression substituted for the
argument in the function definition. For example:
180 LET Al = 3.14 * FNA (X1 + COS (B(3,4))
3-7
SECTION 4
FILES
DEFINITION
A BASIC file is a set of data external to the BASIC program. A file
is known to the operating system by its association with an
input/output device. The data in a BASIC file are organized into
sequential records. The contents of a file are made available
to the program by the execution of input/output statements that
transmit data between the file and the program.
The PRIME BASIC allows the user to create and use both program and
data files.
PROGRAM FILES
A program file may be created by using the operating system editor
(ED or FILED), to create a file consisting of sequentially ordered
BASIC statements. For details, refer to the Prime Disk and Virtual
Memory Operating System manual, and the Program Development System
User Guide.
Generally, a BASIC program file is created by first, editing a
program in conversational mode, as described in Section 1; then,
using the FILE command, described in Section 1, to write the
program file in storage. For example:
FILE 'RANDII'
stores the contents of the program storage area in a file on disk
named RANDII.
After a program file has been created, it may be loaded and executed
by entering BASIC and typing the LOAD and RUN commands. For
example:
BASIC
GO
> LOAD 'RANDIT'"
> RUN
The word GO and the > character before the LOAD and RUN commands are
responses printed by the BASIC language processor.
DATA FILES
Data files for input to a BASIC program are created by using the
operating system editor (ED or FILED) to create files or by using
other BASIC or FORTRAN programs (Refer to Section 5, DEFINE FILE,
for a description of possible file formats).
4-1
An ASCII file, the most used type of file, is a string of ASCII
characters organized into lines followed by a CARRIAGE RETURN.
A line consists of a contiguous string of characters between a
CARRIAGE RETURN character and the next CARRIAGE RETURN character
in the file. The length of a record in a file can be up to 72
characters, including the commas and the CARRIAGE RETURN. Each
data item in the file must be separated from the other items by
a comma.
Data files are read, manipulated, and written, by DEFINE FILE,
DEFINE READ FILE, READ, REWIND and WRITE statements within any
programs written in the BASIC language, that reference data files.
File Names
The name of a file stored on disk is a string of six ASCII
characters enclosed in single quotes. This string is used by the
BASIC interpreter to locate the file. An example of a file name
is:
"RANDIX"
À file name may also be a parenthesized device rame (see Section 5).
File Numbers
À BASIC program refers to files by means of a logical file number.
The range of file numbers is between 1 and 8 inclusive. The corres-
pondence between a file name and a file number is established by
the DEFINE FILE (or DEFINE READ FILE) statement. A file is considered
to be open if it is currently assigned a file number; otherwise,
it 1s considered to be closed.
A DEFINE FILE statement in a BASIC program causes an attempt to
locate the specified file. No error message is printed if the file
cannot be located, unless the file was referenced in a DEFINE READ
file statement, in this case, an error message is printed. However,
even if the absence of a specified file is not detected, subsequent
statements that reference the file may produce an error message.
A file remains open until it is closed. A file can be closed when:
1. control returns from a BASIC program to an operating
system (either normally or abnormally). All files
opened by that program are then closed.
2. a file is closed if its file number is used in a
subsequent DEFINE FILE statement.
4-2
File Expressions
The user can write an expression in a DEFINE FILE statement that is
evaluated to form a file number. The value of this expression
is truncated to an integer if it is a non-integer.
4-3
SECTION 5
STATEMENTS
This section describes all the BASIC statements implemented by the
Prime BASIC language processor except for the array manipulation
statements. These are described in Section 6.
In all the examples shown in this section and Section 6, the response
character, >, and the INPUT statement prompt character ! are not
shown unless deemed necessary for the purposes of the example.
Certain statements are only available on larger memory configurations
( 16K memory), notably the MAT and PRINT USING statements. Table
5-1 is a list of configurations and the extent of the BASIC implementa-
tion on those configurations. Appendix F gives further details with
regard to memory mapping and memory sizes.
Version of BASIC Memory
Size
BASIC without MAT or PRINT USING 16K
BASIC with MAT statements 32K
BASIC with PRINT USING statement 32K
BASIC with both MAT and PRINT USING 32K
statements
BASIC with Double Precision 32K
Table 5-1. List of Configurations and BASIC
System Statement Availability
5-1
BREAK
The BREAK statement selectively enables or disables breakpoints
at specific statements.
Syntax
BREAK ON N1,...Nn
or
BREAK OFF NI,...Nn
where N1...Nn is a list of statement numbers separated by commas.
If a statement at which a breakpoint is set is accessed during the
execution of a program, control is returned to the BASIC processor
command level (immediate mode) before the statement is executed.
If no statement numbers are specified with a BREAK OFF statement, all
breakpoints previously set ON are set OFF.
Example:
90 BREAK ON 40, 318, 215, 10, 45, 9999
195 BREAK OFF 10, 40
200 FOR X = 1 to 10
210 A = FNA (X)
215 REM, CHECKING VALUE OF A
220 NEXT X
235 BREAK OFF 215
5-2
CALL
The CALL statement is used to interface to a written subroutine that
is user-written in FORTRAN or assembly language.
Syntax
CALL C
or
CALL СПД, L2....In)
where the constant C is an integer that serves as a subroutine
identifier. The value of the constant C is limited only by the
size of available memory; i.e., as many subroutines as will fit
in memory may be called. The subroutine identifier 15 related to
the address of the subroutine by a user supplied file. The format
and use of this file are described in Section 7, Interface Conventions.
L1l...Ln are items in a list that are argument specifications to
the subroutine calling sequence. The argument list may contain up
to 26 items. An argument specification can be a numeric or string
variable, a numeric expression, an array, a subscripted variable
or a function argument. String expressions or string constants
cannot be included in the argument list. Arrays, variables, or
subscripted variables can be redefined by the called subroutine.
However, the value of numeric constants or expressions cannot be
redefined by the called subroutine; they can only be passed to the
called subroutine. All items in the list Ll,..Ln must be separated by
commas.
Example
CALL 5 (X1, X2, 6, A(10), X+1)
5-3
DATA
The DATA statement allows the user to specify a list of numeric or
string constants within the program. The constants must be
accessed by a READ statement.
Syntax:
DATA CI, C2, C3,...,Cn
where Cl...Cn are numeric and/or string constants separated by commas.
A trailing comma causes an error. The list of string or numeric
constants may be any length as long as the length of the line
1s not exceeded. To extend the list of constants more than one line,
it is permissible to write subsequent DATA statements.
The DATA statement is a nonexecutable statement that creates a block
of data to be read by the READ statement. BASIC separates numeric
constants in DATA statements from string constants and maintans a
separate data pool for each type. Any number of DATA statements
can appear at any place in the program. Data from all of the DATA
statements in the program, taken in the order of the DATA statements,
are concatenated to create a block of numeric DATA and/or a block of
string data.
When there are no more DATA items to be read, the program prints
the message:
"OUT OF DATA AT N'
where N is a statement number; and the program terminates.
Examples:
100 DATA 2.3, 3.4, 3.7E02, 1, 2, 3
200 DATA 3.1415, 2.783, 0
300 DATA 'ITEMS', 300 'COST' 1.58
5-4
DEF
The DEF statement defines a function of a single variable.
Syntax
DEF FNA(V)
where A is the function name and V is any variable. V may be an
expression that returns a value. For further explanation, refer to
"User Defined Functions" in Section 3.
The DEF statement defines a single-line function whose value is the
value of any expression that can refer to the optional function
parameters. The type of the expression must be the same as the type
of the function as defined. A particular function cannot be defined
by more than one DEF statement in the same program.
A function parameter (function tem) is a scalar variable that is
local to the function body, and a function parameter has no relation-
ship to a variable of the same name elsewhere in the program. The
value of the function parameter is set to the value of the corresponding
function argument when the function is invoked. |
DEF is a non-executable statement, and a DEF statement can be
written anywhere in the program.
20 DEF FNX (B) = 2./COS(B)*3
100 DEF FNO (P) = 3.14159
5-5
DEFINE FILE/DEFINE READ FILE
The DEFINE FILE statement opens the specified BASIC logical file
unit for reading and writing.
Syntax:
DEFINE FILE #E1 = 'S', M, E2
where E 1s an arithmetic expression defining file unit numbers (1-8),
S 1s a string expression specifying file names or an I/0 device,
M is an optional parameter that specifies the mode of the file, and
E2 is an optional parameter that defines file record size.
DEFINE READ FILE #E1 = 'S', M, E2
The DEFINE READ FILE statement functions the same as DEFINE FILE,
except it opens the specified BASIC Logical Unit for reading only.
The parameters have the same meaning as in the DEFINE FILE statement.
For further examples of usage of DEFINE FILE and DEFINE READ FILE,
refer to Appendix C.
El 1s an arithmetic expression defining BASIC logical
unit number. BASIC allows eight logical units (1-8).
Device Names
S 1s a string expression defining file name. If the
name starts with a left parentheses, it is interpreted
as a device name of the format: (dxu) |
where: d = device identifier
X = don't care
u = unit specifier
Possible values for device identifier are:
- Line Printer - pdev = 4
- Magnetic Tape » pdev = 5
A - ASR = pdev = 1
P - PTR/P « pdev = 2
C - Cards - pdev = 3
L
M
The unit specifier, u, ranges from 0 to 9. If the
unit specifier is not a digit, the physical unit is
the BASIC unit plus 3.
Disk File names are one to six characters long and begin with a letter.
1/0 device identifiers are enclosed in parentheses and delimited by
single quotes. Valid I/O device identifiers are as follows:
Device Identifier Device
"(A)" Teletype (terminal)
' (Р)' Paper tape reader/punch
' (LPR)' Line printer
' (С)' Card reader
'(MT1)' Magnetic Tape #1
' (MT2)' Magnetic Tape #2
' (MT3)' Magnetic Tape #3
' (МГ4)' Magnetic Tape #4
The standard versions of BASIC do not contain drivers for physical
devices 3 to 5. They can be configured by modifying the BASIC IOCS
configuration module, BASIO, and rerunning the appropriate command
file
File Modes
The optional mode parameter M specifies the mode of the file (i.e., the
kind of file that it is). Possible entries are: >
Mode (M) Meaning
ASC ASCII file.
ASC SEP ASCII file. When writing to the file, BASIC
inserts a comma between output fields rather
than the spaces specified by the WRITE state-
ment item separators. The type of file
produced by specifying ASC SEP is suitable for
input to other BASIC programs (1.e., acceptable
to BASIC as a READ file).
BIN Binary file. Data written into this type of
file is in internal memory format instead of
being converted to ASCII strings. An arithmetic
item generates two words of data in the file,
a string item generates (C+2)/2 words of data
(where: C is the number of characters in the
string).
5-6A
Mode (M) Meaning
BIN DA Same as BIN mode, except:
1. Fixed length records are written.
2. The file is opened as a DAM file (Refer
to the Disk and Virtual Memory Systems
User Guide).
3. The POSITION statement operates on the
file.
If the mode parameter, M, is omitted; its value is considered to be ASC.
Record Size
The optional parameter E2 is an arithmetic expression that defines the
record size of a file (number of words/record). The value of EZ may
range from 2 to 512. If the field E2 is omitted, a value of 60 is
assumed. The parameter E2 must be specified if mode M is specified
as BIN DA.
Examples of Use of DEFINE FILE:
10
20
30
35
50
60
70
75
76
77
80
90
99
REM CARD TO PRINT CONVERSION, DECK 1000 CARDS
DEFINE FILE #1 = '(CRD)'
DEFINE FILE #2
* (LPR) *
REM N=CARD NUMBER; N$=BLANK OR END OF DECK;
C$=CARD IMAGE
FOR I = 1 to 10000
READ FILE #1, N, C$, N$
IF № = 'Е№ ОЕ DECK' THEN 99
REM STATEMENT 70 SHOWS ONE WAY TO HANDLE END OF FILE
REM SITUATIONS
REM SEE 'ON END' ...
WRITE FILE #2, C$
NEXT 1
END
5-7
DIM
The DIM statement defines the number and size of the dimensions of
a numeric array or string array.
Syntax:
DIM A(C1)
or
DIM A(C1, C2)
where À is a numeric or string array name and CI, C2 are unsigned
numeric constants that specify the upper bounds of the corresponding
dimension.
The DIM statement specifically defines array names, establishes the
number of dimensions (one or two), and specifies the number of
elements in each dimension. The lower bound of each array dimension
is always 0. The upper bound of each array dimension is that value
specified for the element in the DIM statement. (Cl + 1) locations
are allocated for a single-dimension array (vector); and ((С1 + 1) *
(C2 + 1)) locations are allocated for a two-dimension array.
Any number of DIM statements can appear in a program. However, an
array name can be explicitly defined by a DIM statement only once in
a program. (However, it can be redimensioned any number of times by
subsequent MAT statements). A DIM statement is nonexecutable.
Examples:
100 DIM A(12)
declares a one-dimensional numeric array of thirteen locations
(A(0)...A(1])).
300 DIM A$ (2,3)
declares a two-dimensional string array of 3 colums (0, 1, 2) and
4 rows (0, 1, 2, 3).
NOTE: The arrays defined by DIM statements may be used later as
matrices (e.g., the set of array dimensions that are non-
zero). These operations are discussed in Section 6.
END
The END statement terminates execution of the BASIC program.
Syntax
END
The END statement indicates the end of the main program. It is
equivalent to and has the same function as the STOP statement.
Examples:
9999 END
When this statement is executed, the message:
END AT 9999
is printed.
5-9
FOR
The FOR statement defines the beginning of a loop, (sequence of
statements to be executed more than once within the program).
The NEXT statement must be used subsequent to the FOR statement
to define the end of the loop.
Syntax
FOR V = El TO E2
or
FOR V = El, EZ
OT
FOR V = El TO E2 STEP E3
OT
FOR V = El TO E2, E3
or
FOR V = El, E2, E3
where V 1s a scalar numeric variable; and El, EZ, and E3 are
numeric expressions. The variable V is the control variable of the loop.
The first expression (El) defines the initial value of V. The
second expression (E2) defines the final value of V. The expression
E3 is optional and is the incremental value added to V when the
subsequent NEXT statement is executed. The words TO and STEP may be
omitted and replaced by commas.
When the "STEP E3'" or "E3" term 1s omitted, the value +1 1s used.
The value of the control variable (V) can be modified within the
loop. Its value will be available at the end of the loop. Also, the
loop may contain statements that jump out of the loop.
FOR-NEXT loops can be nested indefinitely as long as available memory
is not exhausted. FOR-NEXT loops cannot be interleaved. A nested
FOR-NEXT loop cannot use the same control variable as the FOR-NEXT
loop that contains it.
5-10
5 REM ANOTHER EXAMPLE
10 PRINT “PLEASE SPECIFY N; *
12 INPUT N
14 PRINT "PLEASE СРЕСТРУ М; '
16 INPUT M
20 DIM B(1000)
30 FOR I=N TO M STEP .|
40 LET BCI)=3.,1416*112
20 PRINT I,BCI)
60 NEXT I
66 STOP
RUN
PLEASE SPECIFY Nj
2
PLEASE SPECIFY №;
3.5
2 12.5664
2.1 13.8545
2.2 15,2055
2.3 16.6191
2.4 18,0956
2.5 19.635
2.6 21,2372
2.7 22,9022
2.8 24,6301
2,9 26.4208
3 28.2744
3.1 30,1907
3.2 32417
3.3 34,212
3.4 36.3169
3.5 38.4846
STOPPED AT LINE 66
The next example of FOR-NEXT assigns values to the elements of
a single dimension array.
110 DIM X(10)
110 FOR I = 0 TO 10
120 READ X(I)
140 NEXT I
300 DATA 0,1,2,3,4,5,6,7,8,9
One of the common reasons for using FOR-NEXT loops is to deal
with two-dimensional arrays. The idea is to use two subscript
5-11
variables to point to the column and row of the array controlled
by a loop. This 1s illustrated in the following example:
100
110
120
130
140
145
148
150
160
170
180
199
200
202
300
305
310
320
325
330
350
400
405
410
420
440
999
RUN
16
256
512
1046
34
300
15
READ C1,C2
FOR I=1 TO CI
FOR J=1 TO C2
LET ACI,J)=0
NEXT J
NEXT I
REM ELEMENTS OF ARRAY ASSIGNED TO ZERO
READ C3
IF C3=0 THEN 300
READ C4,X
LET A(C3,C4):=X
GOTO 150
REM STATEMENTS 150 TO 190 ASSIGN VALUES FROM THE DATA LIST TO
REM ELEMENTS OF ARRAY A.
FOR I=1 TO Cl
FOR J=1 TO C2
PRINT ACI, J)
NEXT J
PRINT
NEXT I
REM ABOVE LOOP PRINTS VALUES OF ARRAY ELEMENTS.
DATA 3,4
DATA 1,1,16,1,2,256,1,3,512,1,4,1046
DATA 2,1,34,2,2,300,2,3,13,2,4,9.87654E+08
DATA 3,1,99,3,2,88,3,3,7777,3,4,56
DATA O
END
Values assigned to A(1,1),..., A(1,4)
Values assigned to A(2,1),..., A(2,4)
9.87654E+08
99
83
7111
56
Values assigned to A(3,1),...,A(3,4)
END AT LINE 999
5-12
GOSUB
The GOSUB statement allows control to be passed to an internal
subroutine.
Syntax
GOSUB N
where N is a statement number in the program, N is a statement
number that specifies the line at which the internal subroutine is
to start. The subroutine must contain a RETURN statement.
The GOSUB statement saves the line number of the statement that
follows it, and then transfers to the statement specified by the
line number N. When a RETURN statement is subsequently executed,
control returns to the statement whose line number was saved (i.e. the
statement that follows the referencing GOSUB statement).
A subroutine may itself contain a GOSUB statement. Up to eight
GOSUB statements may occur before the execution of a RETURN statement.
RETURN always causes control to be returned to the statement follow-
ing the most recent outstanding GOSUB statement.
173 GOSUB 1000
The following is an example of a trivial but valid program; the
statements are executed in the order: 10, 30, 50, 70, 60, 40, 20.
10 GOTO 30
20 STOP
30 GOSUB 50
40 RETURN
50 GOSUB 70
60 RETURN
70 RETURN
5-13
GOTO
The GOTO statement causes program control to be passed to a non-
local, designated statement.
Syntax
GOTO N
where N is a statement number of a valid statement.
The GOTO statement causes program execution to continue at the
statement specified by N.
Examples:
10
200
Example use of GOTO:
100
110
120
130
135
138
140
150
160
180
999
GOTO 75
GOTO 400
PRINT 'INITIAL VALUE"
INPUT I
PRINT "TYPE CHANGE"
INPUT C
REM C IS + OR -
IF C = 0 THEN 999
LET I =1+C
PRINT 'NEW VALUE IS', 1
PRINT
GO TO 120
END
IF
The IF statement allows processing to be dependent on the true
or false value of a relational expression.
Syntax
IF El rel E2 THEN N
or
IF El rel E2 GO TON
where El and EZ are either both numeric expressions or both string
expressions; Tel is one of the following relational operators:
Operator Meaning
< less than
> greater than
e= Or =< — less than or equal
>= OT => greater than or equal
= equal
<> Or >< not equal
N is either a statement number or a statement, including another
IF statement. (N can only be a statement if the verb is THEN.)
If E1 and E2 satisfy the relation specified by rel, control is
transferred to the statement specified by N; otherwise, execution
— чаи - .. - re т
continues with the statement that follows the IF statement,
5-15
Examples
100
200
205
305
402
IF
IF
IF
IF
IF
A$ = 'YES' THEN 125
ABS (X-Y) < El THEN 75
C1=>C2 GOTO 50
X <>0 THEN IF X < 100 GOTO 402
(TAN(X9)-1) = (T(J*2-1) + 3 THEN 350
If any of the above conditions are false, program execution continues
with the statement that follows the IF statement.
5-16
INPUT
The INPUT statement requests data from the user terminal.
Syntax
INPUT LI, L2,...ln
where L1,...Ln is a list of references separated by commas. Trailing
commas are ignored. If more items are input then are on the
specified list Ll...Ln, the additional items are discarded.
The INPUT statement causes data to be read from the users terminal
and assigned to the references in the list Ll...Ln in the order
that they are typed. If there are any array references in the list
L1...ILn, subscript expressions are not evaluated until all references
that precede the subscript expressions in the input list have been
assigned values.
The INPUT statement prints the prompt-character, !, to
indicate that input is desired. The user must be sure to type
input as his program requires.
Data items provided by the user must match the data type of the
corresponding reference in the list, Ll...Ln, in the INPUT state-
ment.
A single quote may be combined in a string typed in response to an
INPUT statement. It is transferred literally to the program area.
Example, typing:
ABC'D
in response to an INPUT statement puts the string, ABC'D, in the
program storage area.
When a numeric value is expected, all characters up to the next comma
or CARRIAGE RETURN are input to the program. Spaces, blanks and tabs
are ignored.
5-17
Examples
10 INPUT Il
20 РОВ 12 = 11, 10
30 INPUT A (12)
40 NEXT IZ
Sample Output
16
112345
11. 3141579
12.45
19999999999
134
In the above example, the ! characters are typed by the system;
the numbers are input by the user in response to them.
Interrupting INPUT
The user can stop typing in a series of values in response to an INPUT
statement in his program and return to BASIC command level by typing
CONTROL-C (pushing the control and C key simultaneously. Example:
>10 INPUT A, B, C, D, E
>20 PRINT A, B, C, D, E
>RUN
! 1, 311 CTL-C “User interrupts INPUT
END OF DATA AT LINE 10 «Response from BASIC
> «Return has been made to
command level
5-18
LET
to be assigned a value,
Syntax
LET V = E
or
V = E
where V is a numeric variable or a string variable, and E is an
expression of the same data type as V.
The LET statement assigns the value of an expression to one or
more scalar variables or subscripted array elements. Subscripts
in the expression E are calculated before the expression is
evaluated and before any assignment is done.
Scalar arithmetic variables not explicitly assigned a value are
assigned a default value 0 when first referenced in a program.
Unassigned scalar string variables are assigned a value of a null
string ('').
Array elements not explicitly assigned a value are given a default
assigned value when the array is referenced. (See Section 2.)
5-19
Examples
10 I = 20
20 LET I = 2
100 LET X(5) = 24
102 LET V = C
"STRING OF CHARACTERS"
&
110 LET
120 LET A$
B$ + C$
440 LET I3 = 5
500 A(J) = SIN(X-4.5) + Q3
500 LET S$(J+5) = M$ + '.00'
NEXT
NEXT is used in conjunction with the FOR statement to increment
the control variable of the FOR-NEXT loop.
Syntax
NEXT V
where V is the control variable used with the previous FOR
statement.
Refer to the description of the FOR statement for further details.
The NEXT statement marks the end of a FOR-NEXT loop; it is always
used in conjunction with a preceding FOR statement.
Example
700 FOR I = 1 TO 100
705 LET A = A+1
713 NEXT |
5-20
ON
ON allows control to be passed to one of a list of statements
Syntax
ON E GOTO NI, N2, N3...Nn
where E is an expression and N1...Nn are numeric expressions
separated by commas that represent statement numbers.
The ON statement uses the value of the numeric expression to select
one of the statement numbers as the target of a GOTO operation.
The value of the expression is truncated to yield an integer that
must be positive and also must be less than or equal to the number
of statement numbers (Nn) specified in the ON statement.
Examples:
20 ON (1-1) GOTO 100, 200, 300, 400
If I = 1, control goes to statement 100; if I = 2, control goes
to 200; if I = 3, control goes to 300; and if I = 4, control goes
to 400.
The ON statement is useful because the IF statement provides only
a two-way branch in a program. The ON statement can provide more
altematives (i.e., a milti-way branch).
ON END
The ON END statement directs the transfer of control to a given
statement when an End of File is reached during a READ or POSITION
operation on the unit specified in the ON END statement.
Syntax
ON END #E GOTO N
where E is an expression that specifies a BASIC logical unit (1-8)
(Refer to DEFINE FILE); and N is a statement number. The ON END
statement does not test for End of File; it establishes action to
be taken when the last file record is read.
5-21
10 DEFINE FILE #1 = 'INPUT'
40 ON END #1 GO TO 20
50 READ #1, A$, A, B$, В
POSITION
POSITION positions a file on the unit specified to the start of the
record specified.
Syntax
POSITION #E1 TO E2
where El is an expression that specifies the BASIC logical unit (1-8)
and E2 is an expression that specifies the record in the file. Record
numbering starts at one. The unit (El) must have been defined to be
BIN DA mode (refer to DEFINE FILE).
If the record number specified is greater than the number of records
in the file, the file is positioned to the End of File and the ON END
action is taken.
5-22
PRINT
The PRINT statement causes information to be printed at the terminal.
Syntax
PRINT 11, L2,...,Ln
where L1...Tn are 0 or more items in a list separated by commas or
colons. Individual list items Ll...Ln may be either numeric
expressions or string expressions.
The PRINT statement generates lines of output to be printed at the
terminal. A single PRINT statement can generate either one line,
several lines, or partial lines of information.
The format of the terminal line image is determined by the
elements in the print list. Each element in the list Ll...In is
evaluated to yield a string of characters to be placed on the
terminal print line.
Printing Numeric Expressions
A PRINT list item that is a numeric expression is evaluated and
converted to the equivalent character string representation. This
string begins with the sign character and ends with a blank.
If the value of the expression is positive, a blank is printed for
the sign character. If the value of the expression is negative,
a minus sign is printed for the sign character.
Integers: Numbers printed as integers consist of a string from one
To six decimal digits without a decimal point. Examples:
14
-20796
1
Fractions: Numbers up to six decimal digits may be printed with a
decimal point.
Fractional format is used for nonintegers with an absolute image
in the range .1 to 99999.5. Examples:
5-23
2.5
12.4 3
-0.00796
0.00371
7.74186
Scientific Format: A number printed in scientific format is of
the form:
X E + Y
or
X E - Y
where X is a fractional number greater than one and less than ten,
and Y is an integer power of 10 ranging from -38 to +38. Scientific
format is used whenever integer or fractional format cannot be used
as shown in the following example:
LET X = 999999
LET X = X+1
PRINT X
results are printed:
1.0 E+6
Other examples of numbers in scientific format are:
2.54 E+13
5.0 E+5
-1. E-32
Printing String Expressions
A string expression in the PRINT list Ll...Ln is evaluated and
the resulting string of characters is printed in the output at the
teletype. BASIC does not interpret contents of this character
string; therefore, unpredictable results may occur from the inclusion
of characters that do not advance the print line by one position
(such as combinations of 2 backspace with other characters).
5-24
Comma Separator
The output from the PRINT statement is normally divided into zones
of 14 characters each. The first zone starts in colum 0, the
second in colum 14, etc. The number of zones is determined by
characters, five zones are printed.
A comma in a print list causes the Teletype to advance to the first
character position of the next available zone. If character over-
flow occurs, the current line is printed and a new line is started.
If the last element of the print list is a comma, the partial line,
if any, is printed; and the Teletype is positioned at the start
of the next available zone.
Example Use of Comma in PRINT Statement
The statement:
100 PRINT I, J, K, L
might result in the following output:
1.0 2.4 1.416 75
Colon Separator
A colon in a PRINT list is used to separate PRINT elements and
inhibits the printing of items in different zones. A colon
specifies that the preceding items to be printed is to be followed
by a space rather than the number of spaces required to position
to the next print field.
Examples of Use of Colon in PRINT Statement
The previous example written as follows:
100 PRINT I: K
causes the following output:
1.024 1.41675
The statement :
200 PRINT 'A': 'B', 'CAT': 'DOG'
prints:
A B CAT DOG
5-25
Tab Request
The tab print element requests that the Teletype be moved to a
specific character position (colum). The tab request is written
as:
TAB (E)
where E is a numeric expression. An example of the tab request
is:
100 PRINT X: TAB(40): Y
PRINT List Termination
If the print list does not end in a comma or colon, a CARRIAGE
RETURN character is appended to the print output and the line is
transmitted to the terminal. A null (empty) PRINT list causes the
previous line to be finished or a blank line to be printed.
PRINT Statement Examples
20 PRINT X, SIN (22 - Y 2)
30 PRINT "VALUE IS': X-Y
40 PRINT ' ', A$ + SUB (BS, I, J)
50 PRINT
Example of Use of Print for Conservational Input/Output
10 PRINT 'ENTER LENGTH IN INCHES':
20 INPUT L$(1,1)
30 LET X4 = L(1,1)/12
40 PRINT X4: 'FEET'
Sample results:
ENTER LENGTH IN INCHES ! 30
2.50 FEET
5-26
PRINT USING
A formatted print-statement (the PRINT USING statement) generates
formatted output.
Syntax
PRINT USING S$, Ll, L2...Ln
OT
PRINT USING S$, Ll: L2...Ln
where S$ is a string expression and Ll...Ln are items in a list
that are string or numeric expressions specifying values to be
printed, separated by commas or colons.
A single PRINT USING statement can generate one line, several lines,
or a partial line of printed output. The characters generated by
a PRINT USING statement are formatted as specified by a control
string. |
Format Fields
The string specified by S$ contains a description of the editing
to be applied to the values in the list L1...In. The string 5$
is divided into a series of fields each of which controls the
formatting of a single value in the PRINT list Ll...Ln. The fields
describe a numeric or string value.
There are seven special characters for defining numeric fields in the
ие, ЧРИ mn а о воть пыль ть
+ ra dd has La - # A
AU LIMGA Le 1110035 Ка а о аб.
, + + - $
Their use in a format field is described in the following tables
and paragraphs.
There are three special characters for defining string fields in
the format. These are:
< > #
helt use in a format field is described under the heading "String
-ields"', | a | |
5-27
Numeric Fields
Pound Sign (#): For each pound sign in the field descriptor, a
digit >) from the output value is substituted. Examples are
shown in the following table.
Field Format Datum Representation Remarks
MAP 25 25 Right justify digits
in field with leading
blanks.
HÜ##E .-30 30 Signs and other non-
digits are ignored.
HANA 1.95 2 Only integers are
represented; the
number 1s rounded
to an integer.
#HHHHH 598745 AARkK If the datum is too
large for the field,
all asterisks are
printed.
Table 5-2. Pound Sign in Descriptor Field
Decimal Point (.): The decimal point places a decimal point within
the string of digits in the fixed character position in which it
appears. Digit positions to the right of the decimal point are not
blank filled. Examples are shown in the following table.
Field Format Datum Representation Remarks
HEHEHE HE 20 20.00 Fractional positions
are filled with zeroes.
HH HH 29.347 29.35 Rounding occurs on
0.079 0.08 fractions.
RAÑER EE 789012.34 ARARAR AR When the datum is too
large, a field of all
asterisks, including
the decimal position,
is printed.
Table 5-3. Decimal Point in Descriptor Field
5-28
Comma (,): A comma in a descriptor places a comma in the output
record at that character position unless all digits prior to the
comma are zero, in that case, a space is printed in that character
position. The following table gives examples of use of the comma.
Field Format Datum Representation Remarks
+5 , HA. 30.6 +$ 30.60 Space printed for
comma when leading
digits blank.
+$4 448. HA 2000 +$2,000.00 Comma printed.
++## HHH 00033 +00,033 Comma 1s printed
when leading zeroes
are not suppressed.
Table 5-4. Comma in Descriptor Field
Vertical Arrow (1): A string of four vertical arrows can be used
to indicate an exponent field which is filled by E+n where n is a
two digit integer. The following table gives examples of use of the
vertical arrow.
Field Format Datum Representation
+## ## tte = 170.35 +17.04F+01
+## ## tt 1.2 -20.00E-02
++## ## tt tt 6002.35 +600.24E+01
Table 5-5, Vertical Arrow in Descriptor Field
Plus or Minus Signs (+ -): A single plus sign as either the first
or last character ın the format descriptor causes a + to be output
if the data item is positive, or a - if the data item is negative,
Two or more plus signs starting at the first character of the
descriptor cause the sign to be output (+ if positive, - if negative)
immediately to the left of the most significant nonzero digit of
the output item. If required, the second through the last plus sign
is used as digit positions as required by the magnitude of the
number.
A minus sign (or signs) has the same effect as plus signs , except
a space is output for a positive sign. The following table gives
examples of the use of + or - in formatted print output.
5-29
Field Format Datum
+##.## 20.5
+##, ## 1.01
+## Hi -1.236
+## HA -234.0
He ##- 20.5
MAR HE. 000.01
EAN, HA- -1.236
### ,##- -234.0
---.##- -20
---,## -200
---## 2
Table 5-6
Representation
+20.50
+ 1.01
- 1.24
ARAL AE
20.50
0.01
1.24-
234.00-
-20.00
ERRRRE
2.00
Remarks
Blanks precede the
number.
When the datum is
too large for the
specified format a
field of all asterisks
is printed.
The last leading
zero before the
decimal point is
not suppressed.
Second and third
signs are treated
as digit positions
(#) on output.
When the datum does
not agree with the
specified field,
asterisks are printed.
Plus and Minus in Descriptor Fields
5-30
Dollar Sign ($): A single dollar sign as either the first or second
character in the descriptor causes a dollar sign to be output in
that position of the output record.
Multiple dollar signs starting at either the first or second
character of the descriptor cause a dollar sign to be placed
immediately to the left of the most significant nonzero digit.
The only character that may precede a dollar sign in a format
descriptor is a fixed sign (+ or -). The following table gives
examples of use of the $ in formatted print output.
Field Format Datum Representation Remarks
- SHA #8 30.512 $ 30.51
ФИН AA+ -30.512 $ 30.51-
+$$$$# Яя 13.20 + $13.20 Extra $ signs may
be replaced by digits
as with floating
+ and - signs.
S$##.##- : -1.0 $01.00- Leading zeroes are
not suppressed in the
# part of the field.
Table 5-7. Dollar Sign in Descriptor Field
String Fields
Pound Sign (#): Each pound sign in the descriptor field represents
a character position from the second to the nth character position.
A character from the output (i.e., letter, numeral, or symbol) is
substituted in that position.
Examples are shown in Table 5-8.
Left Angle Bracket (<): This character in a descriptor field is
ways positioned first when it is used. It represents the first
character position and the first character from the output is
substituted for it. It also designates that the output string is
to be left justified in the PRINT statement field. An example is
shown in Table 5-8
5-31
Right Angle Bracket (>): This character in a descriptor field is
always the first character of the field. The first character of the
output is substituted for it and it designates that the output string
is to be right justified in the PRINT field. Table 5-8 shows an
example.
Field Format Datum Representation Remarks
> #HHH## TWELVE TWELVE right-justified
< {НН TWELVE TWELVE left-justified
Table 5-8. String Descriptor Fields
Print Using Statement Example
159 NEM A EXAMPLE TO SHON VARIOUS USES OF PRINT USING
166 REM
176 INFUT AB. 6
198 LET Ef="Ex--1"
199 PRINTUSINC ~ CHESSBSERS0 RRS 8R8444 LES
200 FRINTUSING “DHHHHHHHHHHHHHHHBR EE > ES
218 REM LAST THO LINES SHOW HOM JUSTIFICATION WORKS.
220 LET Fi="—## ##"
238 PRINTUSING РЖ, В, В, С
240 PRINTUSING “TTARAR4A ##", FL BC
250 FRINTUSING “DHH#88H8#84 TO 2°, ES
268 REM NOTE CONCATENATION, RESULT IS PLACED IN FIELD SPECIFIED
278 INPUT Y
200 PRINTUSING -- 48 ##7, CORK)
Sample Output
> UN
123.34,5545.93,45
EX==1
EX== 1
23 „54
Sok ok ko >
$00023 .94
$J3345.93
$UIV45.UU
eX=-=1 TO 2
1654
25.57
un
'
Lo
Lo
Printing Special Characters
To print a literal copy of one of the characters used with special
meaning in a format field, a string field must be used with the PRINT
statement and the character must be passed as part of the print list.
For example, the following statement prints a period at the end of the
output line.
10 PRINT USING 'X IS -### ':'.',Х
If the statement were written
10 PRINT USING 'X IS -###,',X
the decimal point would be part of the numeric field output.
5-33
READ
The READ statement is used in conjunction with a DATA statement.
DATA defines a series of data values (literals); READ sets a list
of variables equal to literals in the numeric and/or string data
pools.
Syntax
READ L1, ..., Ln
where Ll, ..., Ln is a list of references, which may be numeric
variables, string variables or arrays, separated by commas.
The READ statement causes numeric or string values stored in the data
pools by DATA statements to be assigned, starting at the next avail-
able element in the applicable data pool. The assignments are made
in the order specified by the references in the list specified with
the READ statement.
Subscript expressions in an array reference in the list L1, ..., Ln
are not evaluated until all preceding references have been assigned
values.
If a data list is exhausted, a message is printed and program
execution is halted.
The RESTORE statement may be used to prepare to read the data again.
Examples:
100 READ X, Y, Z
110 READ X$, X, Y$, Y, Z$, Z
120 READ X(3)
For examples of READ, all of the DATA are treated as a single list
of numbers. Each READ operation takes the next available number
from the list and advances one position on the list. The following
example illustrates this principle:
5-34
10 DATA 1.314 1.817
20 PATA 1, 2, 3, 5, 8, 13, 21, 34
30 DATA 55, 89
40 READ NI
50 READ N2
60 FOR K1+N1, N2
70 READ A(K1)
80 NEXT Kl
90 RESTORE
READ FILE
Input may be read from a formatted file prepared by the system
editor, from a file created by another BASIC program or from a
binary file created by a FORTRAN program. The format of the files
and their types and modes is defined by the DEFINE FILE statement.
Syntax
READ #N, L1, ..., Ln
where N is a file number and L1, ..., Ln are a list of all numeric
variables or all string variables separated by commas.
This variation of the READ statement reads from the file specified
by #N.
Initially, the READ FILE statement forces the reading of a new
record. The READ FILE statement reads values from the file starting
with the first data item in the record currently pointed to and the
file pointer is incremented by 1 after each data value is read.
If a file number specified in a READ FILE statement has not been
defined in a previous DEFINE FILE statement, the message:
ERROR UF AT LINE N
(where N is a statement number) is printed and execution of the BASIC
program halts, and the user's program returns to BASIC command level.
100 READ #4, V(I), A
110 READ #4, Al, A2, A3
5-35
READ * FILE
Syntax
READ * #N, L1, ... In
The READ * FILE statement has the same effect as the READ FILE
statement except it does not initially force a new record to be
read from the unit specified. If data remains in the last record
read from the unit, it is used before the new records are read.
REM
This statement identifies a remark. It is not executed.
Syntax
REM S
where S is any string of ASCII characters not including the carriage
return character.
The string of characters following REM is ignored by the BASIC
interpreter. The REM statement has no effect on the program; it
is provided for the convenience of the user.
Example:
10 REM PROGRAM TO PERFORM MEDIA CONVERSION
20 REM MLG MODIFIED BY SDH 10-15-72
30 REM
40 REM
RESTORE
The RESTORE statement resets the DATA list pointer so that the list
may be re-used by subsequent READ statements in the program.
Syntax
RESTORE
RESTORE #
RESTORE $
The RESTORE statement re-initializes either or both of the data pools.
The next read statement executed reads the first data item in the
pool or pools restored.
The RESTORE statement resets each data pool. The RESTORE § statement
resets the string data pool only. The RESTORE # statement resets
the arithmetic data pool only.
5-36
112 READ A, B
115 LET C= A*B
120 PRINT A: 'e' B, "PRICE": С
130 RESTORE
135 READ Z
140 PRINT 'NO OF ITEMS IS':Z
900 DATA 100, 3.50
Output is:
100 € 3.50 PRICE 350.
NO OF ITEMS IS 100
RETURN
The RETURN statement causes control to be returned from the sub-
routine that contains it to the statement immediately following
the GOSUB statement that invoked the subroutine (i.e., the last
outstanding GOSUB).
Syntax
RETURN
5-37
Examples:
100
110
111
120
130
300
301
310
320
325
330
340
350
360
370
380
400
410
420
INPUT A
GOSUB 300
INPUT A$
IF A$ <> 'END' THEN 100
END
REM 'SUBROUTINE TO CALCULATE IF A'
REM 'NUMBER N IS PRIME"
FOR X = (A-2) TO 1 STEP -1
LET Ql = A/X
LET Q2 - INT(X.X)
LET R = Ql - Q2
GOSUB 400
NEXT X
IF R=0 THEN 380
PRINT 'NUMBER' :A: 'IS A PRIME’
RETURN
IF R >< THEN 420
PRINT 'NUMBER' :A: ‘IS NOT À PRIME"
RETURN
The RETURN statement in statement number 380 causes a return to the
statement 111; the RETURN statement in 420 causes a return to 550.
REWIND
The REWIND statement causes the specified I/O unit to "rewind".
Syntax
REWIND N
where N is an arithmetic expression defining a file unit (1-8).
If the REWIND statement refers to a disk file, it is reset to start
from the first record.
Examples :
100
110
120
130
140
150
DEFINE FILE #4 = 'ALPHA'
INPUT N
FOR I =1TON
READ #4, A
NEXT I
REWIND #4
5-38
STOP
STOP causes the program to return to its caller.
Syntax
STOP
Any files opened by the program are closed. Executing a STOP
statement in a program is equivalent to an END statement.
Example
9999 STOP
causes a message to be printed such as:
STOPPED AT 9999
TRACE
The TRACE statement is used to turn trace mode ON or OFF.
Syntax
TRACE ON
or
TRACE OFF
When trace mode is ON, the statement number of each statement 1s
printed prior to its execution.
5-39
TRACE 1s useful in debugging a program that contains many GOTO
and/or GOSUB statements.
Examples: 110 TRACE ON
115 FOR I = 1 TO 10
120 A3 = Al + FNX (I) -3.1
130 IF A3 < O0 THEN 400
150 GOSUB 6000
160 IF A3 = 0 THEN 500
170 GOSUB 7500
180 IF A3> 0 THEN 600
190 GOSUB 9000
195 NEXT I
200 TRACE OFF
Assuming all conditions are true (in the first pass) a partial view
of the trace might look as follows:
[115]
[120]
[400]
[401]
[499]
[150]
[6000]
[6099]
[170]
[7500]
[7502]
[7550]
[180]
[600]
[650]
[190]
[9000]
[9010]
[9020]
[195]
[115]
5-40
WRITE FILE
The WRITE FILE statement directs output to a file.
Syntax
WRITE #N
oT
WRITE #N, L1,...Ln
where N is an expression that yields a file number (1-8) and
Ll,...In is an optional list of all numeric variables or all string
variables separated by commas or colons.
A print element in the list can be an expression or a TAB request.
WRITE statement output lines are appended to the specified file in
a stream.
Either full lines (terminated by a CARRIAGE RETURN character) or
partial lines (terminated by a comma or colon) may be output to a
file.
Read After Write Check
If an attempt is made to read on a unit after a WRITE has been
performed, without an intervening REWIND or redefinition of the unit,
a WR error diagnostic is printed. This check does not apply in the
case of writing BIN DA files.
5-41
10 DEFINE FILE #1 = '(LPR)'
20 FOR I = 1 TO 100
30 WRITE FILE #1 'ITEM-':X, 'COST-$ ' Y, 'ONE EACH'
40 NEXT L
120 DEFINE FILE #2 = 'ALPHA'
1 TO 100
130 FOR X
135 LET N X2
140 WRITE #2, X, N
150 NEXT X
Statements 10 to 40 print 100 lines on the line printer (if it is
assigned); statements 120 to 150 consecutively write 100 values
of X and 100 values of N onto a disk file ALPHA.
WRITE USING
Formatted output strings may be passed to a file by means of the
WRITE USING statement.
Syntax
WRITE USING S$, #N, L1,...,In
where N is a file number (1-8); S$ is a string expression, as in
the WRITE USING statement; and L1,...,Ln are a list of expressions
separated by commas or colons.
This variation of the WRITE USING statement directs output to be
appended to a Teletype formatted file. A single WRITE USING state-
ment can generate one line, several lines, or a partial line of
output.
Example:
140 WRITE USING 'X COST IS SHH #47 #3, A
5-42
SECTION 6
MATRIX MANIPULATIONS
AND
MATRIX STATEMENTS
The BASIC statements discussed in the previous section permit the
elements of a matrix to be defined and used as an element by element
basis. The MAT statement, discussed in this section, allows matrices
to be manipulated as a unit. In addition to the individual examples
given in this section, examples showing the use of the MAT statement
are given in Appendix A.
Although the arrays have a colum number 0 and a row number 0, the
MAT statement ignores all matrix elements that have one dimension
equal to zero (i.e., the MAT statement manipulates vectors and
matrices, 0 elements are indeterminate).
MATRIX REDIMENSIONING
The original bounds and the current bounds are determined by the
DIM statement, or by the default bounds value (10) or (10,10), or
by the first MAT statement that references a matrix. The current
bounds of a matrix can be changed within certain constraints.
The total amount of storage defined by the current bounds must be
less than or equal to the amount of storage set aside for the
original bounds. For example:
100 DIM A (10, 10)
300 MAT A = ZER (5, 5)
400 MAT A = ZER (3, 24)
500 MAT A = ZER (2, 29)
are all legal redimensions of the matrix A; but:
550 MAT A = ZER (5, 25)
is not legal redimensioning of matrix A.
A matrix may be assigned the value of another matrix with different
current bounds, provided this operation conforms to the rules for
redimensioning just discussed. The current bounds of the target
matrix are automatically changed to be the same as the current bounds
of the matrix assigned.
6-1
When the current bounds of a matrix are changed, any elements of
that matrix with one or more subscripts equal to 0 are destroyed.
INITIALIZATION STATEMENTS
There are three MAT statements to facilitate the assignment of the
individual matrix elements.
Syntax
MAT A
CON
or
MAT A = IN
or
MAT A ZER
where A is a numeric matrix.
These matrix initialization statements set the matrix specified to
the left of the = to a constant matrix having the same bounds.
The values to the right of the = are called matrix constants.
The constant CON sets each element of the matrix defined by matrix
A to 1. Conversely, the constant ZER sets each element of the matrix
defined by A to 0.
The constant IDN sets the matrix defined by matrix A to the identity
matrix. This action is defined by the following algorithm:
A (I,J)
1 IF I=J
N
A(I,)) =0 IF I<>J
For the IDN assignment to be valid, the matrix A must be two-dimen-
sional and the number of columns must equal the number of rows
(i.e., A must be a square matrix).
6-2
Examples
200 MAT V = CON
sets elements of matrix V to all ones
300 MAT Z = ZER
sets elements of matrix Z to all zeroes
340 DIM I = (4,4)
400 MAT I = IDN
sets matrix I to the identity matrix |
Elements of the matrix defined by matrix I
are assigned as follows:
Row Colum 1 2 3 4
1 = 1 0 0 0
2 = 0 1 0 0
3 = 0 0 1 0
4 = 0 0 0 1
MATRIX INITIALIZATION WITH REDIMENSIONING
Matrices may also be redimensioned in the MAT...CON, MAT...ZER
or MAT...IDN statments.
MAT A = CON (Bl)
or
MAT A = CON (Bl, B2)
or
MAT A = ZER (Bl)
OT
MAT A = ZER (Bl, B2)
or
MAT А = ПЖ (Bl, Bl)
where A 1s a numeric matrix and Bl and B2 are expressions which
define a matrix bound.
These matrix initialization statements set the matrix to the left
of the = to a constant matrix having the bounds specified by Bl
and B2; and in addition, assign values to the elements of the
matrix defined by matrix A according to the functions of the
specified MAT...ZER..., MAT...CON, and MAT...IDN statement.
les
20 DIM X(4,5)
30 MAT X = CON (3,3)
Xis 1 1 1
60 DIM Y(3,3)
70 MAT Y = Z ER (4,2)
Yi 0 0
0 0
0 0
0 0
6-4
MATRIX ASSIGNMENT
A matrix may be assigned the value of another matrix.
Syntax
MAT A=B
where A and B are numeric matrices.
Both A and B must be either both one-dimensional (vectors) or both
two-dimensional (matrices).
The matrix assignment statement sets the matrix appearing to the
left of the = to the value of the matrix appearing to the right of
the =. The current bounds of the target matrix are charged to the
assigned matrix.
Examples
10 DIMA (6,6)
20 DIM B (5,4)
30 МАТ А = В
the assignment at statement 30 is a legal assignment; but
ran Y
15 DIM C - (10, 10)
25 DIMD - (2, 10)
35 MATD =C
is not legal since the effect of the assignment is to try and
assign a larger storage area, (matrix C) into the smaller one
(matrix D) which would be charged with 80 more locations than were
originally allocated.
MATRIX ADDITION
Syntax
MAT A = B + C
where A, B, and C must all be either numeric vectors or numeric
matrices. The elements of A are set to the sum of the corresponding
elements of B and C. The matrices B and C must have the same current
bounds; the bounds of the target matrix A are changed to the bounds
of the input matrices (B and C).
le
100 MAT X
Y + 2
220 MAT Y
X +Z
6-5
MATRIX SUBTRACTION
Syntax
MAT А = В - С
where A, В, and C must all be either numeric vectors or numeric
matrices. The matrix elements of A is set to the difference of
the corresponding elements B and C. B and C must have the same
current bounds, and the bounds of A are set to the current
bounds of B and C.
Example
142 МАТ Х = Y - Z
MATRIX MULTIPLICATION
Matrix elements may be multiplied by scalar quantities or by elements
of another matrix.
SCALAR MULTIPLICATION
Syntax
МАТ А = (Е) * В
where A and B are numeric matrices and E is a numeric scalar expres-
sion.
This form of matrix multiplication sets the matrix A to the value
of the product of each element of B times the value specified by E.
Matrices A and B must have the same number of dimensions. The current
bounds of A are changed to the current bounds of B.
Examples
300 MAT X (5) *Y
(SQR(1-X/Y)) * B
320 MAT X
6-6
PRODUCTS OF MATRICES
Syntax
MT X = Y * Z
X, Y, and Z are numeric two-dimensional matrices.
This form of matrix multiplication sets the matrix A to products
of the matrices to the right of the =.
When two matrices are multiplied, the number of rows in the first
matrix must equal the number of columns in the second matrix; the
result is a matrix with the same number of columns as the first
matrix and the same number of rows as the second matrix.
Examples
10 DIM (10, 10)
(4, 5)
A
20 DIM B
30 DIM C (3, 3)
A
*
В ый
1 AN т mm
ему DAL - X u
NOTE: While the statements of the form:
MAT А = А + В
MAT А = А - В
are allowed, the statement:
MAT А = А * В
causes ап error when the program is rum.
6-7
TRANSPOSE OPERATIONS
Syntax
MAT A = TRN (B)
where A and B are either both numeric one-dimensional matrices or
both numeric two-dimensional matrices.
To transpose statement sets the matrix A to the transpose of matrix
B; the columns (rows) of A are the rows (colums) of B. The current
bounds of A are changed. For example, if B is dimensioned M, N, the
bounds of A are changed to N, M.
Example:
100 DIM B (5, 4)
110 MAT A = TRN (В)
A would be a matrix, the same as if it were fined by the statement:
MAT A = INV (B)
where A is a two-dimensional numeric matrix and B is a square two-
dimensional numeric matrix.
The matrix A is set to the inverse of B. The bounds of A are set
to the bounds of B.
Note that the statement:
A = INV(A)
1s allowed by the Prime BASIC.
MAT READ
The MAT READ statement causes an entire matrix to be read (input).
Syntax
MAT READ Al (Dl, D2) ..., An (Dn, Dn)
where Al ..., An are a list of numeric or string matrix names
separated by commas, and D1 ... Dn are dimensions of the associated
specified matrices. Specifying of dimensions D1 ... Dn are optional.
6-8
The MAT READ statement causes values from the data pool starting
at the next available values, to be assigned, in order, to the matrix
elements of the matrices specified.
Enough data values are read from the data pool to fill a matrix
according to the current bounds of the matrix. If a matrix name
in the MAT READ statement is followed by a bound list, the matrix
is redimensioned to those bounds before any data is read.
Example
10 DIM A (3,5)
50 MAT A = ZER
100 MAT READ A
200 DATA 1, 2, 3, 4, 5, 6, 7, 8, 9
210 DATA 10, 11, 12, 13, 14, 15
The statement at line 100 causes fifteen numbers to be read into
matrix A by colums. For example: A(1,1) = 1; À (2,1) = 2, etc.
MAT READ FILE
The MAT READ statement causes a matrix to be read from an external
data file and assigned, in order, to the matrix elements of the
matrix specified.
Syntax
MAT READ #N, Al,..., An
where N 1s a file number (1-8) previously defined in a DEFINE FILE
statement, and Al,...,An is a list of matrix names.
The file N consists of an ordered list of values that defines the
contents of the elements of the matrix A. It may be created by a
previous MAT WRITE FILE statement in the same or a previosuly
executed program, or it may be created by the operating system
editor.
6-9
Example:
10 DIM V(10)
15 DEFINE FILE #1 = ' (PTR)'
20 DIM M(10, 20)
25 DEFINE FILE #2 = 'ARRAY'
30 MAT READ #1, V
40 MAT READ #2, M
The contents of the file #1 are read from the paper tape reader and
assigned to the elements of the vector V. The contents of the file
named ARRAY stored on the disk are read and assigned to the elements
of matrix M.
MAT READ * FILE
Same as MAT READ file except the statement does not force a new
record to be read. Any data remaining in a previous record are read
as elements of the matrix.
MAT WRITE FILE
The MAT WRITE FILE statements causes a matrix to be written to an
external data file.
Syntax
MAT WRITE #N, AL, ..., An
where N is a file number (1-8) previously defined in a DEFINE FILE
statement. If the output file is in ASCII (print) format, the
character following matrix names in MAT WRITE FILE statements is
used to control the spacing of the matrix elements in the output
records. A comma specifies tabbed format and a colon specifies
packed format. The optional character following the last matrix
name controls the spacing of the elements of that last matrix and
does not inhibit the termination of the last output read. Al, ..., An
is a list of matrix names.
6-10
Example:
10 DEFINE FILE #1 = 'OUTPUT'
15 DIM A (100)
20 FOR X = 1 TO 100
25 X = 2#3.1416
30 A(K) = X*K
40 NEXT K
50 MAT WRITE #1, A
MAT INPUT
The MAT INPUT statement causes data values to be read from the
terminal and assigned, in order, to the elements of a specified
matrix.
Syntax
MAT INPUT Al, ..., An
where Al, ..., An is a list of matrix names separated by commas. The
type of data provided must match the type of matrix being filled.
Example
10 DIM B (5)
20 MAT INPUT B
allows information to be assigned to the elements of matrix B from
the terminal. After the ! is printed, typing:
5, 10, 15, 20, 25
assigns those values to B(1) through B(5).
6-11
MAT PRINT STATEMENT
This statement causes an entire matrix to be printed.
Syntax
MAT PRINT Al, ..., An
where Al, ..., An is a list of matrix names separated by commas or
colons.
The MAT PRINT statement causes all the elements of a matrix with
subscripts that are not 0 to be printed colum by column.
If a matrix name is followed by a colon, elements are printed with
one space; otherwise, elements are printed in zoned format.
Example
100 DIM M(2,6)
110 MAT READ M
120 MAT PRINT M
200 DATA 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
400 END
The above program yields the following output:
1 2 3 4 5
6 7 8 8 10
6-12
SECTION 7
INTERFACE CONVENTIONS
BASIC differs from compiler and assembly languages because its inter-
preter does not compile or assemble a reusable object text from the
source program. Therefore, the BASIC interpreter must be present
in high speed memory each time a user program is run. However, Prime
BASIC provides the CALL statement to call FORTRAN or PMA (macro-
assembly language) subroutines. Refer to Section 5 for details of the
CALL statement format.
RELATING CALL TO SUBROUTINE
The user-supplied configuration file that is associated with the BASIC
CALL statement is a table. The entries to this table are the addresses
of PMA assembly language object text subroutines, or FORTRAN
language object text subroutines, or a combination of both PMA and
object text subroutines.
An example of two typical subroutines that may be called by a program
written in BASIC is as follows:
+ SUBROUTINE TO START CLOCK
+
+
+:
ENT STRICE
FEL
+
STRTCE DAC жа
CRA
=TA “El
ОСР “Ze START CLOCK
IMP: STRTCE
END
/
С SUBROUTINE TO GET REAL TIME CLOCK WORD
С
С
SUBROUTINE GETCLECHREG
COMMON LIST LISTO
С
ARG=LISTC20 613
RETURN
END
The configuration file is produced by modifying the CALLP source
file on the MFD then assembling it. The following listing is the
original source of the CALLP subroutine; immediately following that,
is a listing that shows how the CALLP source was modified to call one
PMA subroutine to start the real-time clock and one FORTRAN subroutine
to get the real-time clock word.
CALLA CEASICLi TRA¡ANSLTES + JAR "a
ed A A
+: +
+ CALL PROCESZON +
+ +
AAA AA EA
m= LL SUBROUTINE NUMBER IN GUF(13, ADDRESS OF ARGS IN BUF (ID).
ELECT... BUFCHI. CM THE HUMBER OR ARGS:
SUBR CALLP, MALL.
REL
+
+
EINSERT PCORON
+
+
CALL DAC E
LIA ELF
DR
НОР
IMP CALL: 41
ZA ЗАНЯВ CFAILL LOCHTIONS.
CALI IMP i
IMF ce
IMF cz
IMP =
IMP =
ЛИР Сиб
ИР Gr
IMP ce
IMP a
4————CEFALNLT SUBROLITINE CALLS
7-2
UT LA UN LA UV UT LA
DHHS LR
M
4
\`
=
mo
3
JHE
IMF
IMF
МР
МР
МР
JME
МР
МР
HLL
DAC
END
CALZ
CAL:
CALZ
CAL:
CALS
CALI
CAL:
Lie
CHL =
LI MPLEMENTED
RERROR
=C‘EC-”
SUEROUT IE
7-3
The "Modified" CALLP follows:
CRLLP XEASICi TRARSL TAS <4 JAM 74
Eee a AE EA
+ 4:
+: CALL PROCESSOR +
++ “fs
HER ER HERR HR HERR HER HM EHE
CL SUBROUTINE HUMBER IN EBUFL, FALDRESS OF ARS IM EUF CZ 15
ESE IA, 111 à Li CMS, did THE HUPRGCE OR ARGS
SHER TRL LFS CELL
REL
+
+
EINSERT FCOMON
+
4
CALL LAC же
Гб СИЕ
СЕК
HOF
IMP CALL. 3.
cesT RAITT INE CALL LCHZFIT LH,
RL IMF" SL
IMP e
IMP Ts
IMP +
IMF SE
IMF TE
ЛИР ST
INP e
ЛИР а
47
de — DEFAULT SUBROUTINE ALL,
7-4
1 CALL STRICE
Jr CALL
= LEA ELIF +1
GIF
er
SMF CAL:
CALL GETCLE
НЯ ЕН +2
IMP CALL
МР CHILE
МР CALI
JF CALE
ИР CHILE
JHE CALZ
МР CALZ
JME CHLZ
$ UY LY E LT LA UI AN +
(5 20 1 01 EN Le LA
4————UNIMPLEMENTED
CALZ CALL RERROF
DAC =C "BC"
+
END
START CLOCK
RETURN
IMGURE 1 ARGUMENT
MOT 1 ARG, ERROR
1 ARG
SUBROITIRE CALL.
7-5
MODIFYING COMMAND FILE
The source of the modified CALLP listed above is assembled. Then, the
command file must be modified. Depending on which version of BASIC
the user desires to use, one of the following command files must be
modified:
C €- BASC *BASIC with no PRINT USING
OR MAT statements
C 4— BUSE *BASIC with PRINT USING
statement
C €- BMAT *BASIC with MAT statements
C «BALL *BASIC with both PRINT USING
and MAT statements
Any or all of the above command files are modified using the editor,
ED, as follows:
1. Locate the command line:
LOAD B<€ CALL
2. Insert LOAD commands for the subroutines to be called by
the program(s) written in BASIC. For example, to call
the subroutines listed in the sample modification of the
CALLP subroutine, the following statements are inserted:
LOAD B<— SIRT
LOAD B€— GTCLK
NOTE: The above 'LOAD' is a command to the DOS/DOS-VM loader;
not to be confused with the BASIC command of the same
name.
7-6
RUNNING PROGRAM WITH CALL STATEMENTS
After inserting the proper LOAD commands, execute the command file
and save the results (see the Program Development Software User
Guide). At this time, the desired version of BASIC, the modified
CALLP subroutine, and the called subroutines are loaded as an entity
so that programs written in BASIC may call the designated subroutines.
For example, the following program starts the real-time clock and
prints a clock value every 300 microseconds.
>LIST
18 CALL 1
28 1=308
39 CALL _2(J>
48 1r I<>J GOTO 38
58 PRINT I,
68 1I=1+308
78 “GOTO 38
Sample Output:
> RUN
388 698 988 1288 1599
1800 2100 2498 2708 3988
>
7-7
APPENDIX A
SAMPLE —..JGRAMS
9 RAM Fea ELE 1. he
28 REM
a REM PROGRAM TO CALCULATE MILES FER GALLON AMC PRINT REPORT 0
40 REM gee
и REN THIS PROGRAM GIVES ВЫ ЕХРМРЕЖСВР НОМ п введен” wim,
Sa REN DATA AD DOS THFLE | JL ET TORHS РН, Ц SE RE TTT
Fil Lol
Pa REM STATEMENT TE. EME POR
20 REM er
26 REM IT IS MER TE GIVE THE ok
REM soe fi PEGELEM wd La
REM: ET STATE, 1 , A
y Æ ee a ya USED ARE: |
Em dés SET CASSTONMEMTS, PRIMT. AMD CATA
PRES BETES ODOMETER. "MILES". "GALLONS, МР
FEM ROM THITIAL IZING SOME VER IABLES USED LATER.
LET ML
LET Mi=
LET.Cii=
i. ET EF ig
REAC E |
REM к 1% ODE METER REFINE,
LET Ki= к
GEM EL IS SET TO ORIGINAL ODOMETER REF ING.
ВЕРЮ My |
FEM MOIS SET TO LATER ODOMETER READINGS
EM HIS ALSO USED AS A FLAG TO TERMINATE LOOP.
Л
.
EA
4
В
Mm e
1
=
A.
ie
A.
SO A
7 wa
1-0
He pe pein Bp pe Ro
Ti
vu #5
E
fs - pt Tu УЗ НЫ =
=“ E se LA x 4
Ta а,
ls “
2 MY
+ PF, *, Fi - Fai" A" 7
1 13 AY hd RY OD
a
q
nu 1
: 1
AF,
à 4 à 0 45
x
2060 REM STATEMENT 148 IS EMTRY IMTOO LOGE.
SOS IF M=6 THEM 456
лей FEM UHEHM NCIS € LOOP CONTIMUES.
218 КЕНО D
326 REM DC IS DATE,
== REF OG
T4 REM OGG IS GALLONS USED SINCE LAST COMETER READIRG.
ЛЕ ВЕТ M=H-K |
ЗЕ REM MO LS THOREMEMT OF TOTAL MILAGE.
276 Mi=P1i-+M
IES OREM ML IS RUNNING TOTAL OF MILES
A-1
SE LET As"
ЯНОВ СРО OF MILES PER OL CP,
GA PRINT С. М, М, С, А
$1 LET fe}
438 REM UPDATES K TO LAST ODOMETER
de LET CSS
БО ВЕР: 5 TOTAL. GALLOHZ
Genk GOTO SEE
STE RM CORT THLE LOGP UNTIL
e
Si FREINT TOTER. “a PELA LG La
Tu REA MITE ОБЕ OP ze
SEE DATA $5885, $6195
Бай DATA T1574. 15. £ 45715
Sam DATA 22274. 3 4. 45506
SIG DATA EEi74. 1.2 7. 45055
Sadi CATA GS da LE a0 TERT
558 DATA 31574, 1.5 20 47314
Sal DATA 22274, 14 Ta 47454
ma DATA CS Sd EL E El
=o HTH E
ео СИР
The following is the output from Example 1:
LOAD "EXAMPI! —.
DATE — ODOMETER MILES
21574 46195 311
22274 46515 - 122
50174 46505 150
30874 46855 350
31574 47067 212
S22 74 47314 247
52974 47464 150
TOTAL 1582
STOPPED AT LINE 350
TO SIP
LEO
: ÉL
E a
HE PRINT FIELD
GALLONS
16.8
9.4
12.7
17.6
15.2
14.7
10.6
557
E ELE
MPG
18.5119
12,9787
14.9606
19.8864
13.9474
16.8027
14,1509
16.3093
16 Feb debas ESFMFLE = e
ek REM
Зв RUM THE FOLLOWING STATEMENTS ARE A MODIFICATION OP EXAMPLE 1
46 REM TO ALLOLM DATA TO BE READ FROM AOFILE RATHER THAM DATA
Sa REM STATEMENT.
e RE
CF IREF ILLES d="0GHZDAT
PRINT “DATE. "ODOMETER, “MILES, "GALLONS, "MILESASGRLLGN
LET Mi=6
LET Hi=
LET Де
НЕТ кн
LET K=45 202
REI MUST SET INITIAL VALUE OP E E НАМ,
REM OF ROAD IT IX FROM ANCOTHER FILE TC PECYENT RECORD FROM BEING
REM DISCARDED
LET KL=E
REF 1. Hd. D, 1
REN ALL ITEMS MUST EC READ OF REST OF RECORD IS DISCARDED
IF H=A THEN E
LET M=H-E
Mi=M1+M
LET АМ.
PRINT 0, М, М, Б.Н
LET E=H
LET Gi=014G
1 Là 1
2
= = le Fou
NE LA BEE La 1 Mm, Ty Tu:
ро "a ра 1 ai Poio
Fa ,
e? pe
Ti
ra т
"a
ho) Ch 0 4
т Td
мот
: Wi Lil
To 7
te "lo
ORI la La A ja a A e A a a
TD DS AS AA
ET...
AAN
GOTO 166
PRINT “TOTAL”, 7 “7, H1, Gd, CE-K1 501
STUFF
DO EEN
fa PU
The following is a sample of the output from Example 2. The results are
similar to Example 1 and are included for comparison.
LOAD "EXAMP2”
RUN
DATE ODOMETER MILES GALLONS MILES/GALLON
21574
22274
30174
30874
31574
32274
32974
TOTAL
46193 Sil 16.8 18.5115
46515 122 9.4 12.9781
46505 150 12.7 14.9606
46855 350 17.6 19.8864
47067 212 15.2 15.9474
47314 241 14.7 16.8027
47464 150 10.6 14.1509
1582 57 16.3093
~ STOPPED AT LINE 350
A-3
5
14
15
29
=S
36
35
+5
+5
Sg
25
50
és
a
=
rad
a
DS
a
25
196
195
119
115
179
4 E
E
138
135
148
145
150
155
168
165
170
175
189
165
156
REM
REM
REM
REM
hi: M
REM
REM
REM
RUM
REM
REM
REM
REM
REM
déguste ESAMPLE kk:
THIS PROGRAM CALCULATES THE FACTORS OF A POSITIVE
INTEGER BETWEEN 1 AND 9999959 INCLUSIVE.
IF THE NUMBER HAS HO FACTORS. A MESSAGE IS RETURNED
THAT THE MUMBER IZ PRIME CHECKING IS MADE FOR SOME
SPECIAL CASES.
THE PROGRAM SHOWS THE US OF GOSUE AMD RETURN STATEMENTS
TO PRODUCE BOTH NESTED ANC SEGUENTIAL SUGROUTINES
IN A PROGRAM. IT ALSO DEMONSTRATES THE USE OF THE PRINT
AND THE INPUT STATEMENTS TO PRODUCE AN INTERACTIVE COM-
VERSATIONAL FROGRARM.
FRINT “PLEASE TYPE YOUR NUMBER: 7:
INFUT A
LET P=1
LE
оо
я ==
LET H=1
Fim
H THITIALIZING FLAGS
GOSUB 375
GOSUE 356
PRINT “IS THIS YOUR LAST NUMBER: *:
INFUT AS
IF ASC vES” THEN 75
END
REM
REM
AAA END OF MAIN PROGRAM.
SUBROUTINE TO CHECK IF À IS NOT AN INTEGER.
IF A=INT{A> THEN 1&8
PRINT “HUMBER MUST BE AM INTEGER. -
GOSUE Sia
RETURN
KEM
SUBROUTINE RETURNS MESSAGE IF A > 999995
IF A{=932293 THEM 1&5
PRINT “SORRY, AT PRESENT, HUMEER MAT MOT EXCEED заза. 7
GUSUE S80
RETURH
КСМ
SUBROUTINE ТО НАНОБЕ А = 1
495 IF AC41 THEN 245
2860 PRINT A:“15 1 AND OIS CIVISIBLE BY ONLY ITSELF AMD 1.7
265 PRINT “HOWEVER, IT IS HOT À PRIME NUMBER. “
716 GOSUE 506
215 RETURN
278 WEM SUGROUTINME TO CHECK IF À IS 6 OF NEGATIVE.
225 IF A>=1 THEH 245
276 PRINT “HUMBER MAY NOT BE EITHER ZERO OR A NEGATIVE VALUE. -
отб PRINT “YOUR HUMBER FA: IS INVALID. |
246 GOSUEB 586
245 RETURN
259 REM SUBROUTINE TO HANDLE A = 2.1.
255 IF ASI THEN 1F AC GOTO 274
259 GOSUE 256
265 GOSUE S00
278 RETURN |
275 REM SUEROUTINE TO PRINT HERDER LINE.
288 IF F=1 THEN 316 -
205 IF H=G THEN 318
228 PRINT “NUMBER” .A:7IS GIVISIBLE 6: 7
себ PRINT
zas FRINT A, CANDO. 107 727 “. 7 ~
205 LET H=0
316 RETURN
245 KEM SUBROUTINE THAT PRINTS DIVISORS AHD QUOTIENTS
=268 IF P=1 THEN 345
325 PRINT 3, AMD, Ga, 7 0° °°
IF XI THEN 345
PRINT “17. "AND", A
rT NT
rr ited
RETURN
KEM SUBROUTINE TO PRINT MESSAGE WHEN NUMBER IS A PRIME
IF P=6 THEN 37
PRINT “NUMBER” :A:/IS A PRIME NUMBER. ‘
PRINT
RETURN
KEM PERFORM CALCULATION AND GET ROUTINES TO PRINT RESULTS
IF 5=8 THEN 426
A-5
305 FÜR *=INTCA 22 TO << TER —À
358 LET =f
225 LET G=S=IMTIH-550
ФНО LET R= AZ
495 GOSUE 426
418 HEXT =
$15 GOSUE cris
320 RETURN
425 REM CALL PRINT ROUTINES ЕТС.
320 IF RIE THEN 456
475 LET P=4d
3430 GOLUB 275
$45 GOGUE 215
458 RETURN
45% KEM SUERCOUTINE TO ENTER SFECIAL ROUTINES.
456 FEM IF A IS HEGATIVE OR ZERO, OR 1.3.5, OF IF A IS A FRACTION
255 GUSLIE 146
379 QOSUE 155
375 IF ASE THEN +15
3209 MOLE 116
465 GOSUE 229
4009 GUISE 258
+55 KETURE
S88 FRINT
sas LET <=
S19 KRETLIRM
The following is same sample output from Example 3.
LOAD "EXAMP3"
RUN
PLEASE TYPE YOUR NUMBER: O
NUMBER MAY NOT BE EITHER ZERO OR A NEGATIVE VALUE.
YOUR NUMBER O IS INVALID.
IS THIS YOUR LAST NUMBER: NO
PLEASE TYPE YOUR NUMBER: |
1 IS 1 AND IS DIVISIBLE BY ONLY ITSELF AND 1.
HOWEVER, IT IS NOT A PRIME NUMBER.
IS THIS YOUR LAST NUMBER: NO
PLEASE TYPE YOUR NUMBER: 2
NUMBER 2 IS A PRIME NUMBER.
A-6
Sample output from Example 3 (cont)
IS THIS YOUR LAST NUMBER: NO
PLEASE TYPE YOUR NUMBER: 4
NUMBER 4 IS DIVISIBLE BY:
4 AND l
2 AND 2
1 AND 4
IS THIS YOUR LAST NUMBER: NO
PLEASE TYPE YOUR NUMBER: 17
NUMBER 17 IS A PRIME NUMBER.
IS THIS YOUR LAST NUMBER: NO
PLEASE TYPE YOUR NUMBER: 324567350123456783
SORRY, AT PRESENT, NUMBER MAY NOT EXCEED 999999.
PLEASE TYPE YOUR NUMBER: 56
NUMBER 56 IS DIVISIBLE BY:
26 AND l
28 AND 2
14 AND 4
3 AND 7
7 AND 3
4 AND 14
2 AND 28
1 AND 26
IS THIS YOUR LAST NUMBER: YES
END AT LINE 230
100
118
120
138
149
159
1668
179
1093
198
288
218
229
225
238
248
254
260
278
260
Z3a
388
316
311
320
330
248
341
342
359
351
352
369
a
3298
REM +44:4:6 EXAMPLE 4 Ae
REM
KEM THIS PROGRAM USES THE ARRAY PROCESSING CAPAEILITIES
REM OF BASIC TO COMPUTE THE TOTAL DOLLAR VALUE OF THREE
REM FRODUCTS SOLD BY FIVE SALESMEN.
REM
REM VECTOR ELEMENT PMY IS THE PRICE OF THE N-TH PRODUCT.
REM MATRIX ELEMENT SIM. MY IS THE TOTAL HUMBER OF THE M-TH
REM PRODUCT SOLO E THE HN-TH SALESMAN.
REM
REM
DIM Só, 45
DIM Pega
T=8
MAT F= CON
MAT S= ZER
READ P<153,FC253,F<Z3
READ Si. 132.501, 22,51, 39, 5212, 52. 21, 502, 31
READ SE 19, SL 2): SLI 3), 54, 19, 524, 29, DU, 3)
READ Sc: 19, 5 2), 502, 3)
FOR I=1 TO $
FOR J=1 TO 3
SCI. I2=P{J545%(1, I>
T=5C01, JI+T
PRINT I:J, SCI, J)
NEXT J
NEXT I
PRINT
PRINT
MATPRINT =
PRINT
PRINT
DATA 1. 23,2 54.5.
“TOTAL SALES =":T
43
DATA 47. 24. 16, 595, 38, 12, 76, 23, 14, V5, 45, 12, 45, 24, 23
STOP
A-8
The following is sample output from Example 4.
60,63
50.56
37,68
12.24
56.52
63,76
93. Ja
25.42
16. 1€
93.04
114.5
62. 16
53.05
36.36
126.04
12.24 98.04 93.04
69.96 56.02 28.42
86.56 О 37.68 65,168
62. 16 126.04 0
9 О |
es DO == AD N m N NN =
CQ VIE bb OCG NED
.
O
с
TOTAL SALES = 1225.52
STOPPED AT Linz 38J
А-9
58.05
114.5
76.12
16363
11a
1263
13
146
156
168
178
те
13
3
216
ZZ
=
=
=
LL
27
"
=
a
HG
216
ia
238
2463
АЗИЗ
360
=
:
эй г
Tr
Cw
390
400
416
420
478
440
450
368
478
+29
4928
598
519
НОМ жанна ESAMPLE 5 AA
REM
REM MULTIFLE PLOT PREG
REM
REM
DEF FHFOHSY=S 103
DEF FRG =LOG SLOG oles
RER À В, =
ВЕРНО ©, В, N
LET H=C0-C1.A
IF HI=58 THEN 27230
PRINT 7 ORLY S5 SUEDIVISIONS HALLOUED ON Y-AXIS”
STOF
Def FHECHIOSIMTH+ SO
PRINT “WRT: FROM CTO <a: IM STEPS OF
PRINT
[= ти
FOR 1=1 TO H-1
LE=L $+" ~~
MET I
PRINT LI..."
FOR X= TO В STEF S
LET Y=FHF {EY
LET Yi=FHRCU7-C."H7
LET Y=FHGX 5
LET YZ2=FHR OC Y-Ca."H3
|=
FOR I=0 TO M
IF I=%1 THEM 420
IF I=%2 THEM 436
LE=L +" 7
GOTO 454
= + тж”
GOTO 456
LE=LE+" ~
MET 1
PRINT L$+- TA
МЕХТ A
DATA 1,148, =
DATA -1. 41,560
CATA 9
STOP
A-10
НН
OF 4E-02
TERS
F
ach
Ir
1
The following is sample output from Example 5.
TORE HE OOOO NG) 0) a
OOOO OOO GOGO OOO
о AAA AY AA E
помола
AD A RL EME UY ©) + Mm
Add A AMA м то Ч оно
+ | + ++
0% EE + + +
+ +
+ + +
и + + +
aj. + we <
+ +
> +
+ E LA]
“e + +
le
+
+
+
“= on
>
+ «=
ie
+
“> =
+ =
+
>
+ wl
>
+ =
A-11
163
1146
1=6
130
149
159
15.9
ire
LE
196
„ИЯ
216
==
«LE
LEP ech EXAMPLE ©
FEM FIEOHFICOOI HUMCER
КЕМ
INPUT E
I=1
—
FRINT Г. т,
Fok K=1 TO Е
Р = 1 +.7
I=1
J=F
FRINT F,
HEXT К
END
Sample output:
120
l
15
144
1297
17711
Vo fo
(0 Го Сы +
Oo UI
Vi DS
=
END AT LINE 230
Mei da ds
DEHERATÜR.
54
377
4151
A-12
55
619
5765
89
387
13546
166
118
120
138
149
156
150
178
158
196
oi
216
228
es
2446
256
268
“эт
|
288
258
зав
318
32a
356
=46
356
60
58
зав
dot
416
4268
+30
448
450
456
370
486
438
Sag
51a
S26
538
S48
S50
560
S78
Sg
РЕМ ek EXAMPLE 7 duda
REM
REM LURAR LANDING PROGRAM
rene
RLY
PRINT
PRINT “CONTROL CALL LUNAR MODULE. MANUAL CONTROL IS NECESSARY. 7
PRINT YOU MAY RESET FUEL RATE K EACH 16 SECS TO 6 OR ANT VALUE"
PRINT “BETWEEN © & 2800 LES 5EC. YOUVE 150860 LES. FUEL. ESTIMMATEC
FRINT “FREE-FALL IMPACT TIME = 120 SECS. CAPSULE WEIGHT = 32568 LES”
c= 4UH4 HHRR НН —---#. ### RUHRÁ HEHE"
PRINT “FIRST RADAR CHECK COMING UP. -
PRINT
PRINT
FRINT
PRINT “COMMERCE LANDING PROCEDURES
PRINT
PRINT “TIME ABLTITUCE . “VELOCITY, “FUEL LBS", "FUEL RATE"
PRINT “SECS MILES FEET. HFH-
PRINT
L=6
H=126
Wi
M= 325066
H= 16560
G=1E-9%
e=i. 5
FRINTUSIHG BE. LL, INTAY INT(SZ204(A-THNT CAD 2 0, сое, М-Н,
PRINT “K=" :
IMFUT K
T=19
ON SONCKI+2 GOTO 40, 450, 418
IF KL GOTO 4238
IF K<=200 GOTO 466
PRINT “MOT FOSSIELE-
PRINT TABISG)
GOTO 378
IF M-HZ1E-9: GOTO Sir
IF T<iE-9: GOTO Zag
S=T |
1F CH+SHROA=M GOTO S18
S=UMN-HIK
GOZUE 1028
IF I<{=8 GOTO 268
IF Y<=9 GOTO 556
IF J<8 GOTO 956
GOSUB 846
GOTO 468
PRINT “FUEL OUT AT“:L:‘SECS-“
== VA SER EA IRA) IG
A-13
508
ELO
628
639
£48
ESO
¿oO
67
686
E96
790
718
728
738
748
758
768
770
798
ses
s16
520
az
848
850
250
876
320
858
366
310
320
338
338
359
366
378
580
396
1660
1818
1820
1978
1840
1856
1669
1879
1666
1636
1196
1110
1126
1136
L=L+5
FRINT “OM THE MOGN AT :L: SECS”
W= 36004:
PRINT "IMPACT VELOCITY OF 7 WM: “MPH”
PRINT “FUEL LEFT IS”: M-N:"LEZ”
IF W>1 GOTO “29
FRINT “PERFECT LANDING!-
GOTO 729
IF W>19g GOTO 718
PRINT “GUDO LANCING-
GOTO 756
IF N>25 GOTO 748
FRIMT "FOOR LANDING”
GOTO 758
IF N>58 GUTO 776
PRINT “CRAFT DAMAGED;
GOTO 786
PRINT “FATAL CR
PRINT
PRINT “TRY AGAIN?"
[МРОТ А
IF AS="YES" GOTO
IF AF="NO" THEN
GOTO 796
LsL+5
T=T-5
M=p— Sai
A=1
>
RETURN
IF SS c-82 GOTO ¿ig
SEAS VFSOR OVER F 20A# (G- 24K AMY 3D
GOSUE 1826
GOSUE 240
GOTO 2088
W=01-MeGACS4K DD 2 12
S=MAEV ASHE WH SOR (WW HY A222 XD + SE~-82
GOSUE 190-290
ri SONCID+2 GOTO 3599, “66, 928
GOSUE 244
O SORNCZII+2 GOTO 1018, 466, 459
ON >GNCYI2+2 GOTO 469, 368, 956
= KAUM
G1=03
FOR Q2=2 TO 1
Gll=Q+ {1 Q2Z2+G1>
NEXT Q2
J=Y+G45- 741
Gil =a
FOR Q2=7 TO 1 STEP —-1
Q1=C4C0O1+1.°C0O24%CO244 551
HEAT Q2
DER GR SS 2-4 Z4 SAL
RETURN
GOOD LUCK TO
SH; MO SURVIVORS
266
STOP
STEP -1
A-14
OLI AND
THE RED
SON. -
Sample output from Example 7.
COMMENCE LANDING PROCE!
10
29
Su
49
29
60
70
80
su
100
119
120
159
140
153
160
179
130
190
ON THE MOON AT 193,354 SECS
ALTITUDE
MILES FEET
120 О
199 5915
99 4223
39 2503
79 1055
63 3959
58 1955
47 2903
37 1929
28 1384
2 1706
15 $599
8 1772
4 2795
2 2013
| 1429
J 2943
J 1364
J 577
0 47
VELOCITY
MPH
SSUV .LUVV
3656.90)
3672.900
3 703,000
5744.000
313U.U00
322,009
54156.45
5972,949
2637.460
2184,970
1649,140
1981.920U
452.719
347.074
164.626
29.795
26.436
15.310
IMPACT VELOCITY OF .313765 MPH
FUEL LEFT
IS 245,219 LBS
PERFECT LANDING!
A-15
FUEL (LBS)
16000,009
| GUVV .UVO-
16000,J00
1 6000.,000
16999.90)
1 6090.09)
16000, 0U0
16000.00J
14900,00U
129UJ.UVO
1JJJJ., 00
SUIVI .UUU
GUIV UV
AUIV VVUV
2900300
1609.990
1033.90
699.999
220,093
520,099
FUEL RATE
K= 19
K= 19
К= 10
K= 10
Kz 10
K= 10
Kz 19
K= 1200
A= 1200
Kz 1200
A= 1200
K= 1200
K= 1209
Kz 1200
K= 140
K= 169
K= 140
K= 18
R= 129
K= 119,4
18 WEM 44:46:46 EXAMPLE 2 ds fe che perde
28 REM
36 REM THIS PROGRAM SEARCHES A DATA FILE COMSISTING OF
48 REM STRING ITEMS AND RETURNS THE LINE (RECORD SEQUENRCED
Sa REM NUMBER THAT DEFINES THE LOCATION OF THE STRINGS).
58 REM
78 FRINT "ENTER FILENAME".
a8 INPUT FS
26 DEFINEFILES 1=F%
188 PRINT “ENTER STRING”,
116 INPUT 53
111 C=1
128 IF Ski="NO MORE” THEN 25609
138 REARD# 1, Ei
148 FOR I=1 TO LENCES>
158 IF E4="EOT" THEN 290
159 IF 623=34 THEM 256
178 IH S$=SUG<BS. I. LEM(S5)3 THEM 250
171 C=C+1
139 NEXT I
196 IF B3<25$ THEN 136
29038 PRINT 5%: “HOT FOUND.
218 REWIRD# 1
228 GOTO 180
238 PRINT S$: “FOUND AT CHARACTER POSITION :C: 7. ~
248 REWIND# 1
258 GOTO 166
269 END
Output from Example 8.
>RUN
ENTER FILEÑNAME I SOURCE
ENTER STRING ¡GORGE
GOrGE FOUND AT CHARACTER POSITION 63
ENTER STRING 1AARDVAARK
AARDVAARK FOUND AT CHARACTER POSITION |
ENTER STRING !SYZYaY
SYZYGY FOUND AT CHARACTER POSITION 783
ENTER STRING IXXXX
XAXX NOT FOUND.
ENTER STRING lADZe
ADZE FOUND AT CHARACTER PUSITION 19
ENTER STRING 180 MORE
END AT LINE 26U
>
A-16
19 KM added EXAMPLE € TO
12 REM
14 REM THIS PROGRAM SIMULATES AN MN DIMENSIONAL ARRAY.
16 REM
28 CGIM V(166G)
Зе INFUT Di. Dz, DS
114 FOR I1=1 TO Li
111 FOR J=1i TO De
112 FOR K=1 TO Di
115 KHeCI-1)I4D24CJ-1I4Di+K
128 vVIXKI=I424 I4+K>
136 PRINT VAI,
136 MEXT K
158 PRINT
156 NEXT J
1790 FRINT
188 NEXT 1
288 STOF
Output from Example 9.
>RUN
12; 3. 4
a 7 12 19
6 9 14 21
8 11 16 23
5 8 13 20
7 18 15 од
9 12 17 24
A-17
CODE
3 BFFIARGHE
nm um mon
S/E
tri CN 00 (0 3 ON LT LT un
Y го О Л О Л ло
APPENDIX B
ERROR MESSAGES DEFINITIONS ,
REASON
OPERAND ERROR
STORAGE SPACE EXCEEDED
(OCCURS DURING ARRAY ALLOCATION)
A( OR A$( EXPECTED (E.G. DIM A$(...,);
MAT STMT ARRAY NAME ERROR
MATRIX DIMENSIONING ERROR
MAT DIM HAS IMPROPER FORMAT
PRINT/WRITE USING EXPR/FORMAT TYPE MISMATCH
(STRING EXPR IN LIST WITH ARITH FORMAT;
OR ARITH EXPR IN LIST WITH STRING FORMAT)
STMT # + LOAD BIAS > 9999;
STMT # NOT FOUND. WHERE EXPECTED
RECORD # IN POSITION <1 OR UNIT NOT BIN DA DISK
FILE 1/0 UNIT NUMBER NOT 1-8
ILLEGAL CHARACTER
CONSTANT EXPECTED
READ/WRITE UNIT IMPROPER
CHARACTER NOT EXPECTED
V= EXPECTED (E.G. FOR I=...)
DEFINE FILE ERROR -
- RECORD SIZE SPECIFIED <2 OR >512
- NO STORAGE FOR RECORD BUFFER
~ - ERROR OPENING UNIT; DRIVER MESSAGE IS PRINTED
(NOTE: A DF ERROR CAN ALSO OCCUR ON A LOAD/FILE
STATEMENT IF OPEN ERROR OCCURS)
DEFINE FILE MODE SPECIFIER ERROR
EXPRESSION NOT OF TYPE EXPECTED
STRING EXPRESSION EXPECTED
ON END WNIT # EXPR IMPROPER |
PRINT/WRITE USING FORMAT ERROR
FOR-NEXT MATCHING ERROR
UNDEFINED PN FUNCTION
FN FUNCTION NAME NOT A-Z
STORAGE SPACE EXCEEDED
(OCCURS DURING STRING OPERATIONS OR FOR STMT)
FUNCTION NAME NOT FOLLOWED BY (
where E/S means Source (S) or Execution (E).
ERx6ZZARÉÉ
PAFONNARHLENGEE
>< О О 5
mama fiat "mon
СП сл) 00 VA VA EI CN CA CN UN UN ETS ON CM CN ITS CN) ET) CN ГО CM
CT} CO) ET) mi ti
FOR SEPARATOR ERROR
MORE THAN 10 OUTSTANDING GOSUB'S
GOTO EXPECTED i
ARRAY DIMENSION < 1
UNRECOGNIZED STATEMENT
ILLEGAL MAT MPY EXPR (E.G. MAT A=B*A)
INTEGER > 32767 |
1О EXPECTED IN POSITION STMT
EXPRESSION FORMAT
LOG ARGUMENT <= 0
READ/ INPUT LIST ERROR
DEF NOT FOLLOWED BY FNX (
MIXED MODE LET (E.G. I=A$; A$=I)
V) NOT FOUND IN DEF STMT
MIXED ARITH + STG ITEMS IN EXPR
ON EXPRESSION OUT OF RANGE |
RIGHT PARENTHESIS REQUIRED
EXPRESSION PARENTHESIS > 10 DEEP
ONLY ONE ARGUMENT IN SUB FUNCTION REFERENCE
MIXED STRING § ARITHMETIC ITEMS IN EXPRESSION
BASIC USES AS INTEGER > 32767; OCCURS IN -
SUBSCRIPT/DIMENSION
1/0 STATEMENT UNIT #
RECORD SIZE IN DEFINE FILE STMT
ON STATEMENT EXPRESSION
TAB FUNCTION ARGUMENT
SUB FUNCTION NUMERIC ARGUMENTS
SUBROUTINE # IN CALL STATEMENT
STRING CONSTANT NOT ALLOWED
ARITHMETIC OVERFLOW
EXPRESSION STACK FULL
STRING ITEM NOT ALLOWED OR ILLEGAL OP IN STRING EXPR
a:
— MATRIX NOT INVERTABLE
UNDEFINED STATEMENT NUMBER
SQR FUNCTION ARGUMENT < 0
SUBSCRIPT OUT OF RANGE OR WRONG # OF SUBSCRIPTS
UNTERMINATED STRING CONSTANT
DIVILE BY ZERO
DIVIDE BY ZERO
STORAGE SPACE FOR PROGRAM EXCEEDED
RETURN EXECUTED WITHOUT OUTSTANDING GOSUB
UNIT REFERENCED BY I/O STMT NOT DEFINED
WRITE # ERROR; DRIVER MESSAGE IS PRINTED
(ERROR IS NOT RECOVERABLE; BASIC MARKS
THE UNIT INDEFINED)
WRITE # TO UNIT DEFINED BY DEFINE READ FILE STMT
READ AFTER WRITE TO NON DA UNIT
READ/INPUT # EXCEED 10° (+/-38)
CONSTANT EXCEEDS 10-(+/-38)
SIN; COS;EXP ARGUMENT > 32767
B-2
APPENDIX C
BASIC SUMMARY
re . | |
Specification Statements:
REM Comment Line
DIM A (3), B (40,3)
DEF X(I) = 2/COS{I} *3
TRACE ON
TRACE OFF
BREAK ON 40,318,215,10
BREAK OFF 10,40
BREAK OFF
Definition Statements:
LET I3=SIN(K-4.5)+Q3
13 = SIN (X-4.5)+Q3
B$ *0001"
LET S$(J+5) = M$+D$+'.00'
Input/Output Statements:
“DATA 2,3,4, - 3.7E2
RESTORE
READ Al, A2, A3
READ #3, Al, A2, A3
DEFINE FILE #3 ='TEST 3’
DEFINE FILE #(I+3) ='(LPR)"
REWIND #3
INPUT 13, Il, X(1,3)
PRINT X4, 'FEET'
WRITE #3, X4, 'FEET'
PRINT USING F$, X1, X4
WRITE USING F$, #3, X1, X4
ON END #1 GO TO 999
Formatted Print Descriptors.
Insert Dec. Point
Insert comma if needed
ттт; Insert exponent field
+ Insert (+) or (-)
- Insert (SP) or (-)
[++ Insert leading (+) or (-)
-- Insert leading (SP) or (-)
Insert dollar sign. |
$$ Insert leading dollar sign.
# Replace with Digit 7
Control Statements:
GO TO 50
GO SUB 30
RETURN
IF Cl<1 GO TO 40
If D4 = 'ANY' THEN 50
IF X = 5 THEN Z = 3
FOR C1 = 2 TO STEP 1
FOR Cl = 2, 10, 1
FOR A4 = 50, -4.5, -1.2
NEXT A4
ON (I-1) GO TO 10, 20, 60
STOP
END
CALL 5 (A3, 6, I-2)
CALL 1
Matrix Statements
MAT X = ZER
MAT X = CON
MAT X = IDN
MAT X = Y+Z
MAT X = Y-Z
MAT X = 4 * 2
т X = (5) *Y
MAT X = TRN (Y)
MT X = IN (Y)
MAT READ X, Y, Z
MAT READ #N,X, Y, Z
MAT WRITE #N,X, Y, Z
MAT INPUT X, Y, Z
MAT PRINT X, Y, Z
Tr
Functions:
SIN(X)
COS (X)
TAN(X)
ATN(X)
LOG (X)
EXP (X)
SQR(X)
ABS (X)
SGN (X)
INT (X)
RND (X)
LEN (X$)
SUB (X$ , Y ,7)
Arithmetic
— Operators
+ ADD
- SUB
* МЛ,
/ DIV
t EXPON
HE95
‚GE
<> NE
> <
String Operator
+ Concatenatinn
RUN 45
LOAD 'BETA" , 1000
FILE'PNAME' , 1000, 1999
LIST 1000, 1999
APPENDIX D
'NUMBER' - UTILITY TO
NUMBER OR RE-NUMBER BASIC
PROGRAMS
PROGRAM DESCRIPTION
NUMBER is a FORTRAN program that reads a BASIC program and either
numbers or re-numbers its statements.
NUMBER is invoked as an external command by typing:
NUMBER
The program, NUMBER, then responds:
PARAMETERS
The parameters that may be specified are:
IFILE - input file name (first 6 characters)
OFILE - output file name (first 6 characters)
START - starting statement number (Decimal 1 < START < 9999)
INCR - statement mmber increment (Decimal 1 <INCR < 9999)
The parameters, OFILE, START, and INCR are optional. However, if INCR
is specified, START must be specified also. If OFILE is omitted, the
output is placed in IFILE. If START and INCR are both omitted, their
value is 1. If INCR alone is omitted, its value is 1.
The input file specified by IFILE can be either a completely numbered
file or a partially numbered file. If every statement has a statement
number, the file is re-numbered in the order of statement numbers of the
input file. For example, if the input file contained the following
statements:
1J
12
30
55
29
SI
79
39
99
95
110
120
139
159
MAT Az
4170
W2-=09
NEXT J
NEXT 1
NEXT K
STOP
and the following sequence of command
NUMBER
PARAMETERS
INMAT OUTMAT 10 10
where INMAT is the input file, OUTMAT
statement number is 10, and increment
РО
20
30
40
50
60
70
30
90
100
110
120
150
140
MAT Az
W1=0
W2=0
FOR
NEXT J
NEXT I
NEXT K
MATPRINT
STOP
DIM ACS,
ZER
9)
FOR K=1 TO 7
FOR I=1 TO 3
FOR J=I-1 TO 3
IF J<=1 THEN 95
GOLUB 290
MATPRINT A
lines is initiated
user types
system responds
user types
is the output file, the starting
is 10. The output becomes:
DIM AC9,9)
ZER
K=1 10 7
FOR I=1 TO 3
FOR J=I-1 TO 3
IF J<=1 THEN 100
GOSUB 290
A
The input file specified by IFILE can be only partially numbered,
NUMBER numbers statements in this type of file in the order of their
occurrence. In the following example, the file is sequential and
only the referenced lines contain numbers.
REM TEST OF THE NUMBER FROGRAM
REM OBJECT IS TO SEE HON A FARTIRLLT HUMEBERED PROGRAM IS HANDLEC.
REM
16 INFLT H
PRIMT CIS THIS THE END" :
THIPUIT Hi
IF H£ ="ENC THEM 3X
ОСОБЫЕ 250
бл ото 416
49 PRINT THIS IS THE LIVING END.
ENT
REM AA:::BECIM SUBROLUTIREZ: sk
Sas LET X= NH с ог
e
E
+ = SERIO
PRINT М: текс, CL o A
PRINT
Sas RETURN
=
ча
MT
Ин
—
zZ
The results of the interaction
NUMBER
PARAMETERS
PTESIN 2 2
are as follows:
> REM TEST OF THE NUMBER FROGRAM.
4 REM OBJECT IS TO SEE HOW A FARTIALL”? NUMBERED PROGRAM IS HANDLED.
So REM
= INFUT H
16 PRINT “IS THIS THE END”:
12 INPUT NE
14 IF NE="ENC" THEN 26
16 GOSUE 26
18 GOTO ©
28 PRINT “THIS IS THE LIVING END -
22 END
24 WEM He BEGIN SUEROUT INES. ef
26 LET x=
e A
за сени
22 Q=SGRCM)
=4 PRINT Bf: edd E Y >
sé PRINT
36
RETURE
RETURN D-3
Note that statements are numbered by NUMBER using only as many
digits as required. Thus, '599' in the above example becomes '38'.
When the NUMBER program completes execution, the input file, IFILE, is
closed; and the output file, OFILE, is also closed if it was opened.
ERROR MESSAGES
Messages
BAD PARAMETERS
ХХХХХХ NOT FOUND
XXXX DUP LINE NUMBER
INPUT FILE NULL
MEMORY OVERFLOW
LINE NUMBER OVERFLOW
D-4
Remarks
If either START or INCR are
specified with more than 4
digits, NUMBER requests a
new parameter line.
The specified IFILE does
not exist. Control returns
to DOS.
XXXX occurs as a line number
more than once. Control
returns to DOS.
The specified IFILE is empty.
Control returns to DOS.
There is not enough memory
to contain a map of line
numbers. Control returns to
DOS.
A new line number 9999.
Control returns to DOS.
APPENDIX E
MEMORY REQUIREMENTS
Memory
Resident DOS
System CONTROL
INTERPRETER INTERPRETER INTERPRETER
and * and * and
10С5 10С5 10С5
т уро
о VIP
hE E
Tables, Tables, Work
pork Areas, Areas, Etc.
Etc. Tabies,
DOS Work Areas,
5.4K Etc.
16K
MINIMUM
SYSTEM
DOS 6.6K
32K
MAXIMUM
SYSTEM
*See Tables on
Page E-2 for
memory
allocation
E-1
64 K VIRTUAL MEMORY USER SPACE — Mi
|
DOS-VM
CONTROL
INTERPRETER
Tables,
Work Areas,
Etc.
32K
Single Double |
Precision Precision
BASIC BASIC
BASIC 7.2K ale
BASIC with
PRINT USING 8.0K ^^
BASIC with
MATRIX 8.2K Ax
BASIC with
PRINT USING 10.2K **
& MATRIX
Interpreter and IOCS Memory
Allocation
High Speed and Memory Memory
Floating Point Required Required
Arithmetic Single-Prec. Double-Prec.
Neither 850 wds. k%
High Speed
Arith. only 640 wds. **
High Speed 6
Floating Point 0 wis, **
VIP (Virtual Instruction Package)
Memory Requirements
** to be supplied when double precision is
available.
E-2
Function Memory Required
Fixed Table | 700 words (single prec.)
1300 words (Double prec.)
Program APPROX. 1 Word/2 char.
Storage
STATEMENT 2 Words/Statement Index
Packet String values
Storage and FOR-NEXT loop
parameters
Array Dependent upon size.
Storage
Memory Allocations for
Tables, Work Areas, etc.
E-3
INDEX
ABS(X) 3-5
ABSOLUTE VALUE FUNCTION 3-5
ACCURACY 2-1A
AD B-1
ADDITION 3-1
AO B-1
AR B-1
ARCTANGENT 3-5
ARCTANGENT FUNCTION 3-5
ARGUMENT 3-4
ARGUMENT LIST 3-4
ARGUMENT: USER DEFINED FUNCTION 3-7
ARITHMETIC DATA POOL 5-36
ARITHMETIC OPERATORS 3-1
ARITHMETIC VARIABLE 5-19
ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
ARRAY
1-7,2-1A,2-3 = 2-6,5-8,5-20,6-1
ADDITION 6-5
ASSIGNMENTS 6-5
BOUNDS 2-5
CONSTANTS 6-2
DATA TYPE 2-3
DECLARATION 2-4
DIMENSIONS WITH REDIMENSIONING 6-3
DIMENSIONS 2-5,2-6
ELEMENT REFERENCE 2-5
ELEMENTS 2-3,5-19,6-?
MANIPULATION STATEMENTS 5-1,6-1
MULTIPLICATION 6-6
NAME 2-3
REDIMENSIONING 2-5,6-1
STATEMENTS 6-1
STORAGE 2-3
STORAGE ALLOCATION 2-5
SUBSCRIPT 2-3,2-5,2-6
SUBTRACTION 6-5
VARIABLES 2-3
ASC 5-6A
ASC SEP 5-6A
ASCII
ASCII
ASR 5-
0-273-475-6A75-36
FILE 4-2
6
ASSEMBLY LANGUAGE 5-3,7-1
ASSIGNED 6-1
ATN(X) 3-5
BASE E 3-5
BASIC
BASIC
BASIC
1-1
FILE 4-1 a
LANGUAGE INTERPRETER 1-1,2-4
I-1
INDEX
BASIC PROGRAM 1-1
BASIO 5-64
BATCH MODE 1-2.,1-5 - 1-6A
BD B-1
BE 8-1
BIN 5-64
BIN DA 5-7,5-22,5-41
BINARY FILE 5-6A
BINARY OPERATOR 3-1
BL 8-1
BLANKS 1-3
BOUNDS 2-3,2-5
BP B-1
BREAK 5-2
BREAK STATEMENT 1-7
BREAKPOINTS 5-2
BU B-1
CALL STATEMENT 5-2,7-1
CALLP SOURCE 7-2
CARD READER S-6A
CARDS 1-5,5-6
CARRIAGE RETURN 1-2,1-3
CH 8-1
CHARACTER ORDERING 3-4
CHARACTER OVERFLOW 5-25
CLEAR COMMAND 1-10
CLOSED FILE 4-2
CN B-1
COLON SEPARATOR 5-25
COLUMN O 6-1
COLUMN MAJOR 2-3
COMMA 2-3,4-2,5-29
COMMA SEPARATOR 5-25
COMMAND 1-1,1-8
COMMAND FORMAT 1-8 - 1-12
COMMAND PROCESSOR 1-1
COMMAND SYNTAX 1-8 - 1-12
COMPARISON OF STRINGS 3-4
COMPILER 7-1
CON 6-2»
CONFIGURATION FILE 7-1,7-2
CONSTANTS 2-1. 2-1A
CONTENTS OF FILE 4-1
CONTEXT ERROR 1-12
CONTINUE COMMAND 1-10
CONTROL VARIABLE 5-9,5-20
CONTROL-C 1-11
CONTROL-P 1-11
CONVERSATIONAL MODE 1-2 - 1-4,1-6A,6-1
I-2
INDEX
CONVERSION 3-1
COS(X) 3-5
COSINE FUNCTION 3-5
CP B-1
CR B-1
CURRENT EQUNDS 6-1,6-€
CV 8-1
DAM FILE 5-7
DATA 1-5,4-1,5-4
DATA FILES 4-1
DATA LIST POINTER 5-36
DATA FOOL 5-4 7»5-34,75-36,6-9
DATA STATEMENT 5-34
DATA TYPE: ARRAY 2-3
DATA TYPES 2-1 - 2-6,3-4.5-17
DEBUGGING 1-7,5-40
DECIMAL POINT 1-7,2-1,5-28
DECIMAL POINT HANDLING 1-7
DEF STATEMENT 3-7,5-5
DEFAULT ARRAY BOUNDS 2-5
DEFAULT ASSIGNED VALUE 5-19
DEFAULT VALUE 5-19
DEFINE FILE STATEMENT 4-225-6/5-3
DEFINE READ FILE STATEMENT 4-2,5-
DEFINING NUMERIC FIELDS 5-27
DEFINING STRING FIELDS 5-27
DELETING A STATEMENT 1-4
DELIMITERS 1-5
DEVICE 1-5,1-6,1-9,4-1,5-6
DEVICE IDENTIFIER 5-6.,5-64
DEVICE NAME 1-5,4-2,5-6
DF B-1
DIM STATEMENT ?2-46,2-5,5-8,6-1
DIMENSIONS 2-3
DISK 1-5
DISK FILE 5-6A,5-38
DIVISION 3-1
pM B-1
DOLLAR SIGN 2-3,5-31
DOS 1-11
DCS/VM 1-11
DOUBLE PRECISION 2-1,2-1A,5-1
5
6
E 8-7?
EDITOR 1-3, 3-1. &4 -1
EE B-1 o
ELEMENT 2-3,6-1,6-2
ELEMENT: ARRAY 2-3
END OF FILE 5-21
1-3
INDEX
END OF PROGRAM 5-9
END STATEMENT 5-9,5-39
ENTERING BASIC 1-1,1-e
EQUAL 3-2
EQUAL PRECEDENCE 3-1
ERASE CHARACTER 1-3
ERROR MESSAGES 1-12,8-1,8-2
ERROR: CONTEXT 1-12
ERROR: EXECUTION 1-12,8-1,B-?
ERROR: SOURCE 1-12,B-1,8-2
ERROR: SYNTAX 1-12
ERRORS 1-12,8-1,B-2
ES B-1
ESCAPE CONVENTION 3-1
EVALUATION 3-1,3-3
EVALUATION: FUNCTION REFERENCE 3-4
EVALUATION: OF EXPRESSION 3-1
EVALUATION: OF RELATIONAL EXPRESSIONS 3-1
EX 8-1
EXECUTING A PROGRAM 1-5
EXECUTION 1-121-3,1-5
EXECUTION ERRORS 1-12,8-1,8-2
EXP(X) 3-5
EXPONENT 2-1,2-1A.,3-?
EXPONENT FIELD 2-1
EXPONENT FUNCTION 3-5
EXPRESSION EVALUATION 3-1
EXPRESSION: IN FUNCTION REFERENCE 3-7
EXPRESSIONS 3-1 - 3-7,5-5
EXPRESSIONS: FILE 4-3
F 8-2
FALSE 5-15
FE B-1
FILE 1-5,1-6,1-9,4-1 - 4-3,5-39
FILE COMMAND 1-5,1-8,1-9,4-1
FILE CONTENTS 4-1
FILE EXPRESSIONS 4-3
FILE MODES 5-6A
FILE NUMBERS 4-2.5-41
FILE UNIT 5-2?
FILE UNIT NUMBERS 5-6
FILENAMES 1-5,4-2,5-6
FILES CLOSED 5-39
FILES OPENED 5-39
FIXED LENGTH RECORDS 5-7
FLOATING POINT 2-1,2-1A,3-1
FLOATING POINT ARITHMETIC 3-1
FLOATING POINT NUMBER 2-1
FM B-1
1-4
INDEX
FN B-1
FO B-1
FOR 5-20
FOR STATEMENT 5-10
FOR-NEXT LOOP 5-20
FORMAT 1-1
FORMAT FIELDS 5-27
FORMATTED OUTPUT STRINGS 5-42
FORMATTED PRINT-STATEMENT 5-27
FORTRAN 5-3,7-1
FP B-1
FRACTIONAL SUBSCRIPTS 2-6
FRACTIONS 5-23
FT B-e
FUNCTION 1-7,5-5
FUNCTION NAME 3-4
FUNCTION PARAMETER 5-5
FUNCTION REFERENCE EVALUATION 3-4
FUNCTION REFERENCE 3-4,3-7
FUNCTIONS 3-1,3-4 - 3-7
GO (ERROR MESSAGE) B-2
GO 1-1
GOSUB 5-13
GOTO 5-14
GREATER THAN 3-e
GREATER THAN COR EQUAL 3-2
GREATEST INTEGER 3-5
GT B-2
1/0 UNIT 5-38
IC B-?
ID B-e
IDN 6-2
IE B-e
IF STATEMENT 5-15,5-16
IMMEDIATE MODE 1-2,1-7,1-€
INITIAL LOAD 1-6
INITIALIZATION OF SCALAR VARIABLES 2-2
INITIALIZATION STATEMENTS 6-2
INPUT 5-17,5-18
INPUT OF STATEMENT 1-4
INPUT TO BASIC PROGRAMS 5-6A
INPUT/OUTPUT 4-1
INPUT/OUTPUT STATEMENTS 4-1
INSERTING A STATEMENT 1-4
INT(X) 3-5
INTEGER FUNCTION 3-5
INTEGERS 2-1,5-23
INTERNAL SUBROUTINE 5-13
I-5
INDEX
INTERPRETER 1-1,7-1
INVOKING BASIC (SEE ENTERING BASIC)
10 B=?
IOCS 5-6A
IS B-2
IT 8-2
KILL CHARACTER 1-3
LANGUAGE 1-1
LANGUAGE INTERPRETER 1-1
LANGUAGE PROCESSOR 1-1,5-1
LEAST INTEGER 3-5
LEFT ANGLE BRACKET 5-31
LENCAS) 3-5
LENGTH FUNCTION 3-5
LENGTH OF FILE RECORD 4-2
LENGTH OF STRING 2-2-,2-3,3-5
LESS THAN 3-2
LESS THAN OR EQUAL 3-2
LET 5-10
LG B-?
LINE 1-1
LINE LENGTH 1-1
LINE NUMBER (SEE STATEMENT NUMBER)
LINE PRINTER 5-6,5-6A
LINE SIZE 2-2
LIST COMMAND 1-9
LITERALS 5-34
LOAD COMMAND 1-5,1-8.7-7
LOADING 1-6
LOADING A PROGRAM 1-6
LOG(X) 3-5
LOGARITHM FUNCTION 3-5
LOGICAL FILE NUMBER 4-2
LOGICAL FILE UNIT 5-6
LOGICAL UNIT 5-21
LOOP 5-10
LT B-2
MAGNETIC TAPE #41 5-6A
MAGNETIC TAPE #2 5-6A
MAGNETIC TAPE #3 5-6A
MAGNETIC TAPE #4 5-6A
MAGNETIC TAPE 1-5,5-6
MANTISSA 2-1A
MAT DIMENSION IMPROPER FORMAT B-1
MAT INPUT STATEMENT 6-11
MAT PRINT STATEMENT 6-12
MAT READ FILE STATEMENT 6-9
I-6
INDEX
MAT READ STATEMENT 6-8,6-9
MAT STATEMENTS 2-5,5-1,5-8,6-1,6-2
MAT WRITE FILE 6-10
MAT...CON 6-3
MAT...IDN 6-3
MAT...2ER 6-3
MATRICES 6-1,6-3,6-7
MATRIX 2-3,2-5
MATRIX ADDITION 6-5
MATRIX ADDITION 6-5
MATRIX ASSIGNMENTS 6-5
MATRIX ASSIGNMENTS 6-5
MATRIX BOUNDS 2-5
MATRIX BOUNDS 2-5
MATRIX CONSTANTS 6-2
MATRIX CONSTANTS 6-2
MATRIX DATA TYPE 2-3
MATRIX DATA TYPE 2-3
MATRIX DECLARATION 2-4
MATRIX DECLARATION 2-4
MATRIX DIMENSIONS 2-5,2-6
MATRIX DIMENSIONS WITH REDIMENSIONING 6-3
MATRIX DIMENSIONS 2-5.,2-6
MATRIX DIMENSIONS WITH REDIMENSIONING 6-3
MATRIX ELEMENT REFERENCE 2-5
MATRIX ELEMENT REFERENCE 2-5
MATRIX ELEMENTS 2-3,5-19,6-2
MATRIX ELEMENTS 2-3,5-19,6-2
MATRIX MANIPULATION STATEMENTS 5-1,6-1
MATRIX MANIPULATION STATEMENTS 5-1,6-1
MATRIX MULTIPLICATION 6-6
MATRIX MULTIPLICATION 6-6
MATRIX NAME 2-3
MATRIX NAME 2-3
MATRIX REDIMENSIONING 2-5,6-1
MATRIX REDIMENSIONING 2-5,6-1
MATRIX STATEMENTS 6-1
MATRIX STATEMENTS 6-1
MATRIX STORAGE 2-3
MATRIX STORAGE 2-3
MATRIX STORAGE ALLOCATION 2-5
MATRIX STORAGE ALLOCATION 2-5
MATRIX SUBSCRIPT 2-3,2-5.,2-6
MATRIX SUBSCRIPT 2-3,2-5,2-6
MATRIX SUBTRACTION 6-5
MATRIX SUBTRACTION 6-5
MATRIX VARIABLES 2-3
MATRIX VARIABLES: 2-3
MAXIMUM STRING LENGTH 2-2
MEMORY 2-2.5-1
I-7
INDEX
MEMORY MAPPING 5-1
MEMORY SIZES 5-1
MIXED DATA 3-2
ML B-2
MM B-Z
MODE OF FILE 5-6
MODES OF OPERATION 1-1,1-2
MR B-2
MS B-e
MULTI-WAY BRANCH 5-21
MULTIPLE DOLLAR SIGNS 5-31
MULTIPLICATION 3-1
NAME OF USER DEFINED FUNCTION 3-7
NAMES 2-2,2-3,2-6
NATURAL LOGARITHM 3-5
NESTED 5-10
NEW COMMAND 1-10
NEXT 5-20
NEXT STATEMENT 5-10
NON-LOCAL 5-14
NOT EQUAL 3-2
NULL STRING 2-3,5-19
NUMERIC ARRAY 2-5
NUMERIC CONSTANT 2-1,5-4
NUMERIC EXPRESSION 3-1,3-2,5-15,5-e3
NUMERIC FIELDS 5-28
NUMERIC OPERAND 3-1
NUMERIC SCALAR EXPRESSION 6-6
NUMERIC SCALAR VARIABLES 2-2,2-3
NUMERIC TO STRING CONVERSION 3-1
NUMERIC VALUES 2-1,2-1A
NUMERIC VARIABLE 5-19
O R-e
ON 9-21
ON END 5-21.,5-22
ONE-DIMENSION 2-3
OPEN FILE 4-2,5-6
OPERAND 3-1
OPERATING MODES 1-1.,1-2
OPERATING SYSTEM 1-1,1-3,1-8
OPERATOR 3-1
ORDER OF ARRAY 2-3
ORIGINAL BOUNDS 6-1
OUTPUT DEVICE 1-9
Ov 8-2
P B-2
PAPER TAPE 1-5
I-8
INDEX
PAPER TAPE READER PUNCH 5-6A
PARENTHESES 3-1,5-6
PARENTHESES: IN EXPRESSION 3-1
PARTIAL LINE 5-25
PLUS OR MINUS SIGNS 5-29
PMA 7-1
PN B-2
PO B-?
POSITION STATEMENT 5-7,5-22
POUND SIGN 5-28,5-31
POWER 3-5
PR B-2
PRECEDENCE 3-1
PRINT ELEMENT 5-41
PRINT STATEMENT 1-3,5-23
PRINT USING STATEMENT 5-1,5-27
PRINTING NUMERIC STATEMENTS 5-23
PRINTING SPECIAL CHARACTERS 5-33
PRINTING STRING EXPRESSIONS 5-24
PRODUCTS OF ARRAYS 6-7
PROGRAM 1-1
PROGRAM FILES 4-1
PROGRAM STORAGE AREA 1-3,1- -6- 1-7
PROGRAM STRUCTURE 1-1 - 1-12
PROMPT 1-1
PROMPT CHARACTER! 5-17
PTR/P 5-6
QUIT 1-11
R B-2
RADIANS 3-5
RANDOM NUMBER 3-5
RANDOM NUMBER GENERATOR 3-5
RANGE OF DIMENSION 2-5
RANGE OF FILE NUMBER 4-2
RANGE OF NUMERIC VALUES 2-14
RE B-C
READ #&#N,L1,...,LN 5-35
READ * FILE 5-36
READ AFTER WRITE CHECK 5-41
READ FILE 5-35
READ STATEMENT 4-2,5-4,5-34
READING 5-6
RECORD 4-1,5-2?2
RECORD NUMBER 5-22
RECORD SIZE 5-7
REDIMENSIONED 5-8
REDIMENSIONING 2-5
REFERENCE TO ARRAY ELEMENT 2-5
I-9
INDEX
REFERENCE: FUNCTION 3-4
RELATING CALL TO SUBROUTINE 7-1
RELATIONAL EXPRESSION 3-1,3-2,5-15
RELATIONAL OPERATORS 3-2
RELOCATION CONSTANT 1-8
REM 5-36
REMARK 9-36 |
REPLACING A STATEMENT 1-4
RESTARTING 1-11
RESTARTING BASIC 1-11
RESTARTING FROM DOS 1-11
RESTARTING FROM DOS/VM 1-11
RESTORE # 5-35
RESTORE $ 5-56
RESTORE 5-34,5-36
RETURN STATEMENT 5-13,5-c6
REWIND STATEMENT 4-2,5-38,5-41
RI B-2
RIGHT ANGLE BRACKET 5-32
RNOCX) 3-5
ROUNDING 3-6
ROW 0 6-1
ROW 6-7
RULES OF PRECEDENCE 3-1
RUN COMMAND 1-5,1-6,1-9
RUNNING A PROGRAM 1-6
RUNNING PROGRAM WITH CALL STATEMENTS 7-7
sc B-2
SCALAR MULTIPLICATION 6-6
SCALAR VARIABLES 2-2,5-19
SCIENTIFIC FORMAT 5-24
SE B-?
SECOND 6-7
SENSE SWITCH 1-11
SF B-2
SGN(X) 3-5
SI B-e
SIGN 2-1
SIGN CHARACTER 5-23
SIGN FUNCTION 3-5
SIGNED DECIMAL 2-1
SIGNIFICANT DIGIT 2-1
SINCX) 3-5
SINE FUNCTION 3-5
SINGLE PRECISION 2-1,2-1A
SINGLE QUOTES 1-5,1-6,2-2,5-17
SM B-2
SN B-2
SOURCE ERRORS 1-12.8-1,B-2
I-10
SOURCE
INDEX
FILE 1-5,1-6
SPECIAL CHARACTERS 1-3,5-27
se B-2
SQR(X)
SQUARE
SS B-2
ST B-2
START 1002
STATEMENT
STATEMENT
STATEMENT
STATEMENT
STATEMENT
STATEMENT
STATEMENT
STATEMENT
STATEMENT
STATEMENT
3-5
ROOT FUNCTION 3-5
1-11
1-1 = 1-2,1-8,5-1 -
BODY 1-3
DELETION 1-4
EXECUTION 1-1
FORMAT 1-1
INPUT 1-4
INSERTION 1-4
NUMBER 1-1 = 1=3,1-6,1-7
REPLACEMENT 1-4
TERMINATOR (SEE CARRIAGE RETURN)
5-42
STEP 5-10
STOP 5-
39
STORAGE 1-3,6-1
STORAGE ALLOCATION 2-5
STORAGE OF ARRAYS 2-3,2-4
STCRAGE OF STATEMENTS 1-3
STRING
STRING
STRING
STRING
STRING
STRING
STRING
STRING
STRING
STRING
STRING
STRING
STRING
STRING
STRING
2-2,2-3
ARRAY 2-5
COMPARISON 3-4
CONSTANT 2-2,5-4
DATA POOL 5-36
EXPRESSION 3-1,3-225-3,5-15,5-23
FIELDS 5-31
LENGTH 2-2,3-4
OPERANDS 3-1
OPERATOR 3-1
SCALAR VARIABLES 2-3
TO NUMERIC CONVERSION & 3-1
VALUES 2-2,3-46
VARIABLE NAME 2-3
VARIABLE 5-19
SUBCLAS,1.J) 3-5
SUBROUTINE 5-3
SUBROUTINE IDENTIFIER 5-3
SUBSCRIPT
SUBSCRIPT
SUBSCRIPT
SUBSCRIPT
2=3,2-5,2-6+5-19
ARRAY ELEMENTS 5-19
EXPRESSION 2-6,5-17,5-34
RANGE 2-6
SUBSTRING 3-5
SUBSTRING
FUNCTION 3-5
SUBTRACTION 3-1
I-11
INDEX
SYNTAX ERROR 1-12
SYSTEM COMMAND 1-2
SYSTEM EDITOR 1-3,3-1,4-1
SYSTEM FUNCTION 3-1,3-4 - 3-7
TAB REQUEST 5-41
TANCX) 3-5
TANGENT FUNCTION 3-5
TARGET ARRAY 6-1
TELETYPE 5-6A
TERMINAL 1-5,5-64A
TO 5-10
TRACE 5-39
TRACE OFF 5-39
TRACE ON 5-39
TRAILING COMMA 5-4 |
TRANSFER INTO A COMPLETED LOOP 5-10
TRANSPOSE OPERATIONS 6-8 e
TRUE 3-3,5-15 -
TWO-DIMENSION 2-3
TWO-DIMENSIONAL 6-2.6-7
TYPE: SCALAR VARIABLES2-2
TYPES OF DATA 2-1 - 2-6
UF 5-35
UFD 1-5
UNARY MINUS 3-1
UNARY OPERATOR 3-1
UNARY PLUS 3-1
UNASSIGNED SCALAR STRING VARIABLES 5-19
UNDECLARED ARRAY 2-5
UNIT SPECIFIER 5-6
USER DEFINED FUNCTION NAME 3-7
USER DEFINED FUNCTION 3-1,3-7
USER DEFINED NUMERIC FUNCTION 3-7
USER FILE DIRECTORY 1-5
VARIABLE 1-1 1-7,2-1,2-18,5-3,5-34
VARIABLE NAME 2-2
VARIABLES: ARRAY 2-3.,72-4
VARIABLES: SCALAR 2-2,2-3
VARIABLES: SUBSCRIPTED 2-3,2-4
VECTOR 2-3.2-5
VERSION OF BASIC 5-1
VERTICAL ARROW 5-29
WR ERROR 5-41
WRITE FILE 9-41
WRITE STATEMENT 4-2
WRITE USING 5-42
I-12
INDEX
WRITING 5-6
X B-2
2 B-e
ZER 6-2
ZERO LENGTH STRING 2-3
ZERO SUBSCRIPTS 2-5
ZONES 5-25
I-13
">
/
Завантажити
Просто дружнє нагадування. Ви можете переглянути документ прямо тут. Але найголовніше, наш штучний інтелект вже прочитав його. Він може пояснити складні речі простими словами, відповісти на ваші запитання будь-якою мовою та допомогти вам швидко орієнтуватися навіть у найдовших або найскладніших документах.
Реклама