|
|
DataMuseum.dkPresents historical artifacts from the history of: CP/M |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about CP/M Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 156160 (0x26200)
Types: TextFile
Names: »D5«
└─⟦e61e7d03c⟧ Bits:30005867/disk01.imd Dokumenter (RCSL m.m.)
└─⟦this⟧ »D5«
R_C_ _B_A_S_I_C_
A_ _S_t_r_u_c_t_u_r_e_d_ _E_d_u_c_a_t_i_o_n_a_l_ _L_a_n_g_u_a_g_e_ _(_C_O_M_A_L_)_
P_R_O_G_R_A_M_M_I_N_G_ _G_U_I_D_E_
A/S REGNECENTRALEN First Edition
Development DivisionSeptember 1977
Documentation Department RCSL 42-i 0671\f
Authors: Stig Møllgaard and Pierce Hazelton
Keywords: RC 3600, RC 7000, MUS, DOMUS, RC BASIC,
Programming Guide
Abstract: This guide describes the RC BASIC language implemented
for RC 3600 and RC 7000 minicomputers.
Supporting RC BASIC System Logical Disc Formatting Program
documents: Operating Guide (RCSL 43-G 45069).
Copyright A/S Regnecentralen, 1977
Printed by A/S Regnecentralen, Copenhagen\f
C_O_N_T_E_N_T_S_
1 INTRODUCTION Page9
1.1 General information9
1.2 RC BASIC programs9
1.3 ESCape key10
1.4 Descriptions of statements, commands,
and functions11
1.5 Formats used in descriptions12
2 RC BASIC ARITHMETIC15
2.1 Numbers15
2.2 Internal representation of numbers15
2.3 Variables16
2.4 Arrays16
2.4.1 Array elements16
2.4.2 Declaring an array17
2.5 Expressions17
2.5.1 Numeric expressions17
2.5.2 Arithmetic operators17
2.5.2.1 DIV operator18
2.5.2.2 MOD operator18
2.5.3 Priorities of arithmetic operators during
program execution18
2.5.4 AND, OR, and NOT operators19
2.5.5 Relational expressions20
2.5.6 Relational operators20
2.5.7 Priorities of arithmetic, Boolean, and
relational operators21
2.5.8 String expressions21
3 RC BASIC STATEMENTS 22
3.1 BYE 22
3.2 CASE-WHEN-ENDCASE 22
3.3 CHAIN 28
3.4 DATA 30
3.5 DEF 31
3.6 DELAY 33
3.7 DIM 33
3.8 END 35
3.9 ENTER 36
3.10 EXEC 37
3.11 FOR-NEXT 38
3.12 GOSUB and RETURN 42
3.13 GOTO 43
3.14 IF-THEN 44 \f
3.15 IF-THEN-ENDIF Page 46
3.16 IF-THEN-ELSE-ENDIF 48
3.17 INPUT50
3.18 LET53
3.19 NEW54
3.20 ON-ERR54
3.21 ON-ESC55
3.22 ON-GOTO/GOSUB58
3.23 PAGE59
3.24 PRINT59
3.25 PRINT USING63
3.26 PROC-ENDPROC71
3.27 RANDOMIZE73
3.28 READ75
3.29 REM76
3.30 REPEAT-UNTIL77
3.31 RESTORE79
3.32 SAVE80
3.33 STOP80
3.34 TAB81
3.35 TAB(X) function81
3.36 WHILE-ENDWHILE83
4 RC BASIC FUNCTIONS87
4.1 Introduction87
4.2 ABS(X)88
4.3 ATN(X)88
4.4 COS(X)89
4.5 EXP(X)89
4.6 FNa(d)90
4.7 INT(X)90
4.8 LOG(X)91
4.9 RND(X)91
4.10 SGN(X)94
4.11 SIN(X)94
4.12 SQR(X)95
4.13 SYS(X)96
4.14 TAN(X)97
5 STRING INFORMATION98
5.1 String concept98
5.1.1 String literals 98
5.1.2 String variables 98
5.1.3 Dimensioning string variables 99
5.1.4 Substrings 99
5.1.5 Assigning values to string variables 100
5.1.6 Concatenation of strings 100 \f
5.1.7 Relational string expressions Page 102
5.2 CHR(X) function 103
5.3 LEN(X<) function 104
5.4 ORD(X<) function 105
6 MATRIX MANIPULATION 107
6.1 Matrix operations107
6.2 Dimensioning matrices107
6.3 Matrix assignment statement108
6.4 Matrix addition/subtraction statement109
6.5 Matrix multiplication statement111
6.6 DET(X) function113
6.7 MAT CON statement114
6.8 MAT IDN statement115
6.9 MAT INPUT statement117
6.10 MAT INV statement117
6.11 MAT PRINT statement119
6.12 MAT READ statement121
6.13 MAT TRN statement122
6.14 MAT ZER statement122
7 LOGICAL DISCS AND RELATED COMMANDS124
7.1 Introduction124
7.2 CONNECT126
7.3 COPY127
7.4 INIT128
7.5 LOCK128
7.6 LOOKUP129
7.7 RELEASE131
7.8 USERS131
8 FILES AND RELATED STATEMENTS133
8.1 Introduction133
8.1.1 Disc files and devices133
8.1.2 Standard devices and reserved names133
8.1.3 Block sizes134
8.1.4 Filenames and file sizes134
8.1.5 How files are used134
8.1.6 Random access files135
8.1.7 Sequential access files135
8.1.8 Write protection135
8.2 CLOSE FILE136
8.3 CREATE137
8.4 DELETE138
8.5 EOF(X) function139
8.6 INPUT FILE140
8.7 MAT INPUT FILE141\f
8.8 MAT PRINT FILEPage141
8.9 MAT READ FILE142
8.10 MAT WRITE FILE 143
8.11 OPEN FILE 143
8.12 PRINT FILE145
8.13 PRINT FILE USING146
8.14 READ FILE147
8.15 RENAME148
8.16 WRITE FILE149
9 SYSTEM COMMANDS151
9.1 Introduction151
9.2 Command to delete program statements151
9.3 AUTO153
9.4 BATCH/BATCH "<LPT"155
9.5 BYE155
9.6 CON/CONL156
9.7 ENTER158
9.8 EOJ159
9.9 LIST159
9.10 LOAD161
9.11 NEW162
9.12 PAGE163
9.13 PUNCH164
9.14RENUMBER166
9.15 RUN/RUNL168
9.16 SAVE170
9.17 SCRATCH172
9.18 SIZE173
9.19 TAB173
9.20 TIME174
APPENDICES
A ERROR MESSAGES 175
A.1 Introduction 175
A.2 Error messages176
A.3 I/O error messages184
A.3.1 I/O error messages 0100 through 0119, 0135, 184
and 136
A.3.2 I/O error messages 0120 through 0134187
B BATCH MODE AND PROGRAMMING ON MARK-SENSE CARDS192
B.1 Batch jobs192
B.2 Mark-sense cards194\f
B.2.1 STATEMENT NUMBERPage 195
B.2.2 STATEMENT 1196
B.2.3 STATEMENT 2 197
B.2.4 FORMULA198
B.2.4.1 Even numbered columns198
B.2.4.2 Odd numbered columns198
B.2.4.3 Writing characters199
B.3 Batch mode202
B.3.1 BATCH/BATCH "<LPT" command202
B.3.2 Illegal statements and commands202
B.3.3 Time limit on jobs203
B.3.4 ESCape key203
B.3.5 Return to interactive mode203
B.4 EOJ command204
B.5 SCRATCH command204
B.6 TIME command205
C OTHER INTERACTIVE USES OF RC BASIC206
C.1 Commands derived from RC BASIC statements206
C.2 Desk calculator functions207
C.3 Program debugging207
C.4 File input/output208
D ASCII CHARACTER SET209
D.1 ASCII characters with their decimal and octal
values209
D.2 Output of non-printing characters210
E RESERVED WORDS211
F SUMMARY OF STATEMENTS, COMMANDS, AND FUNCTIONS212
F.1 RC BASIC statements (Chapter 3)212
F.2 RC BASIC functions (Chapter 4)217
F.3 String functions (Chapter 5)219
F.4 Matrix statements (Chapter 6)219
F.5 Logical disc commands (Chapter 7)221
F.6 File statements (Chapter 8)222
F.7 System commands (Chapter 9)224
F.8 Batch mode commands (Appendix B)227
G ADVANCED PROGRAMMING EXAMPLES228
H CALLING AN ASSEMBLY LANGUAGE SUBROUTINE FROM RCBASIC229
INDEX230\f
F_O_R_E_W_O_R_D_
RC BASIC is a structured educational language, implemented by
A/S Regnecentralen to run on RC 3600 and RC 7000 minicomputers.
The education sector has long felt the need for a suitable
programming language: one which is simple and comprehensible,
yet sufficiently advanced to permit demonstration of important
programming principles.
Until now the BASIC language has generally been used, for
despite its deficiencies as regards advanced programming, BASIC,
precisely because of its comprehensibility and convenient
conversational form, has fulfilled a basic requirement in
educational applications.
In recent years proposals have been put forth for better
educational languages, among them COMAL (C_o_m_mon A_lgorithmic
L_anguage).
COMAL possesses all the features that have made BASIC popular;
in fact, COMAL includes almost all of the facilities found in
existing versions of BASIC, and users can therefore run almost
any program written in BASIC on a computer that runs COMAL.
COMAL, however, contains significant extensions to the BASIC
language.
COMAL was proposed primarily to accommodate users desiring more
advanced control facilities than those found in BASIC. Thus the
designers of COMAL, inspired by the PASCAL language, have intro-
duced five new control structures: REPEAT-UNTIL, WHILE-DO-
ENDWHILE, IF-THEN-(ELSE)-ENDIF, and CASE-OF-WHEN-ENDCASE.
COMAL also contains several other important extensions, such as
the possibility of using long variable names (as many as eight
characters), all of which contribute to making COMAL programs
clearer and more readable than programs written in BASIC.
The COMAL language, which was designed by Børge Christensen,
Government Teachers" College, Tønder, Denmark, in collaboration
with Benedict Løfstedt, Århus University, is incorporated in RC
F_BASIC.\f
1 I_N_T_R_O_D_U_C_T_I_O_N_
1.1 G_e_n_e_r_a_l_ _i_n_f_o_r_m_a_t_i_o_n_
The RC BASIC programming language provides facilities for:
Writing structured programs.
Executing programs in interactive mode.
Running jobs in batch mode.
Performing file input/output.
Performing matrix operations.
Manipulating strings.
Formatting output.
Performing desk calculator functions.
RC BASIC runs under the RC operating system MUS (M_ultiprogram-
ming U_tility S_ystem) or DOMUS (D_isc O_perating M_ultiprogramming
U_tility S_ystem).
This programming guide describes the syntax and semantics of RC
BASIC statements, commands, and functions.
Those who have access to terminals can use RC BASIC in inter-
active mode, but it is also possible to execute programs written
on mark-sense cards in batch mode (see App. B).
1.2 R_C_ _B_A_S_I_C_ _p_r_o_g_r_a_m_s_
An RC BASIC program consists of a number of statements. Each
statement begins with a line number, in the range 1 to 9999,
which determines the order in which the statement will be
executed. The rest of the statement is made up of one or more
RC BASIC words (see below), with or without arguments. Each
statement is written on a separate line.
The user terminates each statement line by pressing the RETURN
key. This generates an automatic line feed in addition to the
carriage return. (Note: The "carriage return" separator referred
to in this guide is the RETURN key, not the ASCII character
Carriage Return). If the user discovers a typing error b_e_f_o_r_e_ he
has pressed the RETURN key, he can delete the last character
typed by pressing the RUBOUT key (repeatedly, if need be) or
delete the entire line by pressing the ESCape key.
\f
Some RC BASIC words, such as END, STOP, or CLOSE, can be used
alone to perform an operation; others require one or more
arguments, on which the operations are performed. Thus the
word READ, for example, cannot be used alone; READ must have at
least one argument, viz. the name of a variable to which a value
is to be assigned (e.g. READ PRICE).
The user may enter program statements in any order. The system
will arrange them by ascending line numbers.
When a program is run, the statements are executed one by one
in ascending line number order, usually beginning with the
lowest numbered statement. The sequential execution of state-
ments may be interrupted by a "control transfer statement," such
as ENDWHILE, EXEC, ENDPROC, or GOTO.
Many of the RC BASIC statements, which are described in Chapters
3, 6, and 8, may also be used as keyboard commands (see App. C).
When a statement is used as a command, it is entered without a
preceding line number and terminated by pressing the RETURN key,
whereupon the system executes it immediately.
Still other RC BASIC words can only be used alone, i.e. they
cannot be part of a statement, but are used solely as commands.
LIST and RUN are examples of such words.
When a program has been entered, it will remain in core
memory until the user clears it by means of a NEW command.
New statement lines can be inserted anywhere in a program.
Existing statements can be deleted, by typing the statement
line number and pressing the RETURN key, or corrected,
simply by entering a new statement with the same line number.
The currently loaded program can be executed by means of a
RUN/RUNL command.
T_ 1.3 E_S_C_a_p_e_ _k_e_y_
Pressing the ESCape key during program execution will cause
&_ interruption of the program, unless an ON-ESC statement has been
executed (see Ch. 3). Control will be returned to interactive
mode, and the system will output the following on the user"s\f
terminal:
T_ STOP
AT xxxx'
&_ *
where xxxx' is the line number of the statement at which the
program was interrupted. The asterisk (*) prompt indicates that
the user may enter a command or a program statement. Program
execution can be resumed by means of a CON/CONL or RUN/RUNL
line no.' command.
Pressing the ESCape key on an idle terminal (e.g. after system
start-up or a BYE command) will place the terminal in inter-
active mode.
When a terminal is in batch mode, the ESCape key has a special
function (see App. B).
T_1.4 D_e_s_c_r_i_p_t_i_o_n_s_ _o_f_ _s_t_a_t_e_m_e_n_t_s_,_ _c_o_m_m_a_n_d_s_,_ _a_n_d_ _f_u_n_c_t_i_o_n_s_
Descriptions of the statements, commands, and functions in the
RC BASIC language will be found in Chapters 3 through 9. These
descriptions have the following form:
x.y R_C_ _B_A_S_I_C_ _W_O_R_D_
Format
Use
Remarks
Example
&_ where
x.y : Chapter.Section
RC BASIC WORD : One or more reserved RC BASIC words
Format : The generalized format (syntax) of the
statement, command, or function.
This format, which is explained in detail
below, must be used when the statement,
command, or function is entered from the
terminal, otherwise an error message
(usually 0002: SYNTAX ERROR) will result.\f
Use : Indicates whether the RC BASIC word is
used as a statement, command, or function,
and describes the operation or operations
which it performs.
Remarks : Contains remarks concerning the use of the
statement, command, or function, including
rules, precautions, program operation, and
the like.
Example : The use of most of the statements,
commands, and functions is illustrated by
one or more examples, which usually
consist of small programs, followed by
the output produced when the program was
executed.
As many of the programs were listed on
the line printer, and the resulting
output was directed to the line printer,
the commands used (viz. LIST "<LPT" and
RUNL) do not appear in these examples.
In a few examples, for clarity"s sake, the
text entered by the user is underlined and
followed by the symbol to denote that the
user has terminated the line by pressing
the RETURN key, e.g. ? 5_,_6_,_7_,_8_ _ _
1.5 F_o_r_m_a_t_s_ _u_s_e_d_ _i_n_ _d_e_s_c_r_i_p_t_i_o_n_s_
Capital letters in the generalized format denote literal
entries.
Any parentheses should be inserted as indicated.
Braces ( ) indicate a choice of the items enclosed.
Brackets () indicate that the enclosed items are optional.
An ellipsis (...) indicates that the preceding argument may be
repeated.
\f
Several abbreviations are used in the formats to represent
common terms. All abbreviations in a format are explained
immediately beneath it, while the terms represented are defined
in the appropriate chapters of this guide. The most frequently
occurring abbreviations are:
var' : The name of a numeric variable, with or
without subscripts.
svar' : The name of a string variable, with or
without subscripts.
expr' : A numeric, relational (Boolean), orstring
expression (see Ch. 2).
slit' : A string literal (string constant), i.e.
a sequence of characters enclosed within
quotation marks (").
val' : A numeric constant.
line no.' : A statement line number in the range
1 to 9999.
statements' : One or more RC BASIC statements.
mvar' : The name of a matrix variable.
ldname' : The name of a logical disc.
filename' : The name of a disc file or a device.
device' : The name of a device.
file' : A numeric expression which evaluates to a
number in the range 0 to 7 (the number of
a user file).
F_ \f
T_ As an example, consider the generalized format of the PRINT
statement (see Ch. 3):
expr' expr'
;slit' , slit' ,
PRINT svar' ; svar' ... ;
&_1 1 25 56 7 7 6 234 43
The PRINT statement begins with the word PRINT. As PRINT is
frequently used, one can write a semicolon (;) instead of the
word PRINT. This is indicated by the pair of braces 1-1.
The pair of brackets 2-2 indicates that the PRINT statement need
not have an argument. PRINT may optionally (brackets 3-3) be
followed by a comma or a semicolon (braces 4-4).
An argument may be of the type expr', slit', or svar', as
indicated by the pair of braces 5-5. If there is more than one
argument (brackets 6-6 and the ellipsis), the arguments should
be separated by a comma or a semicolon (braces 7-7).\f
2. R_C_ _B_A_S_I_C_ _A_R_I_T_H_M_E_T_I_C_
2.1 N_u_m_b_e_r_s_
An RC BASIC number may be in the range:
5.4 * 10UUU-79 DDD n 7.2 * 10UUU75DDD
Numbers may be expressed as integers, as floating-point
numbers, or in exponential form (E-type notation).
In the conversion of numeric data, e.g. by a PRINT statement
(see Ch. 3), any floating-point or integer number that
contains six digits or less is formatted without using
exponential form. A floating-point or integer number that
requires more than six digits is printed in the following
E-type notation:
sign'n.nnnnnEsign'XX
where n.nnnnn is an unsigned number carried to five
decimal places with trailing zeroes suppressed, E means
"times 10 to the power of," and XX represents an
unsigned exponential value.
N_u_m_b_e_r_ O_u_t_p_u_t_ _f_o_r_m_a_t_
2,000,000 2E+06
108.999 108.999
.0000256789 2.56789E-05
24E10 2.4E+11
T_ 2.2 I_n_t_e_r_n_a_l_ _r_e_p_r_e_s_e_n_t_a_t_i_o_n_ _o_f_ _n_u_m_b_e_r_s_
Internally, floating-point numbers are stored in two
consecutive 16-bit words having the form:
_0_ _ _1_ _ _ _ _ _7_ _8_ _ _ _ _ _ _ _ _1_5_
_S_ _ _ _ _ _C_ _______________MANTISSA
_______________________
16 31
&_ \f
where: S is the sign of the mantissa (0 = positive,
1 = negative); the mantissa is a normalized six-digit
hexadecimal fraction; and C is the characteristic and
an integer expressed in excess 64 code.
T_2.3 V_a_r_i_a_b_l_e_s_
A numeric variable name (shown in the statement descriptions
&_ as var') consists of a single letter followed by from 0 to 7
T_ digits or letters, for example:
L_e_g_a_l_ _n_a_m_e_s_ I_l_l_e_g_a_l_ _n_a_m_e_s_
I <PRICE
INTEREST 6I
AMOUNT MEANVALUE
PRICE
&_
In addition to numeric variables, string variables (shown in
the statement descriptions as svar') are also permitted in RC
BASIC (see Ch. 5).
T_2.4 A_r_r_a_y_s_
An array represents an ordered set of values. Each member of
&_ the set is called an array element. An array can have either one
or two dimensions. An array name consists of a single letter
followed by from 0 to 7 digits or letters.
b_2.4.1 A_r_r_a_y_ _e_l_e_m_e_n_t_s_e
Each of the elements of an array is identified by the name
of the array followed by a parenthesized subscript, for
example:
ITEMNO(1), ITEMNO(2), ..., ITEMNO(8), ITEMNO(9)
&_
For a two-dimensional array, the first number gives the
number of the row and the second gives the number of the
T_ column for each element. Thus the elements of the array
C(2,3) would be:
C(1,1) C(1,2) C(1,3)
&_ C(2,1) C(2,2) C(2,3) \f
b_2.4.2 D_e_c_l_a_r_i_n_g_ _a_n_ _a_r_r_a_y_ e
An array must be declared in a DIM statement (see Ch. 3),
which gives the name of the array and its dimensions.
&_
The lower bound of a dimension is always 1. The upper bound is
given in the DIM statement, two upper bounds being separated by a
comma (,). Dimensional information is enclosed in parantheses
T_ immediately following the name of the array in the DIM statement,
for example:
5 DIM SET(15), AMOUNT(2,3)
The total number of elements in an array may not exceed 32 767.
&_ Available memory will normally impose a limit, however.
T_2.5 E_x_p_r_e_s_s_i_o_n_s_
&_ An expression (shown in the statement descriptions as
expr') may be composed of parentheses, constants and
variables (numeric or string), and functions, linked
together by operators.
T_b_2.5.1 N_u_m_e_r_i_c_ _e_x_p_r_e_s_s_i_o_n_s_e
A numeric expression may be composed of numeric variables
and constants and (numeric) functions, linked together by
arithmetic operators.
T_b_ 2.5.2 A_r_i_t_h_m_e_t_i_c_ _o_p_e_r_a_t_o_r_s_e
The arithmetic operators are as follows:
+ : monadic + ( A+(+B) )
- : monadic - ( A+(-B) )
: exponentiation ( A B )
* : multiplication ( A*B )
/ : division ( A/B )
MOD : modulus calculation ( A MOD B )
DIV : integer division ( A DIV B )
+ : addition ( A+B )
- : subtraction ( A-B )
&_
The operators +, -, *, /, and are familiar to most, but DIV
and MOD may require some explanation. \f
T_2.5.2.1 D_I_V_ _o_p_e_r_a_t_o_r_. The result of an integer division A DIV B is equal
to:
SGN(A/B)*INT(INT(ABS(A))/INT(ABS(B)))
The SGN(X), INT(X), and ABS(X) functions are described in
Chapter 4.
E_x_a_m_p_l_e_s_
11 DIV 4 = +1 x 2 = 2
-11 DIV 4 = -1 x 2 = -2
&_
T_ 2.5.2.2 M_O_D_ _o_p_e_r_a_t_o_r_. The result of a modulus calculation A MOD B is
equal to:
SGN(A)*INT(ABS(A))-A DIV B*SGN(B)*INT(ABS(B))
&_
The SGN(X), INT(X), and ABS(X) functions are described in
Chapter 4.
T_ E_x_a_m_p_l_e_s_
11 MOD 4 = 11 - 2 x 4 = 3
-11 MOD 4 = -11 - (-2) x 4 = -3
&_
T_b_2.5.3 P_r_i_o_r_i_t_i_e_s_ _o_f_ _a_r_i_t_h_m_e_t_i_c_ _o_p_e_r_a_t_o_r_s_ _d_u_r_i_n_g_ _p_r_o_g_r_a_m_ _e_x_e_c_u_t_i_o_n_ _e
As a general rule, numeric expressions are evaluated from left
&_ to right.
The arithmetic operators, however, have different priorities,
for which reason the following exceptions to this rule apply:
1. Numeric expressions enclosed within parentheses are always
evaluated before non-parenthesized expressions. If expres-
sions are nested, the innermost expression is evaluatedfirst.
2. Functions are evaluated next.
3. The priorities of the arithmetic operators are as follows:
First: monadic plus and monadic minus
Second: exponentiation
Third: multiplication, division, modulus
calculation, and integer division \f
Fourth: addition and subtraction
4. When two operators have the same priority, evaluation
proceeds from left to right.
T_ The following two examples should help clarify the principles
according to which numeric expressions are evaluated.
1 + 2 - 3 x 4 2 DIV 5 + 6
1: 1 + 2 - 3 x 16 DIV 5 + 6
2: 1 + 2 - 48 DIV 5 + 6
3: 1 + 2 - 9 + 6
4: 3 -9 + 6
5: -6 + 6
6: 0
(1 + (2 - 3) x 4 2) DIV 5 + 6
1: (1 + (-1) x 4 2) DIV 5 + 6
2: (1 -1 x 4 2) DIV 5 + 6
3: (1 -1 x 16 ) DIV 5 + 6
4: (1 - 16 ) DIV 5 + 6
5: -15 DIV 5 + 6
6: -3 + 6
7: 3
&_
T_ b_ 2.5.4 A_N_D_,_ _O_R_,_ _a_n_d_ _N_O_T_ _o_p_e_r_a_t_o_r_s_e
The operators AND, OR, and NOT are analogous to *, +, and
&_ -; but whereas *, +, and - have numeric arguments, AND, OR,
and NOT have Boolean arguments. A Boolean argument can have
two values: true, corresponding to 1 (or ' 0), and false,
corresponding to 0.
T_ NOT operates on one argument only, and means logical ne-
gation, for example:
_ _A_ _ _ _ _ _ _ _ _ _ _ _N_O_T_ _A_ _
TRUE FALSE
_F_A_L_S_E_ _ _ _ _ _ _ _ _T_R_U_E_ _ _
&_ \f
T_ AND operates on two arguments, and means logical multi-
plication (logical and), for example:
_ _A_ _ _ _ _ _ _ _ _ _ _ _B_ _ _ _ _ _ _ _ _ _ _ _A_ _A_N_D_ _B____________
FALSE (0) FALSE (0) FALSE (0 x 0 = 0)
FALSE (0) TRUE (1) FALSE (0 x 1 = 0)
TRUE (1) FALSE (0) FALSE (1 x 0 = 0)
_T_R_U_E_ _(_1_)_ _ _ _ _T_R_U_E_ _(_1_)_ _ _ _ _ _T_R_U_E_ _(_1_ _x_ _1_ _=_ _1_)__ _
&_
T_ OR operates on two arguments, and means logical addition
(logical or), for example:
_ _A_ _ _ _ _ _ _ _ _ _ _ _B_ _ _ _ _ _ _ _ _ _ _ _A_ _O_R_ _B____________ _
FALSE (0) FALSE (0) FALSE (0 + 0 = 0)
FALSE (0) TRUE (1) TRUE (0 + 1 = 1)
TRUE (1) FALSE (0) TRUE (1 + 0 = 1)
_T_R_U_E_ _(_1_)_ _ _ _ _T_R_U_E_ _(_1_)_ _ _ _ _ _T_R_U_E_ _(_1_ _+_ _1_ __'_ _0_)_ _
&_
T_ The priorities of these three operators are:
First: NOT
Second: AND
&_ Third: OR
T_ b_ 2.5.5 R_e_l_a_t_i_o_n_a_l_ _e_x_p_r_e_s_s_i_o_n_s_e
A relational expression is composed of two expressions of
the same type, i.e. both numeric or both string, linked
&_ together by a relational operator.
T_b_2.5.6 R_e_l_a_t_i_o_n_a_l_ _o_p_e_r_a_t_o_r_s_e
The relational operators are as follows:
: less than
= : less than or equal to
= : equal to
'= : greater than or equal to
' : greater than
&_ ' : not equal to
As mentioned above, all relational operators have two arguments.
The arguments are compared, and the result of the comparison is
always either true or false. Thus the notation
0 X 10\f
is illegal, as this would result in a comparison of
0 and X (true or false)
followed by a comparison of
(true or false) and 10
which is meaningless. The correct notation is:
0 X AND X 10
T_ E_x_a_m_p_l_e_s_
1 10 is true.
1 ' 10 is false.
"JOHN" "PETER" is true (see Ch. 5).
1 10 AND 20 30 is true (1 x 1 = 1).
10 5 OR 2 11 is true (0 + 1 = 1).
NOT 1 4 is false.
&_
T_b_2.5.7 P_r_i_o_r_i_t_i_e_s_ _o_f_ _a_r_i_t_h_m_e_t_i_c_,_ _B_o_o_l_e_a_n_,_ _a_n_d_ _r_e_l_a_t_i_o_n_a_l_ _o_p_e_r_a_t_o_r_s_ e
In compound expressions, the priorities of arithmetic,
Boolean, and relational operators are as follows:
First: monadic plus and monadic minus
Second: exponentiation
Third: multiplication, division, modulus calculation, and
integer division
Fourth: addition and subtraction
Fifth: relational operators (', , =, =, '=, ')
Sixth: NOT
Seventh: AND
Eighth: OR
T_ b_ 2.5.8 S_t_r_i_n_g_ _e_x_p_r_e_s_s_i_o_n_s_e
A string expression (see further Ch. 5) may be any of the
following:
1. A string variable, e.g. ANSWER<
2. A string literal, e.g. "PETER"
3. The CHR(X) function, e.g. CHR(65)
4. A concatenation of the above items, e.g.
&_ "JOHN SMITH",ADDRESS< \f
3 RC BASIC STATEMENTS
3.1 B_Y_E_
For description, see Chapter 9.
3.2 C_A_S_E_-_W_H_E_N_-_E_N_D_C_A_S_E_
F_o_r_m_a_t_
CASE expr' OF
statements-0'
WHEN expr' ,expr' ...
statements-1'
.
.
.
WHEN expr' ,expr' ...
statements-n'
ENDCASE comment'
expr': an expression.
statements-0': a block of statements.
.
.
.
statements-n': a block of statements.
comment': a text comment.
U_s_e_
As a statement to execute one of several block of statements
depending on the value of an expression.
R_e_m_a_r_k_s_
1. R_u_l_e_s_
a. expr' may be an expression of any kind.
b. For every CASE statement there must be at least one
corresponding WHEN statement and one ENDCASE statement.
\f
c. If a block of statements belonging to a CASE construc-
tion is entered from outside the construction, the error
message 0062: WHEN WITHOUT CASE or 0061: ENDCASE
WITHOUT CASE will be output when WHEN or ENDCASE is
encountered.
T_2. P_r_o_g_r_a_m_ _o_p_e_r_a_t_i_o_n_
a. The expression in the CASE expr' OF statement is
evaluated.
&_
b. The expressions in the WHEN expr' ,expr' statements
are evaluated one by one until a value is found which is
equal to the value obtained in step a. If this value is
found in the ith WHEN statement, statements-i' is
executed.
c. Execution continues until a WHEN or ENDCASE statement is
encountered; after this, control is transferred to the
first statement following the ENDCASE statement.
d. If a matching value is not found in step b,
statements-0' is executed. If statements-0' is not
present, the error message 0059: CASE WITHOUT WHEN, CASE
ERROR will be output.
T_3. N_e_s_t_e_d_ _c_o_n_s_t_r_u_c_t_i_o_n_s_
CASE-WHEN-ENDCASE constructions may be nested to any
depth.
&_ 4. The word ENDCASE may be followed by a comment.
\f
T_ E_x_a_m_p_l_e_ _1_ C_o_m_m_e_n_t_ _(_1_)_
0010 FOR I=1 TO 5 Shows a nested CASE con-
0020 CASE I OFstruction.
0030 PRINT "CASE ERROR - I"
0040 WHEN 1,3+1,6
0050 FOR J=3 TO 5
0060 CASE J OF
0070 PRINT "CASE ERROR - J"
0080 WHEN 3
0090 PRINT "I,J =";I;J
0100 WHEN 4
0110 PRINT "J,I =";J;I
0120 ENDCASE
0130 NEXT J
0140 WHEN 2
0150 PRINT "I =";I
0160 WHEN 3
0170 PRINT "I =";I
0180 ENDCASE
0190 NEXT I
0200 STOP
T_ I,J = 1 3
J,I = 4 1
CASE ERROR - J
I = 2
I = 3
I,J = 4 3
J,I = 4 4
CASE ERROR - J
CASE ERROR - I
&_
\f
T_ E_x_a_m_p_l_e_ _2_
0010 DIM MONTH<(10)
0020 FOR MONTHNR=1 TO 13
0030 CASE MONTHNR OF
0040 PRINT "ILLEGAL NUMBER: ";MONTHNR
0050 GOTO 0330
0060 WHEN 1
0070 LET MONTH<="JANUARY"; DAYS=31
0080 WHEN 2
0090 LET MONTH<="FEBRUARY"; DAYS=28
0100 WHEN 3
0110 LET MONTH<="MARCH"; DAYS=31
0120 WHEN 4
0130 LET MONTH<="APRIL"; DAYS=30
0140 WHEN 5
0150 LET MONTH<="MAY"; DAYS=31
0160 WHEN 6
0170 LET MONTH<="JUNE"; DAYS=30
0180 WHEN 7
0190 LET MONTH<="JULY"; DAYS=31
0200 WHEN 8
0210 LET MONTH<="AUGUST"; DAYS=31
0220 WHEN 9
0230 LET MONTH<="SEPTEMBER"; DAYS=30
0240 WHEN 10
0250 LET MONTH<="OCTOBER"; DAYS 31
0260 WHEN 11
0270 LET MONTH<="NOVEMBER"; DAYS 30
0280 WHEN 12
0290 LET MONTH<="DECEMBER"; DAYS 31
0300 ENDCASE
0310 PRINT TAB(10-LEN(MONTH<));MONTH<;
0320 PRINT " HAS";DAYS;"DAYS."
0330 NEXT MONTHNR
&_ 0340 STOP \f
T_ JANUARY HAS 31 DAYS.
FEBRUARY HAS 28 DAYS.
MARCH HAS 31 DAYS.
APRIL HAS 30 DAYS.
MAY HAS 31 DAYS.
JUNE HAS 30 DAYS.
JULY HAS 31 DAYS.
AUGUST HAS 31 DAYS.
SEPTEMBER HAS 30 DAYS.
OCTOBER HAS 31 DAYS.
NOVEMBER HAS 30 DAYS.
DECEMBER HAS 31 DAYS.
&_ ILLEGAL NUMBER: 13
\f
T_ E_x_a_m_p_l_e_ _3_
0010 DIM ANSWER<(20)
0020 PROC GETANSWR
0030 REM THE PROCEDURE ACCEPTS ONE OF THREE POSSIBLE
0040 REM ANSWERS: YES, NO, OR DON"T KNOW
0050 REPEAT
0060 LET ERROR=0
0070 INPUT ANSWER<
0080 PRINT ANSWER<
0090 CASE ANSWER< OF
0100 PRINT "ERROR, RETYPE"
0110 LET ERROR=1
0120 WHEN "YES"
0130 LET YES=YES+1
0140 WHEN "NO"
0150 LET NO=NO+1
0160 WHEN "DON"T KNOW","DO NOT KNOW"
0170 LET DONTKNOW=DONTKNOW+1
0180 WHEN "END"
0190 LET FINIS=1
0200 ENDCASE
0210 UNTIL NOT ERROR
0220 ENDPROC
0230 REM
0240 REM MAIN PROGRAM
0250 REM PRINT QUESTION, CHECK ANSWER
0260 REM BY MEANS OF THE PROCEDURE
0270 REM GETANSWR
0280 REM
0290 LET FINIS=0; YES=0; NO=0; DONTKNOW=0
0300 REPEAT
0310 PRINT "QUESTION"
0320 EXEC GETANSWR
0330 UNTIL FINIS
0340 PRINT "13'10'10'"," YES"," NO","DON"T KNOW"
0350 PRINT ,YES,NO,DONTKNOW
0360 STOP
&_ \f
T_ QUESTIONC_o_m_m_e_n_t_ _(_3_)_
NO
QUESTIONFor PROC-ENDPROC,
YESsee Section 3.26.
QUESTION
YES
QUESTION
DO NOT KNOW
QUESTION
NO
QUESTION
DON"T KNOW
QUESTION
NOT
ERROR, RETYPE
NO
QUESTION
YESE
ERROR, RETYPE
YES
QUESTION
END
YES NO DON"T KNOW
&_ 3 3 2
T_ 3.3 C_H_A_I_N_
F_o_r_m_a_t_
&_ CHAIN filename' THEN GOTO lineno.'
filename': a disc file or a device expressed as a string
literal or by means of a variable.
line no.': the line number in the program referred to by
filename' from which execution is to begin.
T_ U_s_e_
As a statement or command to run the SAVEd program referred to by
filename' when the CHAIN statement is encountered in the user"s
&_ program. \f
T_ R_e_m_a_r_k_s_
1. When a CHAIN statement is encountered in a program, it stops
execution of that program, loads a previously SAVEd program
(see SAVE, Ch. 9) from the disc file or the device specified
by filename', and begins execution of the SAVEd program.
2. If the SAVEd program is on disc, the system searches the
logical disc to which the terminal is connected for filename'
(see Ch. 8). If filename' is not found, the system outputs
the error message 0100: FILE UNKNOWN.
3. If filename' is found, the user"s currently running program
is cleared from core memory and the SAVEd program is loaded
into core memory from filename'. If filename' is not found,
the current program remains in core memory.
4. The newly loaded program is run from its lowest numbered
statement, unless the THEN GOTO line no.' argument is given
in the CHAIN statement to specify another line number from
which execution is to begin.
5. The CHAIN statement is typically used to divide a large program
into smaller programs or to run independent programs from a
main program on the basis of conditional statements.
6. CHAIN may also be used as a command, in which case it has the
same effect as LOAD (see Ch. 9), i.e. the SAVEd program is
loaded, but not executed.
E_x_a_m_p_l_e_ _1_ C_o_m_m_e_n_t_ _(_1_)_
0010 INPUT "SELECT PROGRAM NUMBER : ",NUMBERThe user selects a
0020 CASE NUMBER OF program by typing a
0030 PRINT "ILLEGAL NUMBER" number.
0040 WHEN 1
0050 CHAIN "PROGRAM1"
0060 WHEN 2
0070 CHAIN "PROGRAM2"
0080 WHEN 3
0090 CHAIN "PROGRAM3"
0100 ENDCASE \f
T_ E_x_a_m_p_l_e_ _2_ C_o_m_m_e_n_t_ _(_2_)_
0010 DIM NAME<(10) The user selects a
0020 INPUT "SELECT PROGRAM : ",NAME< program by typing its
0030 CHAIN NAME< name, i.e. the name of
0040 END the disc file or the
device from which the
program is to be
CHAINed.
&_
T_
3.4 D_A_T_A_
F_o_r_m_a_t_
val' ,val'
DATA slit' ,slit' ...
val': a numeric value.
slit': a string literal.
U_s_e_
As a statement to provide values to be read into variables
&_ appearing in READ statements.
T_ R_e_m_a_r_k_s_
&_ 1. The DATA statement is non-executable.
2. The values appearing in a DATA statement or statements form a
single list. The first element in this list is the first item
inthe lowest numbered DATA statement. The last element in the
list is the last item in the highest numbered DATA statement.
3. Both numbers and string literals may appear in a DATA
statement. Each value in a DATA statement list must be
separated from the next value by a comma.
T_
E_x_a_m_p_l_e_
100 DATA 1,17,"AB,CD",-1.3E-13
&_ S_e_e_ _f_u_r_t_h_e_r_ _R_E_A_D_ _(_S_e_c_t_._ _3_._2_8_)_._ \f
T_ 3.5 D_E_F_
F_o_r_m_a_t_
DEF FNa'(d') = expr'
a': a letter.
d': a dummy numeric variable, which may appear in
expr'.
expr': a numeric expression, which may contain the
&_ variable d'.
U_s_e_
As a statement to permit the user to define as many as 29
different functions, which can be referenced repeatedly
throughout a program. Each function returns a numeric value.
R_e_m_a_r_k_s_
1. The name of the defined function must be the two letters FN
followed by a single letter, viz. A, B, ..., Z, @, Ø, orÅ.
2. The dummy variable named in the DEF statement is not related
to any variable in the program having the same name; the DEF
statement simply defines the function and does not cause any
calculation to be carried out.
3. In the function definition, expr' may be any legal numeric
expression and may include other user-defined functions.
Functions may be nested to a depth of seven.
4. Function definition is limited to a single-line DEF
statement. Complex functions that require more that one
program statement should be constructed as subroutines or
procedures.\f
T_ E_x_a_m_p_l_e_ _1_ C_o_m_m_e_n_t_ _(_1_)_
* LIST Calculates
0010 DEF FNP(X)=X 2+2*X+2 P(X) = X 2+2*X+2 for
0020 FOR I=1 TO 5 different values of X.
0030 PRINT FNP(I);
0040 NEXT I
* RUN
5 10 17 26 37
END
AT 0040
&_*
T_ E_x_a_m_p_l_e_ _2_ C_o_m_m_e_n_t_ _(_2_)_
* LIST Shows the nesting of
0010 DEF FND(X)=X*SYS(14)/180functions.
0020 DEF FNS(X)=SIN(FND(X))
0030 DEF FNC(X)=COS(FND(X))
0040 FOR DEGR=0 TO 45 STEP 5
0050 PRINT DEGR,FNS(DEGR),FNC(DEGR)
0060 NEXT DEGR
0070 STOP
* TAB=12
* RUN
0 0 1
5 8.71556E-2 .996195
10 .173648 .984808
15 .258819 .965926
20 .34202 .939693
25 .422618 .906308
30 .5 .866025
35 .573576 .819152
40 .642787 .766045
45 .707107 .707107
STOP
AT 0070
&_*\f
T_3.6 D_E_L_A_Y_
F_o_r_m_a_t_
DELAY = expr'
expr': a numeric expression, which is evaluated to an
integer in the range 0 expr' = 60.
U_s_e_
As a statement to interrupt program execution for a specified
number of seconds.
R_e_m_a_r_k_s_
1. expr' is the number of seconds for which the program is
stopped.
2. When expr' seconds have passed since the DELAY statement was
encountered, program execution will continue from the first
statement following the DELAY statement.
T_
3.7D_I_M_
F_o_r_m_a_t_
svar'(m')svar'(m')
DIM array'(m') , array'(m') ...
array'(row',col') array'(row',col')
svar': a string variable.
m': a numeric expression, which evaluates to the
length of a string variable orthe number of
elements in a one-dimensional array.
array': an array name.
row': a numeric expression, which evaluates to the
number of rows in an array.
col': a numeric expression, which evaluates to the
number of columns in an array. \f
T_U_s_e_
As a statement or command to define explicitly the size of one
or more numeric variable arrays or string variables. (Forthe
dimensioning of string variables, see Chapter 5).
&_
T_R_e_m_a_r_k_s_
1. A_r_r_a_y_ _e_l_e_m_e_n_t_s_
For the concept of arrays, see Chapter 2. The DIM statement
&_ is used to declare the size of an array to be a specified
number of elements for each dimension, for example:
10 DIM A(13),B(7,7),C(20,5)
Until a value is assigned by the user"s program, the value of
all elements in an array is zero.
Any variable or expression that is used for a subscript must
evaluate to a value in the range
1 = value = upper bound declared in the DIM statement
for example:
15 X=2
20 PRINT B(1,X 2)
If the variable or expression subscript does not evaluate to
an integer, RC BASIC will convert it using the INT(X)
function (see Ch. 4).
If a subscript evaluates to an integer greater than the upper
bound of the dimension for the array or less than 1, the
error message 0031: SUBSCRIPT ERROR will be output.
T_2. R_e_d_i_m_e_n_s_i_o_n_i_n_g_ _a_r_r_a_y_s_
One can redimension a previously defined array during
execution of a program by declaring the array in another DIM
&_ statement. The total number of elements in the redimensioned
array must not exceed the previous total number of elements,
for example:\f
T_ 100 DIM A(3,3)
.
.
.
200 DIM A(2,3)
.
.
.
300 DIM A(2,2)
The values assigned to elements in the array A(3,3) are re-
assigned to elements in the array A(2,3) and then to elements
&_in the array A(2,2):
T_
1 2 3 1 2 3 1 2
4 5 6 4 5 6 3 4
7 8 9
A(1,1) = 1 A(1,1)= 1A(1,1) = 1
A(1,2) = 2 A(1,2) = 2 A(1,2) = 2
A(1,3) = 3 A(1,3) = 3 A(2,1) = 3
A(2,1) = 4 A(2,1) = 4 A(2,2) = 4
A(2,2) = 5 A(2,2) = 5
A(2,3) = 6 A(2,3) = 6
A(3,1) = 7
A(3,2) = 8
&_ A(3,3) = 9
T_3. T_o_t_a_l_ _n_u_m_b_e_r_ _o_f_ _e_l_e_m_e_n_t_s_
The total number of elements in an array may not exceed 32 767.
Available memory will normally impose a limit, however.
&_
T_ 3.8 E_N_D_
F_o_r_m_a_t_
END comment'
comment': a text comment.
&_
U_s_e_
As a statement to terminate execution of the program and to
return control to interactive mode.\f
T_R_e_m_a_r_k_s_
1. RC BASIC includes the END statement, but does not require its
&_ use to declare the physical end of a program. If control
passes through the last executable statement of the program
and if that statement does not change the flow of control,
i.e. is not a GOTO or similar statement, then the program
will transfer control to interactive mode.
2. Multiple END statements may appear in the same program, and
when encountered will terminate execution of the program
followed by a prompt (*) output on the user"s terminal.
3. The word END may be followed by a comment.
T_E_x_a_m_p_l_e_
*20 PRINT "PROGRAM DONE"
*30 GOTO 60
.
.
.
*50
*60 END
* RUN
PROGRAM DONE
END
AT 0060
&_*
T_ 3.9 E_N_T_E_R_
For description, see Chapter 9.
&_ \f
T_3.10 E_X_E_C_
F_o_r_m_a_t_
EXEC name'
name': the name of a procedure. name' may also be a
simple numeric variable.
&_
T_U_s_e_
As a statement to execute a procedure defined by PROC-ENDPROC
(see Sect. 3.26).
&_
T_ R_e_m_a_r_k_s_
1. R_u_l_e_s_
name' is the name of the procedure to be executed. If name'
&_ is a simple numeric variable, it may be assigned a value
before the procedure is called; it may also be assigned a new
value by the procedure before control is returned to the main
program.
T_2. P_r_o_g_r_a_m_ _o_p_e_r_a_t_i_o_n_
a. When the EXEC statement is encountered, a search is made
&_ for the procedure named name'.
b. If name' is not found, the error message 0046: PROCEDURE
DOES NOT EXIST will be output.
c. The statements in the procedure are executed until an
ENDPROC or RETURN statement is encountered. Control is
then returned to the first statement following the EXEC
statement.
T_E_x_a_m_p_l_e_
See PROC-ENDPROC (Sect. 3.26).
&_ \f
T_3.11F_O_R_-_N_E_X_T_
F_o_r_m_a_t_
FOR control var' = expr1' TO expr2' STEP expr3'
&_ statements'
NEXT control var'
control var': an unsubscripted numeric variable.
expr1': a numeric expression defining the first or
initial value of control var'.
expr2': a numeric expression defining the
terminating value of control var'.
expr3': a numeric expression defining the
increment added to control var' each time
the loop is executed.
statements': a block of statements, which may also
contain FOR-NEXT loops.
T_U_s_e_
As a statement to establish the initial, terminating, and
&_incremental values of a control variable, which is used to
determine the number of times a block of statements contained in
a FOR-NEXT loop is to be executed. The loop is repeated until
the value of the control variable meets the termination
condition.
T_R_e_m_a_r_k_s_
1. R_u_l_e_s_
a. The control variable control var' must not be
subscripted.
&_
b. For every FOR or NEXT statement there must be a matching
NEXT or FOR statement, otherwise an error message (0021:
FOR WITHOUT NEXT or 0022: NEXT WITHOUT FOR) will be
output.
c. The expressions expr1', expr2', and expr3' may have\f
positive or negative values; expr3' must not be zero.
d. If the STEP expr3' argument is omitted in the FOR
statement, expr3' is assumed to be +1.
e. The termination condition for a FOR-NEXT loop depends on
the values of expr1' and expr3'. The loop will terminate
if expr3' is positive and the next value of control var'
is greater than expr2', or if expr3' is negative and the
next value of control var' is less than expr2'.
N_o_t_e_:_ If the value of expr1' (the initial value) meets
the termination condition, statements' will not be
executed even once.
f. If the body of a FOR-NEXT loop is entered at any point
other than the FOR statement, the error message 0022:
NEXT WITHOUT FOR will be output when the NEXT statement
corresponding to the skipped FOR statement is
encountered.
g. When the termination condition is met, the loop is
exited.
T_2. P_r_o_g_r_a_m_ _l_o_o_p_ _o_p_e_r_a_t_i_o_n_
a. expr1', expr2', and expr3' are evaluated. If expr3' is
not specified, it is assumed to be +1.
&_
b. control var' is set equal to expr1'.
c. If expr3' is positive (negative) and control var' is
greater than (less than) expr2', the termination
condition is satisfied and control passes to the first
statement following the corresponding NEXTstatement;
otherwise step e is performed.
d. If expr3' is positive (negative) and control var' +
expr3' is greater than (less than) expr2', the
termination condition is satisfied and control passes to
the first statement following the corresponding NEXT
statement; otherwise control var' is set equal to
control var' + expr3'.
e.statements' is executed. \f
f. Step d is repeated.
T_3. N_e_s_t_e_d_ _l_o_o_p_s_
FOR-NEXT loops may be nested to a depth of seven. The FOR
&_ statement and its terminating NEXT statement must be
completely contained within the loop in which they are nested,
for example:
T_ L_e_g_a_l_ _n_e_s_t_i_n_g_ I_l_l_e_g_a_l_ _n_e_s_t_i_n_g_
FOR X = ... FOR X = ...
FOR Y = ... FOR Y = ...
FOR Z = ... NEXT X
NEXT Z NEXT y
NEXT Y
&_ NEXT X
T_ E_x_a_m_p_l_e_ _1_ C_o_m_m_e_n_t_ _(_1_)_
0010 FOR I=1 TO 25
0020 FOR J=1 TO 25 STEP 7
0030 NEXT J
0040 NEXT I
0050 PRINT I,J
0060 STOP
25 22 Final values of I and J
&_ before their terminating
values were exceeded.\f
T_E_x_a_m_p_l_e_ _2_ C_o_m_m_e_n_t_ _(_2_)_
0010 LET A=10 Shows nested FOR-NEXT loops.
0020 FOR I=A TO 1 STEP -1
0030 PRINT TAB(I);
0040 FOR J=A TO I STEP -1
0050 PRINT "**";
0060 NEXT J
0070 PRINT
0080 REM NEW LINE
0090 NEXT I
0100 STOP
01234567890123456789
**
****
******
********
**********
************
**************
****************
******************
&_********************
T_ E_x_a_m_p_l_e_ _3_
0010 DIM TEXT<(30)
0020 LET TEXT<="TEXT1TEXT2TEXT3TEXT4TEXT5TEXT6"
0030 FOR I=5 TO 0 STEP -1
0040 PRINT TEXT<(I*5+1,(I+1)*5)
0050 NEXT I
0060 STOP
TEXT6 C_o_m_m_e_n_t_ _(_3_)_
TEXT5
TEXT4 A string array can be imple-
TEXT3 mented by means of a FOR-NEXT
TEXT2construction.
&_TEXT1 \f
T_ 3.12G_O_S_U_B_ _a_n_d_ _R_E_T_U_R_N_
F_o_r_m_a_t_
GOSUB line no.'
.
.
.
statements'
RETURN comment'
line no.': the first statement of a subroutine.
statements': a block of statements.
T_ comment': a text comment.
T_U_s_e_
As a statement to direct program control to the first statement
of a subroutine. RETURN exits the subroutine and returns control
to the first statement following the GOSUB statement that caused
the subroutine to be entered.
T_R_e_m_a_r_k_s_
1. A subroutine is a convenient means of executing the same
&_ block of statements at different places in a program. Sub-
routines may be nested to a depth of seven. Nesting occurs
when a subroutine is called during the execution of another
subroutine.
2. A subroutine may be entered only by means of a GOSUB state-
ment, otherwise the error message 0019: RETURN WITHOUT GOSUB
will be output when the RETURN statement is encountered.
3. A subroutine may contain more than one RETURN statement,
should program logic require the subroutine to terminate at
one of a number of different places.
4. Although a subroutine may appear anywhere in a program, it is
good practice to place the subroutine distinctly separate
from the main program. In order to prevent inadvertent entry
of the subroutine by other than a GOSUB statement, the sub-
routine should be preceded by a STOP statement (see Sect.
3.33) or a GOTO statement (see Sect. 3.13) that directs
control to a line number following the subroutine.
5. The word RETURN may be followed by a comment. \f
T_E_x_a_m_p_l_e_ _1_
0010 LET I=144
0020 GOSUB 0060
0030 LET I=169
0040 GOSUB 0060
0050 STOP
0060 PRINT "THE SQUARE ROOT OF";I;"IS:";SQR(I)
0070 RETURN
THE SQUARE ROOT OF 144 IS: 12
&_THE SQUARE ROOT OF 169 IS: 13
T_E_x_a_m_p_l_e_ _2_
0010 GOSUB 0040
0020 PRINT "EXAMPLE"
0030 GOTO 0140
0040 PRINT "NEST";
0050 GOSUB 0080
0060 PRINT "INE ";
0070 RETURN
0080 PRINT "ED ";
0090 GOSUB 0120
0100 PRINT "ROUT";
0110 RETURN
0120 PRINT "SUB";
0130 RETURN
0140 STOP
&_NESTED SUBROUTINE EXAMPLE
T_ 3.13G_O_T_O_
F_o_r_m_a_t_
GOTO line no.'
line no.': a line number.
&_
U_s_e_
As a statement to transfer control unconditionally to a
statement that is not in normal sequential order. \f
R_e_m_a_r_k_s_
1. If control is transferred to an executable statement, that
statement and those following it will be executed.
2. If control is transferred to a non-executable statement, such
as DATA, program execution will continue at the first execut-
able statement following the non-executable statement.
E_x_a_m_p_l_e_
0010 READ NUMBER
0020 PRINT NUMBER;
0030 IF NUMBER'0 THEN GOTO 0010
0040 STOP
0050 DATA 10,9,8,7,6,5,4,3,2,1,0
&_ 10 9 8 7 6 5 4 3 2 1 0
T_3.14I_F_-_T_H_E_N_
F_o_r_m_a_t_
IF expr' THEN statement'
expr': an expression which, when evaluated, has
&_ the value true (' 0) or false (= 0).
statement': any RC BASIC statement except CASE-WHEN-
ENDCASE, DATA, DEF, END, FOR-NEXT, ENDIF,
ELSE, PROC-ENDPROC, REM, REPEAT-UNTIL, and
WHILE-ENDWHILE.
T_U_s_e_
As a statement or command to execute a single statement de-
&_pending on whether the value of an expression is true or false.
T_R_e_m_a_r_k_s_
P_r_o_g_r_a_m_ _o_p_e_r_a_t_i_o_n_
&_1. If the value of expr' is true (' 0), statement' is exe-
cuted. If statement' does not cause transfer of control to\f
another part of the program, execution will then continue at
the first statement following the IF-THEN statement.
2. If the value of expr' is false (= 0), statement' is not
executed.
N_o_t_e_:_ Since the internal representation of non-integer
numbers may not be exact (.2 cannot be represented exactly,
for example), it is advisable to test for a range of values
when testing for a non-integer. If, for example, the result
of a computation, A, was to be 1.0, a reliable test for 1
would be
IF ABS(A-1.0)_1.0E-6 THEN ...
If this test succeeded, A would be equal to 1 to within 1
part in 10 6. This is approximately the accuracy of single-
precision floating-point calculations.
E_x_a_m_p_l_e_ _1_ C_o_m_m_e_n_t_ _(_1_)_
0010 LET I=10 The statement GOTO 40
0020 IF I'5 THEN GOTO 0040 is executed only if I ' 5.
0030 PRINT "DON"_T ENTER HERE"
0040 PRINT "PRINT THIS"
0050 STOP
PRINT THIS
T_E_x_a_m_p_l_e_ _2_a_
0010 LET A=5; B=5
0020 PRINT "A AND B ARE";
0030 IF A'B THEN PRINT " NOT";
0040 PRINT " EQUAL"
0050 STOP
A AND B ARE EQUAL
&_ \f
T_E_x_a_m_p_l_e_ _2_b_
0010 LET A=5; B=7
0020 PRINT "A AND B ARE";
0030 IF A'B THEN PRINT " NOT";
0040 PRINT " EQUAL"
0050 STOP
&_A AND B ARE NOT EQUAL
T_ 3.15I_F_-_T_H_E_N_-_E_N_D_I_F_
F_o_r_m_a_t_
IF expr' THEN DO
statements'
ENDIF comment'
expr': an expression which, when evaluated, has the
value true (' 0) or false (= 0).
statements': a block of statements.
comment': a text comment.
T_U_s_e_
As a statement to execute a block of statements depending on
whether the value of an expression is true or false.
&_
T_R_e_m_a_r_k_s_
1. R_u_l_e_s_
a. For every IF-THEN/ENDIF statement there must be a matching
ENDIF/IF-THEN statement.
&_
b. If statements' is entered at any point other than the
IF-THEN statement, the error message 0056: ENDIF WITHOUT
IF will be output when the ENDIF statement is encountered.
2. P_r_o_g_r_a_m_ _o_p_e_r_a_t_i_o_n_
a. If the value of expr' is true (' 0), statements' is
executed once.
\f
b. Execution will then continue at the first statement
following the ENDIF statement.
3. N_e_s_t_e_d_ _c_o_n_s_t_r_u_c_t_i_o_n_s_
IF-THEN-ENDIF/IF-THEN-ELSE-ENDIF constructions may be nested
to a depth of seven.
4. The word ENDIF may be followed by a comment.
T_E_x_a_m_p_l_e_ _1_ C_o_m_m_e_n_t_ _(_1_)_
0010 LET I=1 The block of statements
0020 IF I THEN betweenIF-THEN and ENDIF is
0030 PRINT "I'0" executed only if I is true
0040 LET I=I+1 (I ' 0).
0050 ENDIF
0060 PRINT "AFTER ENDIF, I=";I
0070 STOP
I'0
&_AFTER ENDIF, I= 2
T_E_x_a_m_p_l_e_ _2_
0010 LET I=0
0020 IF I THEN
0030 PRINT "DON!T ENTER HERE"
0040 LET I=I+1
0050 ENDIF
0060 PRINT "AFTER ENDIF, I=";I
0070 STOP
&_ AFTER ENDIF, I= 0
T_E_x_a_m_p_l_e_ _3_
0010 LET I=26
0020 IF I/2'=13 THEN
0030 PRINT "SHOULD ENTER HERE"
0040 ENDIF
0050 STOP
&_SHOULD ENTER HERE \f
T_ E_x_a_m_p_l_e_ _4_
0010 DIM NAME<(4)
0020 LET NAME<="JOHN"
0030 IF NAME<(2,3)="OH" THEN
0040 PRINT "NAMES CONTAINS "OH" "
0050 LET NAME<(2,3)=" "
0060 PRINT NAME<
0070 ENDIF
0080 STOP
NAMES CONTAINS "OH"
&_J N
3.16I_F_-_T_H_E_N_-_E_L_S_E_-_E_N_D_I_F_
F_o_r_m_a_t_
IF expr' THEN DO
statements-1'
ELSE comment'
statements-2'
ENDIF comment'
expr': an expression which, when evaluated, has
the value true (' 0) or false (= 0).
statements-1': a block of statements which is executed
if the value of expr' is true (' 0).
statements-2': a block of statements which is executed
if the value of expr' is false (= 0).
comment': a text comment.
&_
U_s_e_
As a statement to execute one of two blocks of statements
depending on whether the value of an expression is true or
false.
\f
R_e_m_a_r_k_s_
1. R_u_l_e_s_
If statements-1' or statements-2' is entered at any point
other than the IF-THEN/ELSE statement, an error message
(0051: ELSE WITHOUT IF or 0056: ENDIF WITHOUT IF) will be
output when the ELSE/ENDIF statement if encountered.
2. P_r_o_g_r_a_m_ _o_p_e_r_a_t_i_o_n_
a. expr' is evaluated.
b. If the value of expr' is true (' 0), statements-1' is
executed.
c. If the value of expr' is false (= 0), statements-2' is
executed.
d. When statements-1' or statements-2' has been executed
and if neither has caused transfer of control to another
part of the program, execution will continue at the first
statement following the ENDIF statement.
3. N_e_s_t_e_d_ _c_o_n_s_t_r_u_c_t_i_o_n_s_
IF-THEN-ENDIF/IF-THEN-ELSE-ENDIF constructions may be nested
to a depth of seven.
4. The words ELSE and ENDIF may be followed by comments.
\f
T_E_x_a_m_p_l_e_ C_o_m_m_e_n_t_
0010 DIM PRICE(4),NUMBER(4) If ITEMNO = 1 or 3, the
0020 FOR ITEMNO=1 TO 4 statements in lines 40
0030 IF (ITEMNO=1) OR (ITEMNO=3) THENand 50 are executed;
0040 LET PRICE(ITEMNO)=10otherwise the statements
0050 LET NUMBER(ITEMNO)=7 in lines 70 and 80 are
0060 ELSEexecuted.
0070 LET PRICE(ITEMNO)=25
0080 LET NUMBER(ITEMNO)=9
0090 ENDIF
0100 NEXT ITEMNO
0110 PRINT "ITEMNO","NUMBER","PRICE"
0120 FOR I=1 TO 4
0130 PRINT I,NUMBER(I),PRICE(I)
0140 NEXT I
0150 STOP
ITEMNO NUMBER PRICE
1 7 10
2 9 25
3 7 10
&_ 4 9 25
3.17I_N_P_U_T_
F_o_r_m_a_t_
var' ,var'
INPUT slit-0', svar' ,slit-n' ,svar' ...
slit-0, slit-n': string literals.
var': a numeric variable.
svar': a string variable.
U_s_e_
As a statement or command to assign values entered from the
user"s terminal during program execution to a list of numeric or
string variables.
R_e_m_a_r_k_s_
1. When an INPUT statement is executed, the system outputs a
question mark (?) as an initial prompt unless the INPUT\f
statement contains slit-0', in which case slit-0' is
output.
2. The user responds by typing a list of data items, each of
which is separated from the next by a comma. The last item is
followed by a carriage return.
3. Data items will be read as long as the arguments in the INPUT
statement are var' or svar'. If a string literal, slit-n',
is encountered in the argument list, slit-n' will be output
and any remaining items entered by the user will be skipped.
4. If the data list is terminated (by pressing the RETURN key)
before values have been assigned to all of the variables in
the argument list, the system will output a question mark as
a prompt, indicating that further items are expected.
5. Data entered in response to a prompt must be of the same type
(numeric or string) as the variable in the argument list for
which the data is being supplied. Variables in the argument
list may be subscripted or unsubscripted.
6. If the entered data does not match the type of a variable
in the argument list, the system will output / ? in response
to the erroneous input. The user can then enter data of the
correct type.
7. A comma may not be used as a separator between string data
items. These items must be separated either by a carriage
return or, if typed on the same line, by a quotation mark (")
followed by a comma.
\f
T_E_x_a_m_p_l_e_ _1_ C_o_m_m_e_n_t_s_ _(_1_)_
* LIST
0010 DIM NAME<(20),ADDRESS<(20)
0020 INPUT NAME<,ADDRESS<
0030 PRINT NAME<,ADDRESS<
0040 INPUT "NAME ",NAME<,"ADDRESS ",ADDRESS<
0050 PRINT NAME<,ADDRESS<
* RUN
? R_O_B_E_R_T_ _C_L_A_R_K_ __
? 9_ _M_A_I_N_ _S_T_R_E_E_T_ __
ROBERT CLARK 9 MAIN STREET PRINT output.
NAME R_A_Y_M_O_N_D_ _C_L_A_R_K_E_ __
ADDRESS 6_1_ _H_I_G_H_W_A_Y_ __
RAYMOND CLARKE 61 HIGHWAY PRINT output.
END The underlined texts are
AT 0050 those entered by the user.
&_*
T_ E_x_a_m_p_l_e_ _2_ C_o_m_m_e_n_t_s_ _(_2_)_
* LIST The underlined texts are
0010 INPUT N1,N2,N3,N4 those entered by the user.
0020 PRINT N1;N2;N3;N4
* RUN
? 1__ _ A question mark is output
? 2__ _ as a prompt until data
? 3__ _ has been supplied for all
? 4___arguments.
1 2 3 4
&_
T_END
AT 0020
* RUN
? 5_,_6_,_7_,_8_ _ _ All data items can be
5 6 7 8 typed on a single line
when separated by commas.
END
&_AT 0020\f
T_* RUN
? 9_ __
? U___ The type of the entered data
/ ? 8___items must match the type of
? 7_ __the arguments.
? Y__ _
/ ? 6__ _
9 8 7 6
END
AT 0020
&_*
T_ 3.18L_E_T_
F_o_r_m_a_t_
var'var'
LET svar' = expr' ; svar' = expr' ...
&_
var': a numeric variable.
svar': a string variable.
expr': a numeric, relational, or string expression.
U_s_e_
As a statement or command to evaluate an expression and assign
the resultant value to a variable.
R_e_m_a_r_k_s_
1. Use of the mnemonic LET is optional.
2. The variables may be subscripted.
3. Numeric or relational expressions may be assigned to numeric
variables.
4. String expressions may be assigned to string variables.
\f
T_E_x_a_m_p_l_e_ _1_ C_o_m_m_e_n_t_ _(_1_)_
10 LET A=A+1 The variable A is assigned a
value one greater than it was
&_before.
T_E_x_a_m_p_l_e_ _2_ C_o_m_m_e_n_t_ _(_2_)_
20 A(2,1)=B 2+10 The element in row 2, column 1
of the array A is assigned
the value of the expression
&_ B 2+10.
T_E_x_a_m_p_l_e_ _3_ C_o_m_m_e_n_t_ _(_3_)_
0010 LET I=3 One line may contain several
0020 LET J=4 assignments as shown in line
0030 LET K=I+J; L=I*J 30.
0040 PRINT I,J,K,L
0050 STOP
&_ 3 4 7 12
T_3.19N_E_W_
For description, see Chapter 9.
&_
T_3.20O_N_-_E_R_R_
F_o_r_m_a_t_
ON ERR THEN statement'
statement': any RC BASIC statement except CASE-WHEN-
ENDCASE, DATA, DEF, END, FOR-NEXT, ENDIF,
ELSE, ON, PROC-ENDPROC, REM, REPEAT-UNTIL,
and WHILE-ENDWHILE.
&_
U_s_e_
As a statement to enable the programmer to take special action,
if an error occurs during program execution.
\f
R_e_m_a_r_k_s_
1. Usually a program is interrupted and an error message output,
if an error occurs during program execution. If an ON-ERR
statement has been executed, however, a run-time error will
cause statement' to be executed.
2. The ON-ERR statement closely resembles the ON-ESC statement;
see, therefore, Section 3.21, Remarks 2 to 5, for further
details.
T_E_x_a_m_p_l_e_ C_o_m_m_e_n_t_
0010 ON ERR THEN EXEC OUTERROR If an error occurs, the
0020 LET A=10/0 error codewill be output
0030 LET B=D and execution will continue.
0040 LET C=SYS(18)
0050 PROC OUTERROR
0060 PRINT "ERROR :";SYS(7)
0070 ON ERR THEN EXEC OUTERROR
0080 ENDPROC
ERROR : 16 0016: ARITHMETIC ERROR
ERROR : 17 0017: UNDEFINED VARIABLE
ERROR : 34 0034: ILLEGAL FUNCTION
ARGUMENT
&_
T_3.21O_N_-_E_S_C_
F_o_r_m_a_t_
ON ESC THEN statement'
statement' : any RC BASIC statement except CASE-WHEN-
ENDCASE, DATA, DEF, END, FOR-NEXT, ENDIF,
ELSE, ON, PROC-ENDPROC, REM, REPEAT-UNTIL,
and WHILE-ENDWHILE.
&_
U_s_e_
As a statement to enable the programmer to take special action,
if the ESCape key is pressed during program execution.
\f
R_e_m_a_r_k_s_
1. Usually a program is interrupted, if the ESCape key is
pressed during program execution. If an ON-ESC statement has
been executed, however, pressing the ESCape key will cause
statement' to be executed.
2. If the ESCape key has been pressed once and statement' has
been executed, the program will be interrupted if the ESCape
key is pressed again, unless a new ON-ESC statement has been
executed (see Example).
3. If statement' is a GOSUB or EXEC statement, then when a
RETURN or ENDPROC statement is encountered, control will be
transferred to the statement following the last statement
executed before the ESCape key was pressed.
4. ON-ESC statements may be placed anywhere in a program, so
that different actions may be taken in different parts of the
program.
5. Execution of the statement ON ESC THEN STOP will in all
circumstances cause restoration of the normal ESCape key
function.
\f
T_E_x_a_m_p_l_e_ C_o_m_m_e_n_t_
* LIST
0010 ON ESC THEN GOSUB 0060
0020 FOR I=1 TO 20
0030 PRINT I;
0040 NEXT I
0050 STOP
0060 PRINT
0070 PRINT "ESCAPE PRESSED, I = ";I
0080 RETURN
* RUN
1 2 3 4 5
ESCAPE PRESSED, I = 6
7 8 9 10 11 1 When ESC is pressed a
STOP second time, the program
AT 0030is interrupted.
* LIST
0010 ON ESC THEN GOSUB 0060
0020 FOR I=1 TO 20
0030 PRINT I;
0040 NEXT I
0050 STOP
0060 PRINT
0070 PRINT "ESCAPE PRESSED, I = ";I
0075 ON ESC THEN GOSUB 0060 This statement has been
0080 RETURN inserted in the program
above.
* RUN
1 2 3 4 5
ESCAPE PRESSED, I = 5
6 7 8 9 1
ESCAPE PRESSED, I = 10
11 12 13 14 15 16
ESCAPE PRESSED, I = 16
17 18 19 20
STOP
AT 0050
&_*\f
T_ 3.22O_N_-_G_O_T_O_/_G_O_S_U_B_
F_o_r_m_a_t_
GOTO
ON expr' THEN GOSUB line no.' ,line no.' ...
expr': a numeric expression which is evaluated to an
integer.
line no.': a line number in the current program. The
positions of line numbers in the argument list
are numbered in sequence from 1 to n.
U_s_e_
As a statement to transfer control to one of several lines in a
program depending on the computed value of an expression when
the ON statement is executed.
R_e_m_a_r_k_s_
1. expr' is evaluated. If it is not an integer, the fractional
part is ignored.
2. The program transfers control to the line whose s_e_q_u_e_n_c_e_
n_u_m_b_e_r_ _i_n_ _t_h_e_ _a_r_g_u_m_e_n_t_ _l_i_s_t_ corresponds to the computed value
of expr'.
3. If expr' evaluates to an integer that is greater than the
sequence number of the last line number in the argument list
or that is less than or equal to zero, the ON statement is
ignored and control passes to the next statement.
4. The ON-GOSUB statement must contain a list of line numbers
each of which is the first line of a subroutine within the
current program.
\f
T_E_x_a_m_p_l_e_ C_o_m_m_e_n_t_
10 ON M-5 GOTO 500,75,1000 If M-5 evaluates to 1, 2, or
3, control will be trans-
ferred to line number 500,
75, or 1000, respectively.
If M-5evaluates to any
other value, control will be
transferred to the next
sequential statement in the
program.
&_
T_ 3.23P_A_G_E_
For description, see Chapter 9.
&_
T_ 3.24P_R_I_N_T_
F_o_r_m_a_t_
expr' expr'
;slit' , slit' ,
PRINT svar' ; svar' ... ;
expr': a numeric or relational expression.
slit': a string literal.
svar': a string variable.
&_
U_s_e_
As a statement or command to perform any of the following output
operations at the user"s terminal:
1. Print variables and constants (numeric or string).
2. Print the result of a computation.
3. Print a combination of 1 and 2.
4. Print a blank line (skip a line).
\f
R_e_m_a_r_k_s_
1. P_r_i_n_t_i_n_g_ _n_u_m_b_e_r_s_
Numbers (integer, decimal, or E-type) are printed in the
following form:
sign'number'space'
The sign is either minus (-) or a blank space for plus; the
number is always followed by a blank space (see Ch. 2).
2. Z_o_n_e_ _s_p_a_c_i_n_g_ _o_f_ _o_u_t_p_u_t_
The print line on a terminal is divided into print zones. The
width of a print zone can be set by means of the TAB command
(see Ch. 9). The default zone spacing is 14 columns. This
T_ spacing is used in the examples below. The first column on a
print line is column number 0.
0 13 14 27 28 41 42 55 56 69
14 14 14 14 14
columns columns columns columns columns
&_
A c_o_m_m_a_ (,) between items in the argument list causes the
next print element to be output starting from the leftmost
position of the next zone. If there are no more zones on the
current line, printing continues in the first zone on the
next line. If a print element requires more than one zone,
the next element is printed in the next free zone (see Exx.
1 and 3).
Before each print element is output, its length is compared
with the space remaining on the current line. If the space is
insufficient, the element is moved to the next line. If the
length of an element is greater than the length of the print
line (see the PAGE command, Ch. 9), the error message 0036:
PRINT ELEMENT TOO LONG is output.
3. C_o_m_p_a_c_t_ _s_p_a_c_i_n_g_ _o_f_ _o_u_t_p_u_t_
A s_e_m_i_c_o_l_o_n_ (;) between items in the argument list causes the
next print element to be output starting from the next
character position.
N_o_t_e_:_ A blank space is always printed after a number. A blank\f
space is also reserved for the plus (+) sign, even though the
sign is not printed (see Ex. 2).
4. S_p_a_c_i_n_g_ _t_o_ _t_h_e_ _n_e_x_t_ _l_i_n_e_
When the last element in a PRINT statement argument list has
been printed, a carriage return and line feed are output
u_n_l_e_s_s_ this last element is followed by a comma or a semi-
colon, in which case the carriage return and line feed are
suppressed and the elements in the next PRINT statement
argument list are printed on the same line in accordance with
the comma or semicolon punctuation (see Exx. 2 and 3).
5. P_r_i_n_t_i_n_g_ _b_l_a_n_k_ _l_i_n_e_s_
A PRINT statement with no arguments or punctuation causes a
carriage return and line feed to be output (see Ex. 4).
6. A_d_d_i_t_i_o_n_a_l_ _p_r_i_n_t_i_n_g_ _v_e_r_s_a_t_i_l_i_t_y_
See the TAB(X) function (Sect. 3.35), the PAGE and TAB
commands (Ch. 9), and the PRINT USING statement (Sect. 3.25).
T_E_x_a_m_p_l_e_ _1_ C_o_m_m_e_n_t_ _(_1_)_
0010 LET X=25 If a print element
0020 PRINT "THE SQUARE ROOT OF X IS:",SQR(X)requires more than
0030 STOP one zone, the next
element is printed
in the next free
012345678901234567890123456789012345678901zone.
&_THE SQUARE ROOT OF X IS: 5 \f
T_ E_x_a_m_p_l_e_ _2_ C_o_m_m_e_n_t_ _(_2_)_
0010 LET X=5 Shows the use of
0020 PRINT X;X X;X*X;X 2; the semicolon as
0030 PRINT SQR(X);SQR(X) 2 a spacing charac-
0040 PRINT -X;(-X) 3 ter. The semicolon
0050 STOPterminating line
20 suppresses a
carriage return
012345678901234567890123456789012345678901and line feed.
5 3125 25 25 2.23607 5
&_-5 -125
T_ E_x_a_m_p_l_e_ _3_ C_o_m_m_e_n_t_ _(_3_)_
0010 LET X=100 Shows the use of
0020 PRINT X,X 2,SQR(X), the comma as a
0030 PRINT X 3 spacing character.
0040 PRINT "END" The comma termina-
0050 STOPting line 20 sup-
presses a carriage
return and line feed.
01234567890123456789012345678901234567890123456789012345
100 10000 10 1E+6
&_END
T_ E_x_a_m_p_l_e_ _4_ C_o_m_m_e_n_t_ _(_4_)_
0010 LET X=10 The PRINT statement
0020 PRINT X, in line 40 causes a
0030 PRINT X 2, carriage return
0040 PRINTand line feed to
0050 PRINT X,be output.
0060 PRINT X 2
0070 PRINT"END"
0080 STOP
0123456789012345678901234567
10 100
10 100
&_END\f
T_ E_x_a_m_p_l_e_ _5_ C_o_m_m_e_n_t_ _(_5_)_
0010 DIM A<(10) If a print ele-
0020 LET A<="ABCDE" ment is a rela-
0030 PRINT A<="ABCDE";A<"ABCDEF";A<'"B";1=1;2'5tional expres-
0040 STOPsion, either
the word TRUE
TRUE TRUE FALSE TRUE FALSE or the word
FALSE will be
printed.
T_ 3.25P_R_I_N_T_ _U_S_I_N_G_
F_o_r_m_a_t_
expr' expr'
PRINT USING format', slit' , slit' ... ,
svar' ; svar' ;
&_
format': a string literal or string variable that
specifies the format (see Remarks) for printing
the items in the argument list.
expr': a numeric or relational expression.
slit': a string literal.
svar': a string variable.
U_s_e_
As a statement to output the values of items in the argument
list using a specified format.
R_e_m_a_r_k_s_
1. The occurrence of a separator other than a comma, e.g. a
semicolon or TAB, between items in the argument list will
cause the remaining items to be printed as if no format had
been specified (see the PRINT statement, Sect. 3.24).
2. The PRINT USING statement is executed as a PRINT statement
(see Sect. 3.24); however, if the system does not include the
PRINT USING facility, execution of a PRINT USING statement
will cause the string format' to be printed, followed by the
items in the argument list.
3. The format' expression may have more than one format'\f
field and may include string literals as well as the
following special characters, which are used to format
numeric output:
# . + - < ,
N_o_t_e_:_ The character is used in the following descriptions to
indicate a blank space.
a. D_i_g_i_t_a_l_ _r_e_p_r_e_s_e_n_t_a_t_i_o_n_ _(_#_)_
For each # in the format' field, a digit (0-9) is substi-
tuted from the expr' argument.
_f_o_r_m_a_t_'_ _e_x_p_r_'_ O_u_t_p_u_t_ C_o_m_m_e_n_t_s_
#####2525 The digits are
right justified in
the field with
leading blanks.
##### -30 30 Signs and othernon
digits are ignored.
##### 1.95 2 Only integers are
represented; the
number is rounded
to an integer.
##### 598745 ***** If the number in
expr' has more
digits than speci-
fied by format',
a field of all as-
terisks is output.
T_ b. D_e_c_i_m_a_l_ _p_o_i_n_t_ _(_._)_
The decimal character (.) places a decimal point within the
&_ string of digits in the fixed position in which it appears in
format'. Digit (#) positions which follow the decimal point
are filled; no blank spaces are left in these digit
positions. When expr' contains more fractional digits than
format' allows, the fraction will be rounded to the limits
of format'. When expr' contains less fractional digits than
specified by format' , zeroes are output to fill the
positions. \f
T_ _f_o_r_m_a_t_'_ _e_x_p_r_'_ O_u_t_p_u_t_ C_o_m_m_e_n_t_s_
#####.## 20 20.00 Fractional posi-
tions are filled
with zeroes.
#####.## 29.347 29.35 Rounding occurson
fractions.
#####.## 789012.34 ******** When expr' has
too many signi-
ficant digits to
the left of a de-
cimal point, a
field of all aste-
risks, including
the decimal point,
is output.
T_ c. F_i_x_e_d_ _s_i_g_n_ _(_+_ _o_r_ _-_)_
&_ A fixed sign character appears as a single plus (+) or
minus (-) sign either in the first character position or
in the last character position in the format' field.
A fixed plus (+) sign prints the sign (+ or -) of expr'
in the position in which the fixed plus (+) sign is placed
in format'.
A fixed minus (-) sign prints a minus (-) sign for
negative values of expr' or a blank space for positive
values of expr' in the position in which the fixed minus
(-) sign is placed in format'.
When a fixed sign is used, any leading zeroes appearing in
expr' will be replaced by blanks, except for a single
leading zero preceding a decimal point.\f
T_ _f_o_r_m_a_t_'_ _e_x_p_r_'_ O_u_t_p_u_t_ C_o_m_m_e_n_t_s_
+##.## 20.5 +20.50
+##.## 1.01 +1.01 Blanks precede the
number.
+##.## -1.236 -1.24
+##.## -234.0 ******
###.##- 20.5 20.50
###.##- 000.01 0.01 One leading zero
before the decimal
point is printed.
###.##- -1.236 1.24-
&_ ###.##- -234.0 234.00-
d. F_l_o_a_t_i_n_g_ _s_i_g_n_ _(_+_+_ _o_r_ _-_-_)_
A floating sign appears as two or more plus (++) or minus
(--) signs at the beginning of the format' field.
A floating plus (++) sign outputs a plus or minus sign
immediately before the value of expr' with no separating
blank spaces as would occur with a fixed sign.
A floating minus (--) sign outputs either a minus or a
blank (for plus) immediately preceding the value.
Positions occupied in format' by the second sign and any
additional signs can be used for numeric positions in the
value of expr'.
\f
T_ _f_o_r_m_a_t_'_ _e_x_p_r_'_ O_u_t_p_u_t_ C_o_m_m_e_n_t_s_
---.## -20 -20.00 The second and
third minus signs
are treated as #
on output.
---.## -200 ******Too many digits
to the left of the
decimal point.
---.## 2 2.00
Note that format' may include a floating sign (++ or
--) or a floating dollar sign (<<), as described below,
but not both.
e.F_i_x_e_d_ _d_o_l_l_a_r_ _s_i_g_n_ _(_<_)_
A fixed dollar sign appears as a single dollar (<) sign in
either the first or the second character position in the
format' field, causing a dollar (<) sign to be output in
that position. If the dollar sign (<) is in the second
position, it must be preceded by a fixed sign (+ or -).
A fixed dollar sign (<) causes leading zeroes in the value
of expr' to be replaced by blanks.
T_ _f_o_r_m_a_t_'_ _e_x_p_r_'_ O_u_t_p_u_t_ C_o_m_m_e_n_t_s_
-<###.## 30.512 <30.51
<###.##+ -30.512 <30.51-
&_
f. F_l_o_a_t_i_n_g_ _d_o_l_l_a_r_ _s_i_g_n_ _(_<_<_)_
A floating dollar sign appears as two or more dollar (<<)
signs beginning in either the first or the second
character position in the format' field. If the dollar
signs (<<) start in the second position, they must be
preceded by a fixed sign (+ or -).
A floating dollar sign (<<) causes a dollar (<) sign to be
placed immediately before the first digit of the expr'
value.
\f
Note that format' may include a floating dollar sign (<<)
or a floating sign (++ or --), as described above, but not
both.
T_ _f_o_r_m_a_t_'_ _e_x_p_r_'_ O_u_t_p_u_t_ C_o_m_m_e_n_t_s_
+<<<#.## 13.20 +<13.20 Additional
dollar signs
may be replaced
by #,as with
floating signs
(++ and --).
&_
<<##.##- -1.0 <01.00- Leading zeroes
are not sup-
pressed in the #
part of the
field.
g. S_e_p_a_r_a_t_o_r_ _(_,_)_
The comma separator (,) places a comma in the fixed
position in which it appears in a string of digits in the
format' field.
If a comma would be output in a field of suppressed
leading zeroes (blanks), a blank space is output in the
position for the comma.
T_ _f_o_r_m_a_t_'_ _e_x_p_r_'_ O_u_t_p_u_t_ C_o_m_m_e_n_t_s_
+<#,###.## 30.6 +<30.60 A blank space
is output for
the comma.
+<#,###.## 2000 +<2,000.00
++##,### 00033 +00,033 A comma is
printed when
leading zeroes
are not
suppressed.
&_ \f
T_ h. E_x_p_o_n_e_n_t_ _i_n_d_i_c_a_t_o_r_ _(_ _ _ _ _)_
Four consecutive up-arrows ( ) are used to indicate an
&_ exponent field in format'. The four arrows will be output
as E+nn, where each n is a digit.
If the exponent field in format' does not contain exactly
four up-arrows, a run-time error will result.
T_ _f_o_r_m_a_t_'_ _e_x_p_r_'_ O_u_t_p_u_t_ C_o_m_m_e_n_t_s_
+##.## 170.35 +17.03E+01
+##.## -.2 -20.00E-02
++##.## 6002.35 +600.24E+01
&_
4. A format' expression, as previously remarked, may have more
than one format' field and may include string literals as
well as the special formatting characters just described.
Values of items in the argument list of the PRINT USING
statement are sequentially assigned to format' fields.
RC BASIC distinguishes string literals from format' fields
by the characters that appear in the latter, for example:
"TWO FOR <1.25" <1.25 is part of the string
literal.
"TWO FOR <<<.##" <<<.## is a format' field
in theformat' expression.
"ANSWER IS -85" -85 are characters of a
string literal.
"ANSWER IS -###" -### is a format' field in
the format' expression.
T_5. A format' expression may be specified by referencing a
previously defined string variable, for example:
15 DIM S<(10)
20 LET S<="##.##"
30 PRINT USING S<,1.5,2
&_
6. format' fields in a format' expression are delimited by the
use of a non-formatting character before or after the format'\f
T_ field, for example:
f_i_e_l_d_ _d_e_l_i_m_i_t_e_r_ f_i_e_l_d_ _d_e_l_i_m_i_t_e_r_
"#####FOR<<###.##"
format field format field
string literal
&_
7. String literals may appear in the argument list of the PRINT
USING statement and will be superimposed on a format' field
in the following manner:
a. Each character of the string literal replaces a single
format' field character, which may be any of the special
formatting characters, i.e. #, decimal point, +, -, <,
comma, and .
b. Strings are left justified in the format' field, and
filled with spaces, if necessary.
c. If the number of characters in the string is greater than
the number of characters in the format' field, the string
will be truncated to fit the field, for example:
5 PRINT USING "###,###.##","TEST","CHARACTER","SEVENTY-FIVE"
RUN
TESTCHARACTERSEVENTY-FI
8. When there are more items in the argument list than format'
fields in the format' expression, the format' fields will
be used repetitively. Thus, for example, in
"####Æ<###.##PER###"
the first, fourth, seventh, etc. items will be formatted using
the format' field ####; the second, fifth, eighth, etc. items
using the format' field <###.##; and the third, sixth, ninth,
etc. items using the format' field ###. The embedded blank
spaces, Æ sign, and PER are string literals and delimitthe
format' fields.
\f
E_x_a_m_p_l_e_s_ C_o_m_m_e_n_t_s_
.
.
.
100 PRINT USING "A(#)=##.#",I,A(I)
.
.
.
RUN
A(1)=17.9 Possible output includes two
format' fields and two
string literals.
.
.
.
100 PRINT USING "###.##",I,A,B
.
.
.
RUN
1.0017.9025.77 Possible output with the
format' expression repeated
for each item in the
argument list.
T_ 3.26P_R_O_C_-_E_N_D_P_R_O_C_
F_o_r_m_a_t_
PROC name'
statements'
&_ENDPROC comment'
name': the name of a procedure. name' may also be
a simple numeric variable.
statements':a block of statements.
comment': a text comment.
U_s_e_
As a statement to define a procedure which can be called by \f
means of an EXEC statement (see Sect. 3.10).
R_e_m_a_r_k_s_
1. A procedure is a convenient means of executing the same
block of statements at different places in a program.
Procedures may be nested to a depth of seven. Nesting occurs
when a procedure is called during the execution of another
procedure.
2. R_u_l_e_s_
a. For every PROC/ENDPROC statement there must be one and
only one ENDPROC/PROC statement.
b. A procedure may be placed anywhere in the program. When a
PROC statement is encountered, a search is made for the
corresponding ENDPROC statement, and program execution
continues from the first statement following this ENDPROC
statement.
c. If the body of a procedure is entered without use of an
EXEC statement, the error message 0019: RETURN WITHOUT
GOSUB will be output when the ENDPROC statement is
encountered.
d. A procedure may contain one or more RETURN statements.
When encountered, RETURN has the effect of an ENDPROC
statement.
e. If the name of the procedure, name', is a simple numeric
variable, it may be assigned a value before the procedure
is called; it may also be assigned a new value by the
procedure before control is returned to the main program.
3. P_r_o_g_r_a_m_ _o_p_e_r_a_t_i_o_n_
a. When the procedure is called, execution starts at the
first statement following the PROC statement.
b. Execution continues until a RETURN or ENDPROC statement is
encountered; after this, control is passed to the first
statement following the EXEC statement that called the
procedure.
4. The word ENDPROC may be followed by a comment. \f
T_E_x_a_m_p_l_e_
0010 PROC GCD
0020 REM THE PROCEDURE FINDS THE GREATEST COMMON DIVISOR IN AAND B
0030 PRINT "GCD IN";A;"AND";B;":",
0040 WHILE A'B DO
0050 IF A'B THEN
0060 LET A=A-B
0070 ELSE
0075 LET B=B-A
0080 ENDIF
0090 ENDWHILE
0100 LET GCD=A
0110 REM A AND B DESTROYED
0120 ENDPROC
0130 REM
0140 REM MAIN PROGRAM, A AND B ARE READ FROM THE TERMINAL
0150 REM
0160 INPUT A,B
0170 IF (A=0) OR (B=0) THEN STOP
0180 EXEC GCD
0190 PRINT GCD
0200 GOTO 0160
&_
T_GCD IN 1 AND 1 : 1
GCD IN 2 AND 4 : 2
GCD IN 24 AND 68 : 4
GCD IN 24 AND 16 : 8
GCD IN 16 AND 24 : 8
GCD IN 345 AND 27 : 3
GCD IN 345 AND 344 : 1
GCD IN 6 AND 11 : 1
GCD IN 11 AND 66 : 11
GCD IN 1 AND 100 : 1
GCD IN 56 AND 7 : 7
GCD IN 56 AND 8 : 8
&_
T_3.27R_A_N_D_O_M_I_Z_E_
F_o_r_m_a_t_
&_RANDOMIZE \f
U_s_e_
As a statement or command to cause the random number generator
to start at a different point in the sequence of random numbers
generated by the RND(X) function (see Ch. 4).
R_e_m_a_r_k_s_
1. Normally, the same sequence of random numbers is generated by
successive use of the RND(X) function. This feature is useful
in debugging programs. If, when the program has been found to
run successfully, different starting points in the sequence
are desired, the RANDOMIZE statement should be included in
the program before the first occurrence of an RND(X)
function.
2. The RANDOMIZE statement resets the random number generator
based on the time of day, thereby producing different random
numbers each time a program using the RND(X) function is run.
T_ E_x_a_m_p_l_e_ C_o_m_m_e_n_t_
* LIST This program produces
0010 LET I=0 different results each time
0015 RANDOMIZE it is executed.
0020 REPEAT
0030 PRINT RND(I);
0040 LET I=I+1
0050 UNTIL I=4
0060 STOP
0070 GOTO 0010
* RUN
.921699 .341465 .710697 .816505
STOP
AT 0060
* RUN
.249755 .980187 .616137 .890037
STOP
AT 0060
* CON
.159747 .605283 .118429 .322262
STOP
AT 0060
&_*\f
T_ 3.28R_E_A_D_
F_o_r_m_a_t_
var',var'
READ svar' ,svar' ...
var': a numeric variable.
svar': a string variable.
&_
U_s_e_
As a statement or command to read in values from the list
defined by one or more DATA statements and to assign the values
to the variables listed in the READ statement.
R_e_m_a_r_k_s_
1. READ statements are always used in conjunction with DATA
statements (see Sect. 3.4).
2. The variables listed in the READ statement may be subscripted
or unsubscripted numeric or string variables.
3. The order in which variables appear in the READ statement is
the order in which values for the variables are retrieved
from the DATA statement list.
4. A data element pointer is moved to the next available value
in the DATA statement list as values are retrieved for
variables in the READ statement. If the number of variables
in the READ statement exceeds the number of values in the
DATA statement list, the error message 0015: NO MORE DATA FOR
READ is output.
5. The type (numeric or string) of the READ statement variable
must match the type of the corresponding data element value,
otherwise the error message 0066: TYPE CONFLICT is output.
6. The RESTORE statement (see Sect. 3.31) can be used to reset
the data element pointer to the first item of the lowest
numbered DATA statement or the first item of a particular
DATA statement.
\f
T_E_x_a_m_p_l_e_
0010 DIM TEXT<(20),A(10)
0020 READ TEXT<,NUMBER
0030 DATA "READ DATA",25,1,2
0040 READ A(2),A(4)
0050 PRINT "TEXT","NUMBER","A(2)","A(4)"
0060 PRINT TEXT<,NUMBER,A(2),A(4)
0070 STOP
TEXT NUMBER A(2) A(4)
READ DATA 25 1 2
T_3.29R_E_M_
F_o_r_m_a_t_
REM comment'
comment': a text comment.
&_
U_s_e_
As a statement to insert explanatory comments within a program.
R_e_m_a_r_k_s_
1. REM statements are non-executable, but are stored with the
program and output exactly as entered when LISTed (see LIST,
Ch. 9).
2. If control is transferred to a REM statement from a GOTO or
GOSUB statement, execution continues from the next executable
statement following the REM statement. If no executable state-
ment follows the REM statement, the program will act as if an
END statement (see Sect. 3.8) had been encountered and
control will return to interactive mode.
3. Optional text comments may also be inserted after the
words ENDCASE, END, RETURN, ENDIF, ELSE, ENDPROC, REPEAT,
STOP, and ENDWHILE, for example:
ENDWHILE END OF SEARCH\f
T_E_x_a_m_p_l_e_
10 REM REMARKS THROUGHOUT A PROGRAM CAN
20 REM HELP EXPLAIN THE PURPOSE OF STATEMENTS.
30 REM LINES 10, 20, and 30 ARE NOT EXECUTED.
&_
T_ 3.30R_E_P_E_A_T_-_U_N_T_I_L_
F_o_r_m_a_t_
REPEAT comment'
statements'
UNTIL expr'
comment': a text comment.
statements': a block of statements.
expr': a relational expression.
U_s_e_
As a statement to execute a block of statements repetitively
until the value of an expression is true.
R_e_m_a_r_k_s_
1. R_u_l_e_s_
a. expr' is a relational expression whose value is either
true or false, e.g. NAME< = "JOHN", I ' 25.
b. If the body of a REPEAT-UNTIL loop is entered at any point
other than the REPEAT statement, the error message 0058:
UNTIL WITHOUT REPEAT will be output when the UNTIL state-
ment corresponding to the skipped REPEAT statement is
encountered.
2. P_r_o_g_r_a_m_ _l_o_o_p_ _o_p_e_r_a_t_i_o_n_
a. statements' is executed.
b. expr' is evaluated.
c. If the value of expr' is false, step a is repeated.
d. If the value of expr' is true, the termination condition\f
is satisfied and control passes to the first statement
following the corresponding UNTIL statement.
N_o_t_e_:_ statements' is always executed at least once.
3. N_e_s_t_e_d_ _l_o_o_p_s_
REPEAT-UNTIL loops may be nested to a depth of seven.
4. The word REPEAT may be followed by a comment.
T_ E_x_a_m_p_l_e_ _1_ C_o_m_m_e_n_t_ _(_1_)_
0010 LET I=1 The block of statements
0020 REPEAT between REPEAT and
0030 PRINT I; UNTIL is repeated
0040 LET I=I+1until I ' 10.
0050 UNTIL I'10
0060 PRINT "13'10'AFTER "UNTIL", I=";I
0070 STOP
1 2 3 4 5 6 7 8 9 10
&_ AFTER "UNTIL", I= 11
T_E_x_a_m_p_l_e_ _2_ C_o_m_m_e_n_t_ _(_2_)_
0010 LET I=20 The block of statements
0020 REPEAT between REPEAT and
0030 PRINT "EXECUTED ONCE" UNTIL is always execu-
0040 LET I=I-1ted at least once.
0050 UNTIL I'10
0060 PRINT "AFTER "UNTIL", I=";I
0070 STOP
EXECUTED ONCE
&_AFTER "UNTIL", I= 19
\f
T_ E_x_a_m_p_l_e_ _3_ C_o_m_m_e_n_t_ _(_3_)_
0010 LET A=10; B=1 Shows nested REPEAT-UNTIL
0020 REPEATloops.
0030 PRINT
0040 PRINT "A=";A,
0050 REPEAT
0060 PRINT "B=";B;
0070 LET B=B+1
0080 UNTIL B=5
0090 LET B=1; A=A-1
0100 UNTIL A7
0110 PRINT
0120 PRINT "AFTER LAST "UNTIL", A,B=";A;B
&_ 0130 STOP
T_A= 10 B= 1 B= 2 B= 3 B= 4
A= 9 B= 1 B= 2 B= 3 B= 4
A= 8 B= 1 B= 2 B= 3 B= 4
A= 7 B= 1 B= 2 B= 3 B= 4
AFTER LAST "UNTIL", A,B= 6 1
&_
T_3.31R_E_S_T_O_R_E_
F_o_r_m_a_t_
RESTORE line no.'
line no.': a DATA statement line number.
&_
U_s_e_
As a statement or command to reset the data element pointer
either to the beginning of the DATA statement list or to a
particular DATA statement.
R_e_m_a_r_k_s_
1. If the RESTORE statement is used without an argument, the
data element pointer is reset to the beginning of the DATA
statement list, i.e. to the first item in the lowest numbered
DATA statement (see Sect. 3.4).
2. If the RESTORE statement contains an argument, the data
element pointer is reset to the first item in the DATA\f
statement specified by line no'.
3. If line no.' does not exist in the program, the data element
pointer is reset to the beginning of the DATA statementlist.
T_E_x_a_m_p_l_e_ C_o_m_m_e_n_t_
0010 DATA 1,2,3,4 One can choose among several
0020 READ I,J,K,L DATA statements by means of
0030 RESTORE RESTORE. In line 30, the
0040 REM RESET TO BEGINNING data element pointer is
0050 READ M,N reset to the beginning of
0060 RESTORE 0100 the DATA statement list.
0070 REM RESET TO LINE 100
0080 READ O,P,Q,R
0090 PRINT I;J;K;L;M;N;O;P;Q;R
0100 DATA 5,6,7,8
0110 STOP
&_ 1 2 3 4 1 2 5 6 7 8
T_ 3.32S_A_V_E_
For description, see Chapter 9.
&_
T_ 3.33S_T_O_P_
F_o_r_m_a_t_
STOP comment'
comment': a text comment.
&_
U_s_e_
As a statement to terminate execution of the current program and
to return control to interactive mode.
R_e_m_a_r_k_s_
1. STOP statements may be placed anywhere in the program. When
STOP is encountered, the system will terminate execution and\f
output the following on the user"s terminal:
STOP
AT xxxx'
*
xxxx': the line number of the STOP statement.
2. After control has returned to interactive mode, the program
may be restarted from the first line number (see RUN, Ch. 9)
or continued in its current state (see CON or RUN line no.',
Ch. 9).
3. The word STOP may be followed by a comment.
T_E_x_a_m_p_l_e_
* LIST
0010 REM TERMINATE PROGRAM BY STOP
0020 INPUT A
0030 IF A0 THEN STOP
0040 GOTO 0020
* RUN
? 1
? 3
? -5
STOP
AT 0030
&_ *
3.34T_A_B_
For description, see Chapter 9.
&_
T_ 3.35T_A_B_(_X_)_ _f_u_n_c_t_i_o_n_
F_o_r_m_a_t_
TAB(expr')
expr': an expression which is evaluated to an integer.
&_ \f
U_s_e_
As a function in PRINT statements (see Sect. 3.24) to tabulate
the printing position for an item in the argument list to the
column number evaluated from an expression.
R_e_m_a_r_k_s_
1. As the print line columns are numbered from 0, t_h_e_ _p_o_s_i_t_i_o_n_
i_n_d_i_c_a_t_e_d_ _b_y_ _t_h_e_ _T_A_B_(_X_)_ _f_u_n_c_t_i_o_n_ _i_s_ _a_l_w_a_y_s_ _r_e_l_a_t_i_v_e_ _t_o_ _0_,
e.g. the column number indicated by TAB(31) is 30.
2. A PRINT statement may contain several TAB(X) functions, each
of which affects only the item in the argument list that
immediately follows it. The printing position for this item
will depend on the value of expr' and the punctuation (; or
,) following TAB(X).
3. If expr' evaluates to a column number greater than or equal
to the current column number and less than the length of the
print line, the value of expr' indicates t_h_e_ _n_e_w_ _c_o_l_u_m_n_
p_o_s_i_t_i_o_n_.
If TAB(X) is followed by a semicolon (;), the new column
position remains unchanged (see Example).
If TAB(X) is followed by a comma (,), the new column position
is changed to the leftmost position of the next print zone
u_n_l_e_s_s_ the new column position coincides with the leftmost
position of a print zone (see Example).
After determination of the new column position, the item in
the argument list immediately following the TAB(X) function
is printed (see Remarks in Sect. 3.24).
4. If expr' evaluates to a column number less than the current
column number, the TAB(X) function is ignored and positioning
proceeds as in 3.
5. If expr' evaluates to a column number greater than the
length of the print line, expr' is reduced modulo the length
of the print line and positioning proceeds as in 3.
The length of the print line (width of the page) can be set
by means of the PAGE command (see Ch. 9). \f
6. If expr' evaluates to 0, e.g. TAB(0), a carriage return and
line feed are output and positioning proceeds as in 3.
E_x_a_m_p_l_e_
0010 LET POS=5; NUMBER=-1048
0020 PRINT TAB(POS);NUMBER;TAB(7*POS);NUMBER
0030 PRINT TAB(POS),NUMBER,TAB(7*POS),NUMBER
0040 PRINT TAB(31);NUMBER
0050 STOP
01234567890123456789012345678901234567890123456789012345
-1048 -1048
-1048 -1048
-1048
C_o_m_m_e_n_t_
Shows the use of the semicolon and the comma as spacing
characters in conjunction with the TAB(X) function.
T_3.36W_H_I_L_E_-_E_N_D_W_H_I_L_E_
F_o_r_m_a_t_
WHILE expr' THEN DO
statements'
ENDWHILE comment'
expr': a relational expression.
statements': a block of statements.
comment': a text comment.
&_
U_s_e_
As a statement to execute a block of statements repetitively
while the value of an expression is true.
R_e_m_a_r_k_s_
1. R_u_l_e_s_
a. expr' is a relational expression whose value is either
true or false, e.g. I = 10, MONTH 13.\f
b. For every WHILE statement there must be a matching
ENDWHILE statement, otherwise the error message 0053:
WHILE WITHOUT ENDWHILE is output.
c. If the body of a WHILE-ENDWHILE loop is entered at any
point other than the WHILE statement, the error message
0054: ENDWHILE WITHOUT WHILE will be output when the
ENDWHILE statement corresponding to the skipped WHILE
statement is encountered.
2. P_r_o_g_r_a_m_ _l_o_o_p_ _o_p_e_r_a_t_i_o_n_
a. expr' is evaluatd.
b. If the value of expr' is false, the termination condition
is satisfied and step e is performed.
c. statements' is executed.
d. Step a is repeated.
e. Control passes to the first statement following the
corresponding ENDWHILE statement.
N_o_t_e_:_ If the value of expr' is false the first time the
WHILE statement is encountered, statements' is not
executed even once.
3. N_e_s_t_e_d_ _l_o_o_p_s_
WHILE-ENDWHILE loops may be nested to a depth of seven.
4. The word ENDWHILE may be followed by a comment.
\f
T_E_x_a_m_p_l_e_ _1_
0010 LET I=1
0020 WHILE I10 DO
0030 PRINT I;
0040 LET I=I+1
0050 ENDWHILE
0060 PRINT "13'10'AFTER "ENDWHILE" "
0070 STOP
1 2 3 4 5 6 7 8 9
&_AFTER "ENDWHILE"
T_E_x_a_m_p_l_e_ _2_ C_o_m_m_e_n_t_ _(_2_)_
0010 LET I=11 If expr' is false when
0020 WHILE I10 DO WHILE is encountered for the
0030 PRINT "DO NOT ENTER HERE" first time, statements' is
0040 LET I=I-1 not executed even once.
0050 ENDWHILE
0060 PRINT "AFTER "ENDWHILE" "
0070 STOP
&_AFTER "ENDWHILE"
\f
T_ E_x_a_m_p_l_e_ _3_ C_o_m_m_e_n_t_ _(_3_)_
0010 LET I=1 Shows nested WHILE-ENDWHILE
0020 WHILE I5 DOloops.
0030 LET J=8
0040 PRINT "I=";I,
0050 WHILE J'I DO
0060 PRINT " J=";J;
0070 LET J=J-1
0080 ENDWHILE
0090 PRINT
0100 LET I=I+1
0110 ENDWHILE
0120 PRINT "AFTER LAST "ENDWHILE" "
0130 STOP
I= 1J= 8 J= 7 J= 6 J= 5 J= 4 J= 3 J= 2
I= 2J= 8 J= 7 J= 6 J= 5 J= 4 J= 3
I= 3J= 8 J= 7 J= 6 J= 5 J= 4
I= 4J= 8 J= 7 J= 6 J= 5
&_AFTER LAST "ENDWHILE"\f
T_4R_C_ _B_A_S_I_C_ _F_U_N_C_T_I_O_N_S_
4.1I_n_t_r_o_d_u_c_t_i_o_n_
RC BASIC provides a number of functions to perform various
&_calculations, thereby eliminating the need to write programs for
these calculations.
RC BASIC functions generally have a three-letter mnemonic name,
followed by a parenthesized expression as an argument, and may
be used as an expression or included as part of an expression.
Standard mathematical functions included in RC BASIC and the
values which they produce are as follows:
ABS(X) Absolute value of X.
ATN(X) Arctangent of X in radians.
COS(X) Cosine of X, where X is in radians.
EXP(X) eUUUXDDD (-178 = X = 175).
LOG(X) Natural logarithm of X (X ' 0).
SIN(X) Sine of X, where X is in radians.
SQR(X) Square root of X (X '= 0).
TAN(X) Tangent of X, where X is in radians.
In addition to these standard arithmetical and trigonometrical
functions, the RC BASIC system includes the following:
FNa(d) Functions defined by the user.
INT(X) Integer value of X.
RND(X) Random number between 0 and 1.
SGN(X) Algebraic sign of X.
SYS(X) System information functions.
Further RC BASIC functions, which are described in other
chapters, are these:
CHR(X) String function (see Ch. 5).
DET(X) Matrix function (see Ch. 6).
EOF(X) File function (see Ch. 8).
LEN(X<) String function (see Ch. 5).
ORD(X<) String function (see Ch. 5).
TAB(X) Printing function (see Ch. 3).\f
T_ 4.2A_B_S_(_X_)_
F_o_r_m_a_t_
ABS(expr')
expr': a numeric expression.
U_s_e_
&_As a function to return the absolute (positive) value of expr'.
T_E_x_a_m_p_l_e_
* LIST
0010 PRINT ABS(-10);ABS(10)
* RUN
10 10
END
AT 0010
&_*
T_ 4.3A_T_N_(_X_)_
F_o_r_m_a_t_
ATN(expr')
expr': a numeric expression (- /2 = ATN(expr') = /2).
U_s_e_
As a function to calculate the angle, in radians, whose tangent
is expr'.
\f
T_E_x_a_m_p_l_e_
* LIST
0010 PRINT ATN(0);ATN(1)*180/SYS(14)
* RUN
0 45
END
AT 0010
&_*
4.4C_O_S_(_X_)_
F_o_r_m_a_t_
&_COS(expr')
expr': a numeric expression specified in radians.
U_s_e_
As a function to calculate the cosine of an angle which is
expressed in radians.
T_E_x_a_m_p_l_e_
* LIST
0010 PRINT COS(0);COS(45*SYS(14)/180)
* RUN
1 .707107
END
AT 0010
&_*
T_ 4.5E_X_P_(_X_)_
F_o_r_m_a_t_
EXP(expr')
&_ expr': a numeric expression (-178 = expr' = 175).\f
U_s_e_
As a function to calculate the value of e (2.71828) to the power
of expr'.
T_E_x_a_m_p_l_e_
* LIST
0010 PRINT EXP(1);EXP(2);EXP(2.5)
* RUN
2.71828 7.38905 12.1825
END
AT 0010
&_*
4.6F_N_a_(_d_)_
For description, see the DEF statement, Chapter 3.
4.7I_N_T_(_X_)_
F_o_r_m_a_t_
INT(expr')
expr': a numeric expression.
U_s_e_
As a function to return the value of the nearest integer not
greater than expr'.\f
T_E_x_a_m_p_l_e_
* LIST
0010 PRINT INT(4.567);INT(-4.567)
* RUN
4 -5
END
AT 0010
*
&_
T_ 4.8L_O_G_(_X_)_
F_o_r_m_a_t_
LOG(expr')
expr': a numeric expression.
&_
U_s_e_
As a function to calculate the n_a_t_u_r_a_l_ logarithm of expr'.
T_E_x_a_m_p_l_e_
* LIST
0010 PRINT LOG(2);LOG(EXP(1))
* RUN
.693149 1
END
AT 0010
*
T_4.9R_N_D_(_X_)_
F_o_r_m_a_t_
&_RND(expr')
expr': a numeric expression (required, but not used). \f
U_s_e_
As a function to produce a pseudo random number, n, such that
0 = n 1.
R_e_m_a_r_k_s_
1. The RND(X) function requires an argument, although the
argument does not affect the resulting random number and the
function does not affect the argument.
2. Each time the RND(X) function is called, it produces a pseudo
random number in the range 0 to 1. The sequence in which
these numbers are generated is fixed. The length of the
sequence is 2 16.
3. As the sequence of random numbers is fixed and the starting
point in the sequence is reset to the same point each time a
NEW or RUN command (see Ch. 9) is given, the sequence of
numbers generated by the RND(X) function is reproducible.
4. The RANDOMIZE statement (see Ch. 3) causes the random number
generator to start at a different point in the sequence of
random numbers generated by the RND(X) function.
5. Each occurrence of the RND(X) function yields the value of
the next random number in the list.\f
T_ E_x_a_m_p_l_e_ _1_
* LIST
0010 LET I=0
0020 REPEAT
0030 PRINT RND(I);
0040 LET I=I+1
0050 UNTIL I=4
0060 STOP
0070 GOTO 0010
* RUN C_o_m_m_e_n_t_ _(_1_)_
.21132 .14464 .852625 .927054
STOP The RUN command resets the
AT 0060 sequence of random numbers;
* RUN the CON command does not.
.21132 .14464 .852625 .927054
STOP
AT 0060
* CON
.162866 .433095 .563933 .20965
STOP
AT 0060
&_*
T_E_x_a_m_p_l_e_ _2_
* LIST
0010 LET I=0
0020 WHILE I4 DO
0030 PRINT INT(25*RND(I));
0040 LET I=I+1
0050 ENDWHILE
* RUN C_o_m_m_e_n_t_ _(_2_)_
5 3 21 23
END The program produces random
AT 0050 integers in the range 0 to
&_*24.\f
T_ 4.10S_G_N_(_X_)_
F_o_r_m_a_t_
SGN(expr')
expr': a numeric expression.
&_
U_s_e_
As a function to return a +1 if expr' is greater than 0, a 0 if
expr' equals 0, and a -1 if expr' is less than 0.
T_E_x_a_m_p_l_e_ C_o_m_m_e_n_t_
* LIST Note that SGN(0) = 0.
0010 PRINT SGN(-5);SGN(0);SGN(5)
* RUN
-1 0 1
END
AT 0010
&_*
T_ 4.11S_I_N_(_X_)_
F_o_r_m_a_t_
SIN(expr')
expr': a numeric expression specified in radians.
&_
U_s_e_
As a function to calculate the sine of an angle which is
expressed in radians.
\f
T_E_x_a_m_p_l_e_
* LIST
0010 PRINT SIN(0);SIN(45*SYS(14)/180)
* RUN
0 .707107
END
AT 0010
&_*
T_ 4.12S_Q_R_(_X_)_
F_o_r_m_a_t_
SQR(expr')
expr': a positive numeric expression.
&_
U_s_e_
As a function to compute the square root of expr'.
T_ E_x_a_m_p_l_e_
* LIST
0010 PRINT SQR(25);SQR(25.734)
* RUN
5 5.07287
END
AT 0010
&_*\f
T_ 4.13S_Y_S_(_X_)_
F_o_r_m_a_t_
SYS(expr')
expr': a numeric expression.
&_
U_s_e_
As a function to return system information based on the value of
expr', which is evaluated to an integer (0 to 15), as follows:
F_u_n_c_t_i_o_n_ I_n_f_o_r_m_a_t_i_o_n_
SYS(0) Time of day (seconds past midnight).
SYS(1) Day of the month (1 to 31).
SYS(2) Month of the year (1 to 12). Current date.
SYS(3) Year as two digits (e.g. 77).
SYS(4) Terminal port number (32, if console).
SYS(5) Time used in seconds since the terminal was
logged on.
SYS(6) Number of file I/O statements executed (i.e.
every statement or command referring to a file,
e.g. PRINT FILE, LIST "<LPT").
SYS(7) Error code of the last run-time error.
SYS(8) File number of the file most recently
referenced in a file I/O statement.
SYS(9) Page size (length of the print line).
SYS(10) Tab size (width of the print zone).
SYS(11) Hour of the day.
SYS(12) Minutes past the last hour. Current time
of day.
SYS(13) Seconds past the last minute. \f
SYS(14) Constant (3.14159).
SYS(15) Constant e (2.71828).
T_ 4.14T_A_N_(_X_)_
F_o_r_m_a_t_
TAN(expr')
expr': a numeric expression specified in radians.
&_
U_s_e_
As a function to calculate the tangent of an angle which is
expressed in radians.
T_E_x_a_m_p_l_e_
* LIST
0010 PRINT TAN(0);TAN(45*SYS(14)/180)
* RUN
0 .999999
END
AT 0010
&_*\f
T_ 5S_T_R_I_N_G_ _I_N_F_O_R_M_A_T_I_O_N_
5.1S_t_r_i_n_g_ _c_o_n_c_e_p_t_
This chapter explains how strings are used in RC BASIC. The
&_string concept is described in the present section, while three
useful string functions, viz. CHR(X), LEN(X<), and ORD(X<) are
described in the remaining sections.
b_5.1.1 S_t_r_i_n_g_ _l_i_t_e_r_a_l_s_ e
A string is a sequence of characters, which may include letters,
digits, spaces, and special characters. A string literal (string
constant) is a string enclosed within quotation marks. String
literals are often used in PRINT and INPUT statements (see Ch.
3), for example:
100 PRINT "THIS IS A STRING LITERAL"
200 INPUT "X=",X
The enclosing quotation marks are not printed when the string
is output. N_o_n_-_p_r_i_n_t_i_n_g_ _a_n_d_ _s_p_e_c_i_a_l_ _c_h_a_r_a_c_t_e_r_s_ _m_a_y_ _b_e_ _i_n_c_l_u_d_e_d_
i_n_ _s_t_r_i_n_g_ _l_i_t_e_r_a_l_s_ _b_y_ _e_n_c_l_o_s_i_n_g_ _t_h_e_ _d_e_c_i_m_a_l_ _v_a_l_u_e_ _o_f_ _t_h_e_
c_h_a_r_a_c_t_e_r_ _w_i_t_h_i_n_ _a_n_g_l_e_ _b_r_a_c_k_e_t_s_ _(__'_)_, for example:
10 PRINT "USE DECIMAL 60 TO PRINT 60' IN STRINGS"
* RUN
USE DECIMAL 60 TO PRINT IN STRINGS
The decimal values of all ASCII characters are given in
Appendix D.
b_ 5.1.2S_t_r_i_n_g_ _v_a_r_i_a_b_l_e_s_ e
RC BASIC permits the use of string variables as well as string
literals. A string variable name consists of a letter, followed
by from 0 to 7 letters or digits, f_o_l_l_o_w_e_d_ _b_y_ _a_ _d_o_l_l_a_r_ _s_i_g_n_ _(_<_)_,
for example:
ANSWER<, TEXT<
String values are assigned to string variables, as described
below, by means of LET, READ, and INPUT statements, for example:
INPUT ANSWER<
LET TEXT<="THIS IS A TEXT"\f
b_5.1.3 D_i_m_e_n_s_i_o_n_i_n_g_ _s_t_r_i_n_g_ _v_a_r_i_a_b_l_e_s_e
All string variables m_u_s_t_ be dimensioned before they are used.
By dimensioning the variable, the user sets an upper bound for
the number of characters that can be stored in it. Dimensioning
T_ is accomplished by means of the DIM statement (see Ch. 3), for
example:
DIM ANSWER<(20)
DIM TEXT<(15),STRING<(5)
&_
If the user attempts to assign a string literal that is too long
T_ to a string variable, the string literal will be truncated, for
example:
10 DIM TEXT<(6)
20 LET TEXT<="LONG STRING"
30 PRINT TEXT<
* RUN
LONG S
&_
A string may be of any length, the sole limitation being
available memory.
b_5.1.4 S_u_b_s_t_r_i_n_g_s_e
One can also reference a portion of a string variable. The
T_ general form of such substrings is the following:
i'
svar'( j,k' )
svar': a string variable name.
&_
i': a numeric expression indicating
that the ith character in svar'
is to be referenced.
j,k': numeric expressions indicating
that the jth through the kth
characters in svar' are to be
referenced.
Example 1 shows how substrings can be referenced.\f
T_ E_x_a_m_p_l_e_ _1_
0010 DIM TEXT<(20)
0020 LET TEXT<="AAAAAAAAAAAAAAAAAAAA"
0030 PRINT TEXT<
0040 LET TEXT<(5)="B"
0050 PRINT TEXT<
0060 LET TEXT<(10,13)="BCDE"
0070 PRINT TEXT<
0080 LET TEXT<(15,17)="BCDEFG"
0090 PRINT TEXT<
0100 PRINT TEXT<(1),TEXT<(8,13),TEXT<(20)
AAAAAAAAAAAAAAAAAAAA
AAAABAAAAAAAAAAAAAAA
AAAABAAAABCDEAAAAAAA
AAAABAAAABCDEABCDAAA
A AABCDE A
&_
N_o_t_e_: When a value is to be assigned to a substring (i,j), a
value must first be assigned to the substring (l,i-l). This can
be done by initializing the entire string with blanks.
b_ 5.1.5 A_s_s_i_g_n_i_n_g_ _v_a_l_u_e_s_ _t_o_ _s_t_r_i_n_g_ _v_a_r_i_a_b_l_e_s_e
Values can be assigned to string variables by means of LET,
READ and DATA, and INPUT statements (see Ch. 3) and READ FILE
and INPUT FILE statements (see Ch. 8). Example 2 shows various
uses of LET, READ and DATA, and INPUT.
T_b_5.1.6 C_o_n_c_a_t_e_n_a_t_i_o_n_ _o_f_ _s_t_r_i_n_g_s_e
Any number of strings (variables or literals) can be concate-
nated by means of a LET statement having the following syntax:
svar' svar'
LET svar' = slit' , slit' ...
svar': a string variable.
slit': a string literal.
&_ See Example 2, lines 50, 80, and 90.
\f
T_ E_x_a_m_p_l_e_ _2_C_o_m_m_e_n_t_ _(_2_)_T_
* LIST
0010 DATA "THIS"," A"
0020 DIM TEXT<(23),TEMP<(5)
0040 READ TEXT<(1,4)
0050 LET TEXT<=TEXT<," IS"
0060 READ TEXT<(LEN(TEXT<)+1,20) For LEN(X<), see
0070 INPUT TEMP< Sect. 5.3.
0080 LET TEXT<=TEXT<," ",TEMP<
0090 LET TEXT<=TEXT<," TEXT"
0100 PRINT TEXT<
* RUN
? S_H_O_R_T_ _ _ The underlined
THIS IS A SHORT TEXT texts are those
entered by the user.
END
AT 0100
* RUN
? L_O_N_G___
THIS IS A LONG TEXT
END
AT 0100
&_ *
N_o_t_e_: When a value is assigned to a substring, the number of
characters in the source string must not be less than the number
of characters in the substring referenced; otherwise, the rest
of the characters in the substring and any remaining characters
in the string will be truncated. Example 3 provides an
illustration of this.
\f
T_ E_x_a_m_p_l_e_ _3_C_o_m_m_e_n_t_ _(_3_)_
* LIST
0010DIM TEXT<(10)
0020 LET TEXT<="AAAAAAAAAA" The underlined
0030 PRINT TEXT< texts are those
0040 INPUT TEXT<(3,7) entered by the user.
0050 PRINT TEXT<
* RUN
AAAAAAAAAA
? 1_2_3___ Source string.
AA123TEXT<(6,10) has
been truncated.
* LIST
0010 DIM TEXT<(10),TEMP<(10) The desired result
0020 LET TEXT<="AAAAAAAAAA"can be achieved in
0030 PRINT TEXT<this way.
0040 INPUT TEMP<
0050 LET TEMP<=TEMP<," "
0060 LET TEXT<(3,7)=TEMP<
0070 PRINT TEXT<
* RUN
AAAAAAAAAA
? 1_2_3___
&_ AA123 AAA
b_ 5.1.7 R_e_l_a_t_i_o_n_a_l_ _s_t_r_i_n_g_ _e_x_p_r_e_s_s_i_o_n_s_e
Strings (literals and variables) may be compared. The result of
a comparison is either true or false. The strings are compared
character by character, on the basis of their decimal values
(see App. D), until a difference is found or the end of one or
both strings is met.
If a character in a given position in one string has a higher
decimal value than the character in the corresponding position
in the other string, the first string is the greater of the two.
If the characters in corresponding positions are identical, but
one string contains more characters than the other, the shorter
string is the lesser of the two. Thus, for example, the
expression "ABC" "ABCD" is true.\f
T_ E_x_a_m_p_l_e_ _1_
IF NAME<(1)="J" THEN
.
.
.
&_
T_ E_x_a_m_p_l_e_ _2_ C_o_m_m_e_n_t_ _(_2_)_
CASE ANSWER<="YES" OF
.
.
.
WHEN 1 1 corresponds to true.
.
.
.
WHEN 0 0 corresponds to false.
.
.
.
ENDCASE
&_
T_ 5.2C_H_R_(_X_)_ _f_u_n_c_t_i_o_n_
F_o_r_m_a_t_
CHR(expr')
expr': a numeric expression.
&_
U_s_e_
As a function to return the character corresponding to the
number specified in the argument.
R_e_m_a_r_k_s_
1. The correspondence between numbers (decimal values) and
characters is shown in Appendix D.
2. The number is found as expr' modulo 128.
3. The CHR(X) function may be used in any string expression.\f
T_ E_x_a_m_p_l_e_ C_o_m_m_e_n_t_
0010 TAB=4
0020 PAGE=32
0030 FOR I=65 TO 74
0040 PRINT I,CHR(I),
0050 NEXT I
65 A 66 B 67 C 68 D The characters corresponding
69 E 70 F 71 G 72 H to the numbers 65-74 are A-J.
&_ 73 I 74 J
T_ 5.3L_E_N_(_X_<_)_ _f_u_n_c_t_i_o_n_
F_o_r_m_a_t_
svar'
LEN( slit' )
svar': a string variable.
slit': a string literal.
&_
U_s_e_
As a function to return the current length (number of
characters) of the string specified in the argument.
R_e_m_a_r_k_s_
1. The LEN(X<) function may be used in any numeric expression.
2. If the string argument is empty, the value returned is 0.
T_E_x_a_m_p_l_e_ C_o_m_m_e_n_t_
0010 DIM TEXT<(10)
0020 TAB=12
0030 PRINT TEXT<,LEN(TEXT<)
0040 FOR I=1 TO 10
0050 LET TEXT<=TEXT<,CHR(I+64) For CHR(X), see Sect. 5.2.
0060 PRINT TEXT<,LEN(TEXT<)
0070 NEXT I
&_\f
T_ 0
A 1
AB 2
ABC 3
ABCD 4
ABCDE 5
ABCDEF 6
ABCDEFG 7
ABCDEFGH 8
ABCDEFGHI 9
&_ABCDEFGHIJ 10
T_ 5.4O_R_D_(_X_<_)_ _f_u_n_c_t_i_o_n_
F_o_r_m_a_t_
svar'
ORD( slit' )
svar': a string variable.
slit': a string literal.
&_
U_s_e_
As a function to return the number of the first character of the
string specified in the argument.
R_e_m_a_r_k_s_
1. The number returned is the character"s decimal value, which
is equivalent to its internal representation. (This number is
also the ordinal number of the character; thus the character
A, for example, which has the decimal value 65, is the 65th
character in the ASCII character set). The correspondence
between numbers and characters is shown in Appendix D.
2. The ORD(X<) function may be used in any numeric expression.
\f
T_ E_x_a_m_p_l_e_ C_o_m_m_e_n_t_
0010 TAB=4
0020 PAGE=32
0030 DIM A<(10)
0040 LET A<="0123456789"
0050 FOR I=1 TO 10
0060 PRINT ORD(A<(I));A<(I),
0070 NEXT I
48 0 49 1 50 2 51 3 The c_h_a_r_a_c_t_e_r_s_ 0-9 have the
52 4 53 5 54 6 55 7internal decimal values
&_56 8 57 948-57.\f
i
T_A_B_L_E_ _O_F_ _C_O_N_T_E_N_T_S_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _P_A_G_E_
1. FOR TECHNICAL USE ...................................... 1
1.1 RC8000 Test Base Systems (Binary) Version Aug. 82 . 1
1.2 Testprogram User's Manuals ........................ 1
1.3 PLU801 Test ....................................... 1
1.4 -Programmed Tests ................................ 2
1.5 CDU801 Test ....................................... 2
2. FOR MAINTENANCE USE .................................... 3
2.1 RC8000 Test Programs Back-Up ...................... 3
2.2 RC3600 Program Back-Up ............................ 3
2.3 User's Manuals .................................... 3
2.4 PLU801 Maintenance ................................ 3
\f
ii
\f
F_ 1_._ _ _ _ _ _ _ _ _F_O_R_ _T_E_C_H_N_I_C_A_L_ _U_S_E_ 1.
Changes in the RC8000 test system are described in the paper "RC
TESTNEWS".
Changes related to the newest versions may be found in:
"RC TESTNEWS, Edition: 4, Date: Aug. 1982"
Additional information may be found in the previous editions.
1_._1_ _ _ _ _ _ _ _R_C_8_0_0_0_ _T_e_s_t_ _B_a_s_e_ _S_y_s_t_e_m_s_ _(_B_i_n_a_r_y_)_ _V_e_r_s_i_o_n_ _A_u_g_._ _8_2_ 1.1
Mag.tape 800 bpi RCSL No 30-M306
Mag.tape 1600 bpi RCSL No 30-M307
DISC KIT (for RC3652) RCSL No 30-M308
Flexible disc (for RC3751) stand-alone RCSL No 30-M309
Flexible disc (for RC3751) TOP RCSL No 30-M310
1_._2_ _ _ _ _ _ _ _T_e_s_t_p_r_o_g_r_a_m_ _U_s_e_r_'_s_ _M_a_n_u_a_l_s_ 1.2
RC8000 Test System User Manual RCSL No 30-M216
RC8100 Memory Test RCSL No 30-M198
RC8000 CPU Test RCSL No 30-M58
RC8200 Disc Test RCSL No 30-M241
RC8400 FPA Test RCSL No 30-M57
RC8000 Test Operating System (TOP) RCSL No 30-M261
OCTAL-DECIMAL conversion table RCSL No 30-M164
1_._3_ _ _ _ _ _ _ _P_L_U_8_0_1_ _T_e_s_t_ 1.3
User's Manual RCSL No 30-M179
Listing (rev. 0.0) RCSL No 30-M180
Listing (rev. 0.1) RCSL No 30-M311
RC8000 Mirror, User's Manual RCSL No 30-M251
\f
1_._4_ _ _ _ _ _ _ __-_P_r_o_g_r_a_m_m_e_d_ _T_e_s_t_s_ 1.4
CPU810 User's Manual RCSL No 30-M167
CPU810 Listing RCSL No 30-M195
CPU820 User's Guide RCSL No 30-M270
IFP801 User's Guide RCSL No 30-M297
1_._5_ _ _ _ _ _ _ _C_D_U_8_0_1_ _T_e_s_t_ 1.5
Manual RCSL No 30-M10
Listing RCSL No 30-M38
Source RCSL No 30-M39
\f
F_ 2_._ _ _ _ _ _ _ _ _F_O_R_ _M_A_I_N_T_E_N_A_N_C_E_ _U_S_E_ 2.
2_._1_ _ _ _ _ _ _ _R_C_8_0_0_0_ _T_e_s_t_ _P_r_o_g_r_a_m_s_ _B_a_c_k_-_U_p_ 2.1
Mag.tape (version Feb. 79) RCSL No 30-M240
Mag.tape (version Jan. 81) RCSL No 30-M263
Mag.tape (version Aug. 82) RCSL No 30-M312
2_._2_ _ _ _ _ _ _ _R_C_3_6_0_0_ _P_r_o_g_r_a_m_ _B_a_c_k_-_U_p_ 2.2
Code Procedure Library RCSL No 44-RT1344
Program "OPCOM"-Listing RCSL No 30-M303
Program "OPCOM"-ASCII Source RCSL No 30-M302
Program "OPCOM"-R.B. Papertape RCSL No 30-M304
Program "TFGEN"-Listing RCSL No 30-M205
Program "TFGEN"-ASCII Source RCSL No 30-M206
Program "TFGEN"-R.B. Papertape RCSL No 30-M207
2_._3_ _ _ _ _ _ _ _U_s_e_r_'_s_ _M_a_n_u_a_l_s_ 2.3
RC8000 Generating of Test Systems RCSL No 30-M215
RC8000 "OPCOM" Program Maintenance RCSL No 44-RT1382
2_._4_ _ _ _ _ _ _ _P_L_U_8_0_1_ _M_a_i_n_t_e_n_a_n_c_e_ 2.4
Logic Diagrams RCSL No 30-M178
RC8000 Back-Up Mag.tape RCSL No 30-M313
R_C_3_6_0_0_ _P_r_o_g_r_a_m_s_:
Program "PLUBM"-Listing RCSL No 30-M190
Program "PLUBM"-ASCII Source RCSL No 30-M211
Program "PLUBM"-P.B. Papertape RCSL No 30-M212
\f
F_
\f
«eof»