Casio FX 720p Owners Manual
Casio FX 720p Owners Manual
Casio FX 720p Owners Manual
PB-410©/FX-720P©/FX-820P
Personal Computer
PB-410(E)/FX-720P(E)/FX-820P
INTRODUCTION
This manual provides an explanation of the computer so that BASIC pro-
gram beginners as well as users, who have a complete knowledge of BAS-
IC and intend to fully utilize it, can easily understand and utilize the
computer immediately.
Users who are new to BASIC programming should read this manual from
Chapter 1 in order to master programming. Especially in Chapter 3, the
explanation of program preparation and commands should be carefully read.
A program flow explanation is provided in Chapter 3. See Chapter 4 "Com-
mand Reference" for the command formats and detailed explanation.
Users who have a knowledge of BASIC should utilize the computer while
reading Chapter 4 "Command Reference" after mastering the basic opera-
tions explained in Chapters 1 and 2.
Users who intend to use programs immediately by entering them can uti-
lize the programs in Chapter 5 "Program Library ".
This explanation is provided for the PB-410, FX-720P and FX-820P. The differ-
ent points are that the FX-720P and FX-820P have a Function key (blue LH ),
and that the FX-820P has the built-in character printer (see page 12 for
details).
PRIOR TO OPERATION
This computer was delivered to you through CASIO's strict testing process,
high level electronics technology, and strict quality control.
To ensure a long life for your computer, please observe the following
precautions.
• Utilization precautions
• Since this computer consists of precision electronic parts, do not disas-
semble it. Also do not apply an impact to it by throwing or dropping
it, or do not expose it to rapid temperature changes. In addition, do not
store it in a place with high temperatures or high humidity, or in a dusty
place. When the computer is utilized in low temperatures, sometimes
the display response is slow or does not operate. When normal temper-
ature conditions are restored, however, the computer operation will be-
come normal.
• Special care should be taken not to damage the computer by bending.
For example, do not carry it in your hip pocket.
• As optional equipment, the FA-3 cassette interface for the PB-410, FX-720P
and FX-820P, and the FP-12S character printer for the PB-410 and FX-720P
are provided. Please do not connect units other than these to the con-
nector portion.
• Since " - " is displayed during calculation in which key operation is in-
valid except for certain keys, always confirm the display before pressing
a key.
• Although the display sometimes becomes faint while buzzer is sound-
ing, it is not a malfunction. However, if the display becomes very faint,
replace the batteries with new ones as soon as possible.
• Every two years, replace the batteries of the computer and RAM card
with new ones even if the computer is not utilized. Do not leave ex-
hausted batteries inside them because trouble may occur due to battery
leakage.
• When the batteries of the computer is replaced, sometimes the content
of the RAM card is changed. Therefore, replace the battery after remov-
ing the RAM card from the computer.
• If the lock switch for the RAM card is moved to the left, the power is
cut off and operation cannot be performed. Therefore, set this switch
to the LOCK position during utilization.
• Always keep the cap for the connector portion when only the computer
is used.
• If strong static electricity is applied to the computer or RAM card, some-
times the memory content is changed, or key operation cannot be per-
formed. If this occurs, remove the batteries, then replace them again.
• Always connect optional equipments after turning the computer power off.
• To clean the computer, do not use volatile liquids such as benzine or
thinner, but wipe it with a soft dry cloth, or a cloth dampened with a
neutral detergent solution.
• Do not turn the power off during program execution or operation.
• Since the computer is made up of precision electronic parts, avoid giv-
ing a strong shock while a program is being executed; otherwise the pro-
gram execution may be stopped or the memory contents may be changed.
• Programs in any RAM card prepared by the PB-410, FX-720P or FX-820P
cannot be executed with any other RAM card computers.
• When a malfunction occurs, contact the store where the computer was
purchased or a nearby dealer.
• Before seeking service, please read this manual again, check the power
supply, check the program for logic errors, etc.
CONTENTS
CHAPTER 1 GENERAL GUIDE
1-1 NOMENCLATURE AND OPERATION 12
1-2 POWER SOURCE OF THE MAINFRAME 20
1-3 FOR USERS OF THE FX-820P 22
1-4 RAM CARD 24
1-5 BEFORE CALCULATING 31
SAVE [ A L L ] 129
LOAD [ A L L ] 130
VERIFY 131
CLEAR 131
END 132
STOP 132
LET 132
REM 133
INPUT 133
KEY$ 134
PRINT 135
CSR 136
GOTO 137
ON — GOTO 138
IF —THEN 139
FOR — NEXT 140
GOSUB 141
RETURN 142
ON — GOSUB 142
DATA 143
READ 144
RESTORE 145
PUT 146
GET 146
BEEP 147
DEFM 148
MODE 149
CONTENTS
SET 150
LEN 151
MID$ 152
VAL 153
STR$ 154
SIN, COS, TAN 155
ASN, ACS, ATN 156
LOG, LN , 156
EXP 157
SQR 157
ABS 158
SON 158
INT 158
FRAC 159
RND 159
RAN # 160
DEG 160
DMS$ 161
i
CHA
GENERAL GUIDE
• |
Q B E tfg
BBBj -®
BBBi
m t* a Ki!
KB KB 1 3 SB BZB KB 0 d 831 CI'D B E a
<FX-720P>
P raMiiaiinii — — — — —!
B B P S
«
BBII "
<FX-820P>
h®
-©
raraijBBl
IflUM
© ®-l
Power switch ® Display window
Shift key © Display contrast control
© Numeral and decimal point keys © Connector portion
© Calculation keys © RAM card slot (FX-820P)
© Execution key ® RAM card lock switch
© Alphabetical keys and space key © Function key (FX-720P/FX-820P)
© Memorandum key ® Paper feed key (FX-820P)
-12-
1-1. NOMENCLATURE AND OPERATION
Please note that the FX-720P and FX-820P have an (3D (function) key that
is used together with alphabetical keys when functions are entered, while
the PB-410 does not have such a key. And FX-820P has the built-in charac-
ter printer.
• Power switch
When this switch is moved to the right, the power is turned on, and when
it is moved to the left, the power is turned off.
Function key (Blue QD key: Only provided for the FX-720P and
FX-820P)
If this key is pressed, the function mode is selected (" (3D " is displayed)
and the function printed below each key can be displayed. When it is
pressed again, the function mode is released and " (3D " disappears.
(To distinguish this key from the alphabetical 3 key, it will be written
as S from now on in this manual.)
(PB-410/FX-720P)
ED ® rxi en m m ta en ® cs
S [£) CU [E [G] [El [T) E CD CD
S E E S [IKE) I S S B ®
(FX-820P)
SSmCIDCEmCyDmCpDCE)
[AjtiDClimECSCTjCKjCri
' rxiEEimiiDCEitMDiriri]'
c
Using these keys, commands are entered, or progams are written. Each of
the 26 alphabetical keys from ® to U3 functions as a memory (for storage
locations).
Also, the ® — fXI keys have another function. When they are pressed af-
ter th£ S key, a symbol or BASIC command is displayed.
Press the space key (PB-410/FX-720P: m , FX-820P: I I ) when a space
is required.
-14-
1-1. NOMENCLATURE AND OPERATION
Example) @ ( T ) - * G 0 S U B N SOD—>• ?
(PB-410/FX-720P)
/ •• a s I ) ? : : \
CZZD • CZD CZD CZD CZD • CZD CZD CZD
GOSUB RfTym GOTO FOR T O NEXT I F THEN LIST A N S
I l( ICZDt >CZ3< 1 C 3 I 1 CZD CZD
PRINT INPUT CLEAR OEFM LOAD SAVE RUN
(FX-820P)
»» $ (
In addition, the alphabetical keys have another use in the extension mode
(When H is pressed after the B key, "EXT" is displayed). When they are
directly pressed, small alphabetical characters are displayed, and when they
are pressed after the S key, special symbols are displayed.
(PB-410/FX-720P)
BBSQBBBmSE
BBBmBBmSEB
BBBBBBBeBB
(FX-820P)
msBsmssmsm
BaHLUBBLDBLI]
15
CHAPTER 1 GENERAL GUIDE
Functions provided when a key is pressed after the S key in the extension mode:
(PB-410/FX-720P)
CZD • CZD CZD CZD CZD CZD CZD CZD CZD
% . g y ( . J & - i• -
(FX-820P)
CZD CZD CZD CZD CZD CZD CZD CZD CZD CZD
% . @ v ( ) 8. - i
The FX-720P and FX-820P are provided with the S key. When a key is
pressed after the H k e y , one of the following functions is displayed.
Example) ® O—»S IN
(PB-410/FX-720P)
SIN COS TAN ASN ACS ATN LOG LN EXP SQR
ZZ> CZD CZD CZD CZD CZD CZD CZD CZD ff]
ABS INT FRAC SGN RANS CSR RNDI DEGt DMS${< '
(FX-820P)
-16-
1-1. NOMENCLATURE AND OPERATION
• Equal key ( Q )
This key is not used to provide an answer for calculation, but is used
for an assignment statement (see page 52) and for a condition in an IF
statement (see page 74).
Also, when this key is pressed after the S key, a ^ (not equal) symbol
is displayed.
• Mode key ( B )
This key is used together with CD and 0 to i when the computer
status or angle unit is specified.
BQ "EXT" is displayed to indicate extension mode in which small al-
phabetical characters and special symbols can be used. To release
the extension mode, press these keys again.
BE "RUN" is displayed for the performance of manual and program
calculations.
SB "WRT" is displayed for the performance of program write-in, check-
ing, and editing.
SO "TR" is displayed for the performance of execution trace, (see page
69 for details.)
SO When "TR" is displayed, execution trace mode is released and "TR"
disappears.
SSI " D E C is displayed to indicate that degree is specified as the an-
gle unit.
NO "RAD" is displayed to indicate that radian is specified as the an-
gle unit.
SO "GRA" is displayed to indicate that grade is specified as the angle
unit.
-17-
CHAPTER 1 GENERAL GUIDE
• Memorandum key ( S )
Pressed to use the Data Bank function. Also pressed for sequential recall
or for recall after pressing a specified character in the RUN mode
(press I B 0 ) or in the input mode (press BSE)).
• Cursor keys ( B S )
These keys are used to move the cursor (blinking " - " in the display win-
dow) to the left or right as a convenience when correcting a displayed
character. When they are pressed once, the cursor is moved one charac-
ter, and when they are continuously pressed, the cursor moves continu-
ously within the range of written characters.
• Delete/Insert key ( fi )
This key is used to delete a character where the blinking cursor is posi-
tioned. After deletion, the character to the right of the cursor moves to
the left. When it is pressed after the S key, the character where the blink-
ing cursor is positioned is moved to the right to provide a space.
-18-
1-1. NOMENCLATURE AND OPERATION
3
(FX-820P)
The display becomes darker when the control is turned in the direction
of the arrow, and becomes lighter when turned in the opposite direc-
tion. If the display is still faint when this control is placed in the darkest
position, the batteries are weak and should be replaced with new ones.
• Connector portion
When program storing on a tape is required, the FA-3 is connected, and
when printing is required with the PB-410 or FX-720P, the FP-12S is con-
nected.
(PB-410/FX-720P)
(FX-820P)
The PB-410 or FX-720P can be connected to the FP-12S and FA-3, and
the FX-820P can be connected to the FA-3.
Do not connect any equipment other than the FP-12S and FA-3 to this
connector portion. When these optional equipments are not connect-
ed, always place the attached connector cap on it.
-19-
1-2. POWER SOURCE OF THE MAINFRAME
Power for the computer is provided by two lithium batteries (CR2032). When
only the computer is used, the battery life is about 140 hours. However,
it is shortened if the buzzer is used often. If the display is faint even after
the contrast is adjusted (see page 19), this is caused by weak batteries which
should be replaced with new ones as soon as possible. Always replace both
of the batteries at the same time.
* Replace the batteries with new ones every two years even if they are not used
since leakage might occur.
• Battery replacement
When a RAM card is placed in the computer, remove it before replacing
the batteries. After replacing the batteries, place the RAM card in the slot
(see page 26). (PB-410/FX-720P)
Screws
o o
4f All reset button
m
o •».
o
^5
Scrsws
© PB-410/FX-720P: ,
Slide the battery holding panel in the direc- (PB-410/FX720P)
tion of the arrow while pressing ® as
shown in the right figure, then remove it.
FX-820P:
Open the battery compartment lid by m
loosening the screw with a screwdriver.
irA-ozurj
• r—Screw °t
0 ^ nEr-
-20- °ff> ^fp
1-2. POWER SOURCE OF THE MAINFRAME
© PB-410/FX-720P:
Replace the battery holding panel.
FX-820P:
Replace the battery compartment lid.
Screw carefully.
Please keep the batteries in a location out of the reach of children. If they are
swallowed, contact a doctor immediately.
-21-
1-3. FOR USERS OF THE FX-820P
• How to charge the printer battery
The printer operates on a built-in rechargeable Ni-Cd battery.
With a fully charged Ni-Cd battery it prints approximately 3000 lines con-
tinuously. When battery power decreases, printing speed becomes slow
or the print-out figures become dim. In this case, recharge the battery.
To charge the battery, plug the applicable charger (100, 117, 220 or 240V)
into an AC outlet and the cord into the jack on the unit. While the charger
is connected, the battery is being charged except when the printer is acti-
vated. It takes approximately 15 hours to fully charge the battery.
You can operate the unit after charging the battery for 1 or 2 hours but
shorter charging periods will reduce the battery operating time.
It is recommended that the battery be fully charged before you use the unit.
• When charging, be sure the power switch of the computer is OFF.
• The use of a charger other than the CASIO charger supplied with the
unit may result in damage to your unit.
• It is normal for the charger to be warm to the touch when it is plugged
into an AC outlet. Unplug the charger from the AC outlet after the bat-
tery is fully charged.
• If the battery will not hold a charge and seems to discharge very quickly
in use, it may be defective.
See the original store or nearby dealer to order a replacement.
-22-
7-3 FOR USERS OF THE FX-820P
Fig. 3
Paper tear
off blade
Note:
Be sure to use the specified electro-thermal recording paper (size: 38mmW x
16mm<£) since the unit employs a special "electro-thermal printing system".
- 2 3 -
• RAM card characteristics
Although an ordinary handheld computer has built-in memory for storing
data or programs, the internal memory in this computer is separated from
the mainframe in the form of a "RAM card" which can be freely inserted
or removed. It is very convenient when data or programs are stored or
replaced.
While a conventional handheld computer utilizes cassette tape for storing
or replacing data or programs. This trouble can be eliminated by using a
"RAM card" with which data or programs can be easily and quickly replaced
and processed. The stored RAM card content is protected by a built-in bat-
tery; it is not erased when the RAM card is removed from the mainframe.
Two different kinds of RAM cards, the RC-4 (4K bytes) and the RC-2 (2K
bytes), are available.
* Since this computer is not provided with a built-in RAM area, if a RAM card
is not installed, it cannot be used.
• Handling precautions
Although two different RAM cards, RC-4 (4K bytes) and RC-2 (2K bytes),
are available for this computer, their handling methods are the same.
Front Back
1
©
Battery
compartment lid
Connector cover
- Insulation paper
Metal tab
[
1 ] — • Metal tab
-25-
CHAPTER 1 GENERAL GUIDE
\
\
(5) Press the card holder projection
slightly downward so that the RAM
card is horizontal, and insert it in
the card holder completely.
Locked
Note) If the lock switch is not locked when e mainframe power switch is turned
on, the power is not turned on.
-27
CHAPTER 1 GENERAL GUIDE
Lock switch
Projection
28
1-4. RAM CARD
Screw
-29-
CHAPTER 1 GENERAL GUIDE
Since programs and data stored in a RAM card are protected by the bat-
tery, be sure to replace the battery before it is exhausted. It is recommended
to store important programs and data on a cassette tape before replacing
the battery.
-30-
1-5. BEFORE CALCULATING
-31-
CHAPTER 1 GENERAL GUIDE
Example)
Manual calculation
1E32345678912 SB ::;
1,, 2 3 4 5 b i'' •;: 1
12345678912ni00E3 1. 2 3 4 5 6 8 7 E!2
12345678912D-100 •••••.'!.. 2 3 4 5 76 E i 2
Program calculation
For PRINT 1 23456789 1 2 Q - 1 00
Is automa-
"•" ;•": •!
-1.23456 i 0 i 1 I"J
tically shifted.
t .1.
1.234567 8 9 IE
.234567S 91 El
2 34 5 6 7891 E 1 2
Disappears from Has not been
the display. displayed.
32-
CHAPTER 2
LET'S OPERATE
RERDY P8
Erase this display first by pressing the S3 key. "READY P0 " disappeared,
didn't it? When this occurs, " .... " blinks on the extreme left of the display.
This is called a "cursor" where a character can be written.
When the cursor blinks, this is called an "input wait state" in which the
computer waits for the input of calculation or an instruction. While the
cursor usually blinks as " ...." it also blinks as " | " while characters are
continuously written. Up to 62 characters can be written on one line. When
56 or more characters are written, the " 1 " sign appears as a warning sig-
nal. "RUN" and " D E C on the display indicate the present status. "RUN"
indicates the RUN mode in which manual calculations or program execu-
tions can be performed. "DEG" indicates that the angle unit is degree.
The angle unit also includes the Radian mode ("RAD" is on) which is speci-
fied by pressing S ( 5 ] , and the Grade mode ("GRA" is on) which is speci-
fied by pressing S O in addition to the above. The angle units are required
when trigonometric functions are used. Whenever the power switch is turned
on, "DEG" is displayed.
The status display also includes the program write-in mode ("WRT" is on)
specified by pressing S 3D , the trace mode ("TR" is on, see page 69) speci-
fied by pressing s (g), the print mode ("PRT" is on, see page 116) by press-
ing S C z i , the data input mode for DATA BANK function ( " S C N ] " is on,
see page38) by pressing S O ) , and the extension mode ("EXT" is on)
by pressing S H .
You will learn about these display modes as you continue to operate this
computer.
-34-
2-1. LETS OPERATE THE COMPUTER
Press 83.
Press appropriate keys to enter the numerical expression.
memos)®® 12 3 + 4 5 6 _
After this, an answer is obtained by pressing GS instead of
J i
Example) 4 5 x 6 + 8 9 = 3 5 9
Consider that 45 was pressed as 46 by mistake.
SiDiBHi 4 6 * 6 + 89
Now you notice that 46 was pressed by mistake. Place the cursor
at the location where the wrong key was pressed by using a cursor
key ( H ) calmly.
r=&~
HBBBBB 4jfe* f. + 8 9
vrf
L
The cursor and 6
turn on and off.
Press the correct key, (5) .
45*J-, + H4
—:—~ '*+* S =:—=—
Since the calculation expression is now corrected by performing the above
procedure, press the S i key to obtain the answer.
This computer is provided with some special characters which are con-
venient for games or as scientific symbols in addition to alphanumeric
characters. (See page 16 for the special characters.)
For these marks, press alphabet keys after pressing the S keys.
36-
2-1. LET'S OPERATE THE COMPUTER
e^e^ecE, •**#£!H!F
Since these marks and symbols are provided, please try to use them. Also,
to return to the mode in which upper case letters are displayed,
press BBQ again to erase "EXT". During the continuous use of this com-
puter, sometimes "ERR2" is displayed and it does not operate even if a key
is pressed. This is not computer trouble, but is a message called an "error
message". When this occurs, press the 03 key, then the display clears and
the computer operates again. See pages 64 and 192 for details.
-37-
2-2. CONVENIENT DATA BANK FUNCTION
This computer is provided with the DATA BANK function which allows data
to be easily stored or retrieved by just using the S key. It can be used
in many ways.
For example, it can be used as a telephone directory, time table, schedule,
chart, etc.
Also, since retrieval, access, and write-in can be performed in a BASIC pro-
gram, the utilization range can be expanded such as for a customer list,
product list, estimated calculation, catalogue of books, etc.
There are many different ways to utilize the DATA BANK function in addi-
tion to the above items.
For details, see the "DATA BANK Reference Manual".
-38-
2-3. SIMPLE CALCULATION, AT THE
BEGINNING
Simple calculation is performed as follows. However, if you have never used
a scientific calculator, please be careful because this computer is provided
with True Algebraic Logic functions in which multiplication and division
are performed before addition and subtraction.
Example 1) 2 3 + 4 . 5 - 5 3 = - 2 5 . 5
operation) eootarzieaeEisa i j
* Numeral keys are shown without a frame from now on.
Example 3) 7 x 8 - 4 x 5 = 3 6
Operation) 708040503 • '•> b
Example 4) ( 4 . 5 X 1 0 7 5 ) X ( - 2 . 3 X 1 0 78) = - 0 . 0 1 0 3 5
Operation) 4 . 5 ® 75 O O 2 . 3 E Q 78 SB | - 0 , 61635
* Press the SO key then enter the exponent.
There is another algebraic calculation which uses the memory. This memory
is convenient when a certain numerical value is calculated in many differ-
ent ways.
For example, 3x + 5=
4X4-6 =
5 X + 7 =
-39-
CHAPTER 2 LET'S OPERATE
3 O S D 5 S3
,-j q q •"'
4 nan6 m G A
5 Q B H 7 BS
They can be performed easily.
-40-
O-A PI iMrnriM PAI r\ 11 ATiON
A ITER
This computer is provided with scientific functions as well the four basic
functions.
Although these functions can be utilized in a program, manual utilization
is explained here.
The functions provided by this computer are as follows.
Name of functions
Trigonometric functions sin x SIN x
cos x COS*
tan x TAN x
Inverse trigonometric sin"'x ASN x
functions cos -1 x ACS*
tan" 1 x ATN x
Square root Vx SQR x
Common logarithm log* LOG x
Natural logarithm In x LN x
Exponential function ex EXPx
Power xy xly
Decimal -> sexagesimal DMS $ (x)*
Sexagesimal ^ d e c i m a l DEG (x,y,z
Integer INTx
Integer removal FRACx
Absolute value \x\ ABSx
Coding 'Positive No.->1 S SGN x
0^0
^Negative No.-* - 1 /
/
Rounding off x is rounded ^ RND (x,y)*
off at the 10'
^position. /
Random number RAN #
generation
41
CHAPTER 2 LETS OPERATE
Example) sin-'0.5=30°
Operation) ASN 0 . 5 B
42-
2-4. FUNCTION CALCULATION — A HIGHLIGHT OF THIS COMPUTER
Example) e5=148.4131591
Operation) E X P 5 SB 148.4131591
Example) /!+/5=3.65028154
Operation) SQR 2 S 3 S Q R 5SB 3.65028154
43
CHAPTER 2 LET'S OPERATE
Example) Round off the result of 12.3 x 4.56 to one decimal place.
12.3X4.56=56.088
Operation) RNDBcb 1 2 . 3 D 4 . 5 6 Q O 2&<±M
* When RND (x,y) is used, •56. 1
l.yl < 100.
Operation) F R A C B 6 7 8 0 0 H 96BcbSl
-44-
i
2-4. FUNCTION CALCULATION — A HIGHLIGHT OF THIS COMPUTER
Example) 1 ~ 3=0.3333333333
Operation) S E T NEB (Designation cancellation)
..T „ T .„,. „.,. „.r ...,. ...,.
1 B 3 1
Example) 147536"=14.42666667
Operation) DEGHc=. 14CD25[U36SdDl2i
i 4 « 4Zbbbbb
45
CHAPTER 2 LET'S OPERATE
46
3
CHAPTER
"BASIC"
PROGRAMMING
10 INPUT X
20 Y = 2 * X t 2 + 5 * X + 1 3
30 PRINT Y
10 INPUT X
20 Y = 2 * X t 2 + 5 * X + 1 3
3 0 PRINT Y
-48-
3-1. WHAT IS A PROGRAM?
10 INPUT X Input
20 Y = 2 * X t 2 + 5 * X + 1 3 Calculation
30 PRINT Y Output
At first, the input part is used to enter (input) data (such as numerical values
for calculation) into the computer. Next, the calculation part is used to per-
form a calculation so that an answer can be provided. Last, the output part
is used to provide (display) an answer.
A computer does everything required if correct commands (instructions)
are provided. In this example, an input command (INPUT) and an output
command (PRINT) are memorized.
These three parts can be further broken down as follows.
10 INPUT X
~T~ I T
Line No. Command Operand
The line numbers indicate the sequence of the program flow. Since a com-
puter reads and executes statements in ascending order of line numbers,
place these line numbers according to the expected execution sequence.
Also, it is advisable to assign these numbers in 10s (10, 20, 30, . . . . ) be-
casue this is convenient if additions are required later. Decimal figures such
as 1.5 or 12.3 cannot be used for line numbers.
The items that follow the line number are the commands to be performed
by the computer. There are many different kinds of commands used for
specification of instruction required.
Although it is desirable to remember all the commands, just memorize the
minimum necessary commands at first, then the rest gradually. See "CHAP-
TER 4 COMMAND REFERENCE" on page 123and after for the kinds of com-
mands and their functions. The function of an operand next to a command
is to supplement it. Some commands have an operand while other com-
mands do not. In this example, the INPUT command indicates the entry
of data. An operand specifies memory where entered data is placed; in
this case, the entry to variable X.
-49-
CHAPTER 3 "BASIC" PROGRAMMING
20 is the line number. The assignment statement means that the value on
the right of the equal sign (=) is entered (assigned) to the variable on the
left. If the LET command is added to the assignment as follows,
2 0 LET Y=2*Xt2+5*X+13
-50-
3-2. PROGRAM PREPARATION
This section and after cover the main subject, BASIC Programming, in which
a program is actually prepared.
When these three items are sequentially connected, it is easily found that
the last item is the display of the answer. Next, it is necessary to perform
calculation to obtain an answer, and also to enter data to perform calculation.
Connect these three items.
(2) Calculation
(3) Display
As the flowchart has been completed by this procedure, let's change it into
a format that is more like a program.
-51-
CHAPTER 3 "BASIC" PROGRAMMING
The first item is an instruction to enter data. Since data is entered into a
variable by using an INPUT statement, determine the variable. If variable
A is used, the content of (1) is "INPUT A".
In the calculation performed in the second item, the entered content of
variable A is squared, and the answer is assigned to another variable. If
this variable is B, then "B=AT2". This calculation expression is called an
assignment statement which is formally written as "LET B=AT2". However,
since LET can be omitted, it can be written as "B=AT2".
The answer is displayed by the third item. Since the content of variable
B which includes the answer is displayed by using a PRINT statement, it
is written as "PRINT B". These three items are placed into a flowchart again.
INPUT A
B=At2
PRINT B
This program is completed by placing line numbers for these three items.
10 INPUT A
20 B=At2
3 0 PRINT B
A program can be quickly and easily made by sequentially assembling a
flowchart after preparing each item as mentioned above.
An actual flowchart has formal symbols which have special meanings. Draw
the above example by using them.
52
3-2. PROGRAM PREPARATION
Enter 2 numerical
values.
/ Display 4
V answers.
Use an INPUT statement (an instruction to enter data from the keyboard
into a variable) to enter 2 numerical values. Items that should be noted
are the variables where data or an answer are entered. The utilization of
variables is quite complicated. Variables include those with alphabetical
characters from A to Z, and array variables that have an item called a sub-
script such as A(3). Although a variable can be selected from among these
variables, it is recommended that variables be selected in alphabetical order
while you are not accustomed to programming.
Two numerical values are entered here. A and B are selected and "INPUT
A, B" is written. Several variables can be handled in one INPUT statement
by punctuating them with commas.
How about the calculation parts? Four items are calculated here; four an-
swers will be obtained. The variables where the four answers are entered
will be C, D, E and F.
Since this completes the calculation items, the answers are displayed next.
The display command is PRINT; "PRINT C, D, E, F" is realized.
-53-
CHAPTER 3 "BASIC" PROGRAMMING
INPUT A,B
c==A+B
D==A-B
E==A*B
F==A/B
PRINT N
C.D.E.Fy 1
70 END
The program has been completed by the above procedure. It can be easily
written if it is assembled sequentially.
First, prepare a simple and practical program instead of complicated one
by using many different commands.
NOTE
VARIABLES
Variables are important elements for program preparation. Variables are just
like boxes where entered data or calculated data are stored with each hav-
ing a name. Variables include the standard ones from A to Z and those
with a subscript attached to the name (A to Z). The latter ones are called
array variables such as A(5) and B(50).
-54-
3-2. PROGRAM PREPARATION
/
r r
/ / / / / / / /
A
? B
/
C
/
X( 5 )
/
Z(15)
/
Also, there are two different types of variables; numerical variables where
numerical values are entered, and character variables where character strings
are entered. The variables that were previously used are numerical varia-
bles where numerical values have been entered to perform a calculation.
In addition to these, there are character variables with $ attached to the
name (A to Z), such as A$, B$, C$, and a special character variable called
"exclusive character variable", $.
A numerical value with up to 10 digits (10 digits in the mantissa part, 2
digits in the exponent) can be entered into a numerical variable, while a
string with up to 7 characters can be entered into a character variable. Also,
up to 30 characters can be entered into the exclusive character variable.
Since the items entered in these two kinds of variables are different, charac-
ters such as "ABC" cannot be entered into numerical variables while nu-
merical values for calculations cannot be entered into character variables.
The utilizations of these variables are different. Use numerical variables
when numerical values are to be entered for calculation, and character vari-
ables when messages or symbols are to be entered.
Arrays are convenient when data are stored in many variables. They are
distinguished by subscripts indicating the 1st variable, 2nd variable, etc.
Array variables will be explained by utilizing them in a program.
55
CHAPTER 3 "BASIC" PROGRAMMING
A*
H(6)
A( 1 3 ) / /
N N
A$(13) N(0)
A=A(0)=A$=A$(0)
B=A(1)=B(0)=B$=A$(1)=B$(0)
C=A(2)=B(1)=C(0)=C$=A$(2)=B$(1)=C$(0)
56
3-2. PROGRAM PREPARATION
Program
10 INPUT A , B
20 O A + B
3 0 D=A-B
40 E=A*B
50 F=A/B
6 0 PRINT C . D . E . F
70 END
When the power switch is turned on, the RUN mode, in which manual
calculations or program execution can be performed, is specified.
Press KBIT] to switch from this mode to the WRT mode in which a pro-
gram can be written.
Program area
This display shows a status in which no program is stored. The above 4-digit
numeral indicates the number of remaining steps. Maximum number of
steps is 1568 when using RC-2 RAM card and 3616 when using RC-4 RAM
card. This number decreases when a program is stored or when the memory
is expanded (see page 95). Numerals from 0 to 9 are program area num-
bers; the blinking one indicates the currently specified program area. When
a program is stored during this status, it is stored in program area P0. Differ-
ent programs can be written in 10 program areas from P0 to P9.
If a program is stored, the program area number is not displayed but the
cursor, " - " , is displayed. To erase all the programs and store a program
in program area P0, enter
This is a command that erases all programs. Store a program with the fol-
lowing procedure.
-57-
CHAPTER 3 "BASIC" PROGRAMMING
(DtaewtsmExnoscDii] m
m\MD(E(E} 133
After the 133 key is pressed, a one character space is made after the line
number to allow the display to be easily read.
Was the program correctly stored?
Press the keys slowly and firmly even if it is boring. When a wrong key
was pressed, a correction can be made by the following operation.
58
3-2. PROGRAM PREPARATION
After the correction has been completed, press the 139 key.
BIB
Press the E l key once to place the cursor under the "N".
a r =H
Press the correct key.
5 0 F = H/tL.
After the correction has been completed, press the 133 key.
59
CHAPTER 3 "BASIC" PROGRAMMING
NOTE —• —
PROGRAM AREAS
This computer is provided with 10 program areas, P0 to P9 where indepen-
dent programs can be stored. All these program areas can be used in the
same way. For example, if these areas were not provided and if 3 programs
were to be used very often, they would have to be loaded from tape each
time, or the RAM card would have to be replaced. This computer can store
these 3 programs in 3 program areas such as P0, P1 and P2.
Although this function is very convenient, precautions have to be taken con-
cerning the number of steps used; the total number of steps used in all
program areas must not exceed the maximum capacity (1568 steps with
RC-2 RAM card, and 3616 steps with RC-4 RAM card.)
A program area can be specified by pressing a key from m to m after press-
ing the S key. This specification can be done both in the RUN mode and
WRT mode. In the RUN mode, the program stored in the specified area
automatically starts. In the WRT mode, the program does not start but a
program area, where a program is to be input or editing is to be performed,
is specified.
The program areas must be correctly handled. When a program is execut-
ed, stored on cassette tape, or loaded from cassette tape, if a wrong area
is specified, the operation cannot be performed correctly.
When the power is turned on, program area P0 is specified automatically.
This can be confirmed by the numeral following "READY" after you
press m ED •
-60-
3-2. PROGRAM PREPARATION
After 2 data were entered, the sum was displayed. Press the 63 key to dis-
play the next answer.
1626
61
CHAPTER 3 "BASIC" PROGRAMMING
When the RUN command is used, the program in the currently specified
program area is executed. However, if P0 is to be executed while P5 is
specified, what is the procedure?
The solution is to press @ S .
After a program has been prepared and stored, execute it. Even if an error
(ERR is displayed) occurs after execution, don't be disappointed. In this case,
find the cause of the error (debug) by referring to the following section.
NOTE
-62-
3-2. PROGRAM PREPARATION
Example)
(5 6 8- Number of remaining steps
HJED
P 8123456789
The number of steps is counted as follows.
• Line No 2 steps per line No. from 1 to 9999.
• Command 1 step
• Function 1 step
• Character 1 step per character.
• In addition, each press of the S3 key during storage is counted as 1 step.
2 1 1 1
10 B=SIN A SO 7 steps
i i i ii ii i i i
2 1 1 1 1 1
1 1 1 1 Total: 22 steps
When the memory is expanded, 8 steps are required for 1 memory ex-
pansion.
Example) Initial state 26 memories 1568 steps
DEFM 10 S3 36 memories 1488 steps
-63-
CHAPTER 3 "BASIC" PROGRAMMING
The error type is indicated by a code number that follows "ERR". The code
number from 1 to 9 is used to indicate type; "ERR1" indicates "memory
overflow", and "ERR2" indicates "syntax error". See the "Error Message Ta-
ble" on page 192 for the meaning of these code numbers.
The program area and line number where the error occurred are also in-
dicated.
Where and what kind of error occurred can therefore be determined by
these three items.
Let's take a look at an example.
An error that often occurs is "ERR2" which is a syntax error. It occurs when
a program is incorrectly stored.
-64-
3-2. PROGRAM PREPARATION
For example, the program used in the previous example is incorrectly stored.
Operation Display
(BCD P ....123456" : 89
SS20E3 28 C =fl+ B_
20 C=flB
39 C = fl B_
READY P8
In this example, " C = A + B " on line 20 was entered as "C=AB" by mistake.
Now, execute the program.
Operation Display
45 im
12B I ! ! I
-' I.-1 ••••• 2 H
-65
CHAPTER 3 "BASIC" PROGRAMMING
-66-
3-2. PROGRAM PREPARATION
10 INPUT A
20 B=1
30 FOR C=1 TO A
40 B=B*C
50 C=C+1
60 NEXT C
70 PRINT B
80 END
-67-
CHAPTER 3 "BASIC" PROGRAMMING
Operation Display
•y ••] i r
BCD p_*. .. j . . . . . :'.' H J 6 7 £9
S S
NEWEE
p'.
p .
m345 .,j 4 .,..! D 1 Cy
b r c9
TZ Command to erase a program.
10 B B A 1 10 IN PUT H
20 B=1BB 20 B = 1
30 eFc83C=1 B S A I 3 0 FU R U s i T
i
40 B=B*CGS! 4 0 B =B*C
50 C=C+1 m 50 C+i
60 B N S T CBB 60 NE NT
70 B B B B 70 PR 1 H ! B
80 ENDED 80 EN D
Operation Display
Example)
1211 1039
The correct answer is 479001600.
Check the calculation expression. It has no mistake. Next, check the FOR-
NEXT loop flow.
Insert a STOP statement after line 50 to stop the program each time.
Operation Display
BCD P _\le2 34 5 6' '89
55 STOP I 55 'STOP
RE Hv V P 1
-68-
3-2. PROGRAM PREPARATION
Since a STOP statement is to be inserted after line 50, place a line number
between 50 and 60. As line number, 55 was selected.
Execute the program.
Operation Display
as Iv
2W My
Check the value of loop control variable C.
cm
Continue execution.
-69-
3-3. PROGRAM DEVELOPMENT
It is certain that the outline of program has been understood by the previ-
ous explanation. The three parts of a program are input, calculation, and
output. Many different programs can be prepared with these three items.
However, a program can be more convenient and easier by using the com-
mands explained in this section.
INPUT A
10 INPUT A
20 B=A*A
30 PRINT B
40 END
-70-
3-3. PROGRAM DEVELOPMENT
43IB 1849
-71-
CHAPTER 3 "BASIC" PROGRAMMING
10 INPUT A*
1
20 GOTO 50-
p^30 PRINT B
I
40 GOTO 10-
50 B = A * A «
I
'—60 GOTO 30
Since a GOTO statement unconditionally causes a jump to a specified line
number as shown above, it is called an "unconditional jump."
A jump to a program area as well as to a line number can be performed
by a GOTO statement. The program area is specified by adding " # " and
a number from 0 to 9.
Example) GOTO # 1 Jumps to program area P1.
GOTO # 9 Jumps to program area P9.
NOTE
PRINT STATEMENTS
A PRINT statement is used for displaying the content of a variable, charac-
ter string, or numerical value. Numerical variables and character variables
can both be used.
Example) When A= 123 PRINT A ^ 1 2 3
When B$=*ABC" PRINT B $ ^ A B C
Since a character string placed inside " " (quotation marks) is displayed
as it is, it can be used as a message.
Example) PRINT ' C A S I O " —• CASIO
-72-
3-3. PROGRAM DEVELOPMENT
When two or more items are to be displayed, they can be written by punc-
tuating them with commas ( , ) or semicolons ( ; ).
Example) PRINT A , B , Z $
PRINT *TOTAL=";T
Note that when a " , " is used, output is performed with line change; the
execution stops after the first content is displayed ("STOP" appears). The
following display is obtained by pressing the S3 key. However, when a " ; "
is used, continuous display is performed.
-73-
CHAPTER 3 "BASIC" PROGRAMMING
[EXERCISE]
Prepare a program to obtain the areas of circles by entering radiuses. Use
a GOTO statement.
Expression: S=7rr2 (Press S o b for Pi entry.)
The flowchart is as follows. S and R are used for variables according to the
expression.
NPUT R
S=7r*R*R
PRINT S
PROGRAM
10 INPUT R 10 INPUT R "T2" is also used
20 S=;r*R*R or 20 S=7r*RJ_2 for square
30 PRINT S 30 PRINT S calculation.
40 GOTO 10 40 GOTO 10
YES (True)
NO (False)
1£ 1 —-
Data input INPUT A
30 |N°
Square calculation B= A*A
I GOTO 10
Since "THEN" includes the meaning of "GOTO", "THEN GOTO 10" can
be written as "THEN 10".
Execute this program.
Operation Display
RUNES
5 SB 25
12 S3
9SB 81
Data can be selected by an IF statement as mentioned above.
Example) When " 0 " is entered after entering several data, the average of
these data is obtained.
-76-
3-3. PROGRAM DEVELOPMENT
•INPUT A
YES
• IF A = 0 T H E N
Average
1
Total calculation display •PRINT B/C
1
Number of data
calculation •B=B+A
c End
J •C=C+1
77-
CHAPTER 3 "BASIC" PROGRAMMING
10 B=e:c=e
20 INPUT A
30 IF A=0 THEN PRINT B/C
40 B=B+A
50 C=C+1
60 GOTO 20
Although the program input is completed, the program does not terminate
after displaying the average. Therefore, add an END statement after the PRINT
statement on line 30 by using a multistatement.
30 IF A=0 THEN PRINT B/CIEND
• IF statement applications
In the above example, program progress was determined by one test.
However, if there are several tests and all conditions must be satisfied, what
is the solution?
For example, an arbitrary numerical value is to be entered and numerical
values from 1 to 9 are to be selected. In other words, since the selected
numerical values must be larger than 0 and smaller than 10, two condi-
tions ("0 < variable" and "variable < 10") are required. This can be writ-
ten on one line as follows.
IF 0 < variable THEN IF variable < 10 THEN
Although the same kind of statement can be used when there are three
conditions or more, it is recommended that a maximum of two conditions
be used since using more than two is too complicated and the line be-
comes too long.
-78-
3-3. PROGRAM DEVELOPMENT
NOTE
MULTISTATEMENT ( : )
A multistatement is convenient when short assignment expressions are ar-
ranged on one line, or when there are several commands after THEN in
an IF statement.
Example 1)
10 A=1
2 0 B=2 10 A=1:B=2:C=3
30 C=3
Example 2)
50 C=A+B
60 D=A-B
70 E=A*B 50 C=A+B:D=A-B:E=A*B:F=A/B
80 F=A/B
79
CHAPTER 3 "BASIC" PROGRAMMING
[EXERCISE]
Prepare a program to separate entered numerical values into two groups
(larger or smaller than 0) and obtain each total.
Assign 0 to A=0
two variables
B=0
INPUT C
IF C>0 THEN
Totalization of Totalization of A= A+ C
negative numbers positive numbers
B= B+ C
PROGRAM
10 A = G : B = 0
20 INPUT C
30 IF C>0 THEN A=A+C:GOTO 50
40 B=B+C
50 PRINT A;B
60 GOTO 20
The IF statement on line 30 determines whether or not the input value (value
of variable C) is larger than 0. If it is larger than 0, it is added to variable
A after THEN, and if it is not larger than 0, it is added to variable B on
line 40. On line 50, each total is displayed every time a value is entered.
-80-
3-3. PROGRAM DEVELOPMENT
10 INPUT A
20 FOR B=1 TO 10 STEP A
30 PRINT B
40 NEXT B
50 GOTO 10
-81-
CHAPTER 3 "BASIC" PROGRAMMING
Operation Display
RUN SB
3633
BIB
2JJ •—1
±
223 18
0 . 8 (S3 J
1. 8
•u. n '-'
Example) Prepare a program to obtain a total and an average for data when
a certain number of data is entered.
For this program, enter the number of data first, then enter each data by
a FOR-NEXT statement and obtain the total. After the data input has been
terminated, the total and average are displayed.
-82-
!
3-3. PROGRAM DEVELOPMENT
•D=0
•INPUT A
1
/Total and average] PRINT D D/A
\display J
I
Totalization
c End
> •END
10 D=0
20 INPUT A
30 FOR B=1 TO A
40 INPUT C
50 D=D+C
60 NEXT B
70 PRINT D.D/A
80 END
When the number of data is known as shown above, data input and calcu-
lation can be repeated by a FOR-NEXT statement. The number of data can
be directly written instead of A on line 30 without entering the number
of data by an INPUT statement as shown on line 20. In this case, line 20
is not required.
•83-
CHAPTER 3 "BASIC" PROGRAMMING
[EXERCISE]
Prepare a program that calculates factorial.
<HINT>
Perform a factorial calculation (e.g., 5! = 1 x 2 x 3 x 4 x 5) by using
a FOR-NEXT loop.
FLOWCHART
FOR B = 1 TO A
END
C= C*B
10 INPUT A
20 C=1
30 FOR B=1 TO A
40 OC*B
50 NEXT B
60 PRINT C
70 END
On line 20, 1 is assigned to variable C, that obtains the factorial, because
a wrong answer is obtained if this variable does not have 1 for initial value.
Factorial calculation is performed by the FOR-NEXT statement (from lines
30 to 50) in which the value of variable B is incremented by 1; the factorial
is obtained by calculating 1 x 2 x 3 x .... The program is terminated by
the END statement on line 70 after one calculation. However, if many fac-
torial calculations are to be performed sequentially, line 70 should be
"GOTO 10".
-84-
3-3. PROGRAM DEVELOPMENT
You are now accustomed to preparing programs; they can become long
and complicated. A program, which is convenient for performing repeti-
tive processing and is especially helpful when composing lengthy programs,
is called a "subroutine".
I I ;C J
J C J
C
I
J To a subroutine
c J
\C J
c D C J
Check its function by using an example.
Expression: Permutations „p r =
Ut^T)\
Combinations „cr=—rr1^—rr
85
CHAPTER 3 "BASIC" PROGRAMMING
C
Answer
display
n! calculation
n! calculation
r\ calculation
(n - r)\ calculation
(n - r)\ calculation
n\l(n~r)\ calculation
The calculations of n\ and (n - r)\ are used in both of permutation and com-
bination calculations. Also, three different factorial calculations are per-
formed.
86
3-3. PROGRAM DEVELOPMENT
10 INPUT N ,R ' N : n
20 A=1 R : r
30 FOR B=1 TO N P : Permutation
n! calculation
40 A=A*B C : Combination
50 NEXT B A : For factorial
60 E=A B : For FOR-NEXT
70 A=1 ' loop
80 FOR B=1 TO N- -R E : n\
90 A=A*B • (n-r)'. calculation F : (n-r)\
100 F=A G : r\
1 10 NEXT B •
•87-
CHAPTER 3 "BASIC" PROGRAMMING
[ EXERCISE ]
Prepare a program to obtain standard deviation. The data input, sum cal-
culation, sum of squares calculation, and the number of data counting are
included in a subroutine.
Expression: , 2* : Sum
ffw=/S»'-(2x) /n
v n 2x ! : Sum of squares
n '. Number of data
-88
3-3. PROGRAM DEVELOPMENT
Assign 0 to
Data input
sum
1
Assign 0 to
YES
sum of squares <CT Data = 0 ~"^>
*
f NO
I
Assign 0 to
counting Sum calculation ( RETURN
3
•
Subroutine
Sum of squares
calculation
i
Standard deviation
calculation _L
Number of
data counting
*
( Answer display )
V \
J
End
C ]
PROGRAM
10 B=0:C=0:D=0
20 GOSUB 100 To the subroutine
30 E=SQR( ( C - B * B / D ) / D ) Standard deviation
4 0 PRINT E
50 END
100 INPUT A
110 IF A=0 THEN RETURN
120 B=B+A Sum
Subroutine
130 C=C+A*A Sum of squares
140 D=D+1 Number of data
150 GOTO 100
89
CHAPTER 3 "BASIC" PROGRAMMING
The angle unit is specified on line 10. Since the calculation is performed
in degree, "MODE 4" is specified. The trigonometric function is used to
perform calculation on line 30.
90
3-3. PROGRAM DEVELOPMENT
Since the angle unit is radian, "MODE 5" is specified on line 10. The x-
coordinate and .y-coordinate are obtained on lines 30 and 40.
-91
CHAPTER 3 "BASIC" PROGRAMMING
On line 20, enter the hour, minute, and second into 3 variables, D, E, and
G respectively.
Lines 30 and 40 are used for subtraction. If the hour is entered with a nega-
tive sign ( - ) , the entered time is subtracted from the previous result. If only
addition is performed, these lines are not necessary.
The total is obtained on line 50. 1 is entered into variable S to perform
addition, and - 1 to perform subtraction. The DEG function converts sex-
agesimal (hours, minutes and seconds) to decimal, and totalization is per-
formed in decimal.
Line 60 for the display uses the DMS$ function that converts decimal to
sexagesimal.
Example) A( 1 )
' Subscript
' Variable name
-92-
3-3. PROGRAM DEVELOPMENT
10 FOR A=1 TO 10
20 INPUT N(A)
30 NEXT A
General variables 0 P Q R S T U V W X
Array variables N(1) N(2) N(3) N(4) N(5) N(6) N(7) N(8) N(9) N(10)
A B C D X Y Z
A(0) A(1) A(2) A ( 3 ) A ( 2 3 ) A(24) A(25)
B(0) B(1) B ( 2 ) B ( 2 2 ) B(23) B(24)
-93-
CHAPTER 3 "BASIC" PROGRAMMING
Assign 7 to variable I.
I=7BS
Confirm the content of variable I.
I S3
Assign 10 to the 9th container of array variable A
A ( 8 ) = 10SB
Confirm the content of variable I.
10
The content of variable I has been changed as shown above. It is because
the container for variable I is the same as that for array variable A(8). When
an array is used in a program, keep variables for FOR-NEXT loop or assign-
ment, and then determine the variable names of this array.
94
3-3. PROGRAM DEVELOPMENT
This program consists of three parts. In the first part, numerical values from
0 to 99 are generated as random numbers which are assigned to array vari-
ables G(0) to G(99). In the second part, they are arranged in the descend-
ing order. In the third part, they are displayed in this order.
The BEEP statements on lines 50 and 130 are used to generate a buzzer
sound. A high sound is generated by "BEEP 1" and a low sound generated
by "BEEP 0". Since these two lines are only used to generate sound that
indicates the termination of data preparation and arrangement, they can
be deleted from the program. Lines 60 to 120 are repeatedly executed to
arrange data in the descending order.
-96-
3-3. PROGRAM DEVELOPMENT
[ EXERCISE ]
Enter 10 data items and obtain the component ratio for each of them. Ob-
tain this ratio (percentage) with up to 2 decimal places.
A= 0
I
B= 0
E ~~-.n 1
f
B= B+ I / <
<f PRINT A J
INPUT G ( B ) SET F 2
* i
A = A + G(B) B= 0
B^
B= B+ I
"V
1
PROGRAM
10 A=0
20 FOR B = 0 TO 9
30 INPUT G ( B )
40 A=A+G(B)
50 NEXT B
60 PRINT A
70 SET F2
80 FOR B=0 TO 9
90 PRINT G ( B ) / A * 1 0 0
100 NEXT B
110 SET N
12 0 END
97
CHAPTER 3 "BASIC" PROGRAMMING
Lines 20 to 50 are used to enter 10 data items into C(0) — G(9) by a FOR-
NEXT statement. "SET F2" on line 70 specifies two decimal places for the
component ratio. This ratio is displayed by lines 80 to 100. The specifica-
tion of the decimal places is released on line 110.
PROGRAM Operation
10 FOR B=1 TO 10 RUN 333
20 READ A QJJ
30 PRINT A 033
40 NEXT B
50 DATA 1 , 2 , 3 , 4 , 5 ,
6,7,8,9,10
6 0 END 221 10
Example)
PROGRAM Operation Display
10 READ A $ , B $ RUN SB CflSIOPB&FX
20 PRINT A $ ; B $
30 END
40 DATA C A S I O . P B & F X
-98
3-3. PROGRAM DEVELOPMENT
-99-
•
CHAPTER 3 "BASIC" PROGRAMMING
[ EXERCISE ]
Read-in names CHICAGO, LONDON, PARIS, ROME, and TOKYO, and ar-
range them in the descending order of their related data.
Note that the names are assigned to G$(0)—G$(4) while data are entered
into L(0)—L(4).
Flowchart example
1
E = L(A)
L(A) = L(D)
L(D)=E
F$=G$(A)
G$(A)=G$(D)
G$(D) = F$
PRINT G$
(A); L(A)
100
3-3. PROGRAM DEVELOPMENT
This program is divided into two parts which are an input part on lines
10 to 50, and an arrangement part on lines 60 to 140. In the input part,
names are read by using a DATA statement while a loop is performed 5
times by a FOR-NEXT statement, and data are also entered at the same time.
The PRINT statement on line 30 displays the name as a message before
data is entered by the following INPUT statement. The names and data are
both simultaneously arranged on lines 110 and 120.
The DATA statement on line 150 can be placed anywhere in the program.
-101-
CHAPTER 3 "BASIC" PROGRAMMING
10 INPUT A
20 ON A GOTO 100,200,30
30 PRINT * NO*
40 END
100 PRINT *LINE 100" :END
200 PRINT "LINE 200" :END
300 PRINT *LINE 300" :END
400 PRINT *LINE 400" :END
500 PRINT 'LINE 500" :END
102-
3-3. PROGRAM DEVELOPMENT
[ EXERCISE ]
Enter an angle and a numerical value from 4 to 6, branch to the subrou-
tine that specifies the angle unit by an indirect specification, and obtain
the sine of this angle.
Flowchart
f Main routine J f Subroutine J ( Subroutine J ( Subroutine J
PROGRAM
10 INPUT 'ANGLE",A
20 INPUT *UNIT",B
30 ON B - 3 GOSUB 1 0 0 , 2 0 0 , 3 0 0
40 PRINT S I N A
50 GOTO 10
100 MODE 4
110 RETURN
200 MODE 5
210 RETURN
300 MODE 6
310 RETURN
Since two data items are entered, a message is added to each input state-
ment so that input can be easily performed. On line 10, the angle is en-
tered into variable A, and on line 20, either 4, 5 or 6 is entered into variable
B to specify the angle unit (See page 149). On line 30, the branching loca-
tion is determined by converting the 4—6 numerical value to 1—3 by us-
ing ON-GOSUB.
Each subroutine is used to specify an angle unit.
103
CHAPTER 3 "BASIC" PROGRAMMING
• LEN
The LEN function counts the number of characters in a character variable.
Example) Display
(TJtiDBBc^raSaScblSl
* An array variable cannot be used
with the LEN function.
• MID$
The MID$ function fetches characters from among those stored in the ex-
clusive character variable ($) by specifying the starting location and the
number of characters to be fetched.
Example)
Operation Display
10 $=*CASIO PB&FX"
20 PRINT $ R U N ma Chi ; I 0 PBt;FX
30 PRINT MID$(1,5) CFM:; 10
40 PRINT MID$(7,5) PBE:FX
50 END
• VAL
The VAL function converts numerals stored in a character variable to a
numerical value.
Example)
Operation Display
10 A $ = * 1 2 3 " : B $ = * 4 5 6 "
2 0 PRINT A $ + B $ RUN S3 123456
3 0 PRINT V A L ( A $ ) 5 79
+VAL(B$)
4 0 END
An array variable cannot be used with
the VAL. function.
-104
3-3. PROGRAM DEVELOPMENT
• STR$
The STR$ function converts numerical values stored in a numerical varia-
ble to a character string; this is the inverse of the VAL function.
Example)
10 INPUT $
20 FOR A=1 TO LEN($)
30 PRINT MID$(A,1);
40 BEEP 1
50 NEXT A
60 END
-105-
CHAPTER 3 "BASIC" PROGRAMMING
This program obtains the average for an unknown number of data. Data
input is terminated by entering END, and the average is displayed by branch-
ing to line 100.
Line 20 provides a message that enables easier input.
On line 50, since data is entered into the exclusive character variable ($)
as a character, totalization is performed after converting it to a numerical
value. Also, since data input is terminated by entering END, an error (ERR2)
occurs if anything else is entered.
Example)
10 INPUT A
20 PRINT A
30 B$=KEY$
40 IF B$=** THEN 30
50 PRINT B$
60 END
-106-
3-3. PROGRAM DEVELOPMENT
Line 10 uses an INPUT statement while lines 30 and 40 utilize the KEY$
function. The KEY$ function accepts input of one character from the key-
board, but no input waiting display occurs and the execution does not stop.
Therefore, this function is combined with an IF statement as shown on line
40, and if character input is not performed, a return is made to line 30.
Example)
10 A$=KEY$
20 IF A$=*1* THEN 100
30 IF A$=*2* THEN 200
40 IF A$=*3* THEN 300
50 GOTO 10
100 PRINT *LINE 100*:END
200 PRINTLINE 200*1 END
300 PRINTLINE 300*: END
In the previous example a check was made for key depression. In this pro-
gram a check is made for the keyboard entry of 1, 2 or 3. If a condition
is true, an advance is made to the next work.
When the KEY$ function is used at the beginning of a program like in this
example, pay attention to program starting. There are two different program
starting methods. When B S is used for a program starting method, un-
less the LTJ key is released immediately, the numeral 1 is read by the KEY$
function; "LINE 100" will be displayed.
When the KEY$ function is used at the beginning of a program, add the
following lines.
5 A$=KEY$ 1
6 IF A$#* * THEN 5 I Waits until the pressed key is released.
10 A$=KEY$ J
-107-
CHAPTER 3 "BASIC" PROGRAMMING
10 PRINT *A"
20 PRINT CSR 2;*A"
30 PRINT CSR 8;*A"
40 END
A PR I NT *A"
0 1 2 3 4 5 6 7 8 9 10 11
A P R I N T CSR 2;*A"
0 1 2 3 4 5 6 7 8 9 10 11
Example)
10 A=INT(RAN#*12)
20 PRINT CSR A;*t"
30 GOTO 10
108
3-3. PROGRAM DEVELOPMENT
Example)
10 D=0:$=* 0123456 789"
20 FOR B=1 TO 10
30 I F KEYS** * THEN 30
40 A=INT(RAN#*10)
50 PRINT MID$( 1 ,A+1 );*t";MID$(A+3);
60 FOR C=1 TO 30
70 E$=KEY$
80 IF E$#** THEN 100
90 NEXT C
100 IF E$<*0" THEN 130
110 IF E$>*9" THEN 130
120 IF VAL(E$)=A THEN D=D+KBEEP KGOTO 140
130 BEEP 0
140 PRINT
150 NEXT B
160 PRINT CSR 2;*RIGHT";D;
170 IF D+10 THEN 210
180 FOR B=1 TO 10
190 BEEP 1IBEEP 0
200 NEXT B
210 END
-109-
CHAPTER 3 "BASIC" PROGRAMMING
If the speed with which the display changes is too fast, set the final value
of the FOR statement on line 60 to a numeral larger than 30.
-110-
3-4. CONVENIENT OPTIONAL EQUIPMENTS
SAVE command
mm READY Pn
Z The program located in this program area
can be stored.
-Ill-
CHAPTER 3 "BASIC" PROGRAMMING
'}. — ^
o X X X
SAVE "file name"
o o X X
X X o X
• • • • • . . ;
X X o o
* Items marked with " o " can be loaded; those marked with " X " cannot be
loaded.
* File names must be identical.
Example)
LOAD m
LOAD "file name" O
LOAD ALL SB
LOAD ALL "file name" M
-112-
3-4. CONVENIENT OPTIONAL EQUIPMENTS
SAVE PF:
Precautions:
Sometimes a program cannot be stored or loaded smoothly. If this hap-
pens, check the following items.
-113-
CHAPTER 3 "BASIC" PROGRAMMING
Up to 8 characters can be placed inside " " for a file name, the same as
when a program is stored.
Example)
SAVE** 'MEMO" m
To load data for DATA BANK function from tape to the computer,
" L O A D # " is used.
The previous data are erased when new data are stored.
Example)
LOAD** *MEMO" Ed
When data for DATA BANK function are being loaded, a display depend-
ing on the storing format appears.
SAVE* MF:
-114-
3-4. CONVENIENT OPTIONAL EQUIPMENTS
For a file name, up to 8 characters can be placed inside " " as for pro-
gram storing.
If the exclusive character variable ($) is used, specify it first. Then next two
variable names are specified to determine the beginning and end of the
variables to be stored.
Example)
Store the content of the exclusive character variable ($) and 13 variables
from A to M.
PUT $,A,M
Store the content of 36 variables from A to Z(10) with a file name, "CASIO".
PUT * C A S I O * A,Z(10)
Since the variable names specify the beginning and end of the variables
to be stored, place them in alphabetical order (e.g., "A, Z"). A specification
such as "Z, A" cannot be performed.
When the variables are character variables, "A, Z" can be specified instead
of "A$, Z$".
"GET" is used to load data from a tape to the computer. Variables are speci-
fied in a GET command. A file name can also be specified.
-115-
CHAPTER 3 "BASIC" PROGRAMMING
Example)
Load data to the exclusive character variable ($) and 3 variables from X to Z.
GET $,X,Z
Load data with a "PB" file name to variables from G(0) to G(99).
GET *PB* G(0),G(99)
PUT $, A, Z DF:
116
3-4. CONVENIENT OPTIONAL EQUIPMENTS
• 0 L I S T S3 Print example
LIST
16 INPUT fi
20 PRINT fl*fl
38 SOTO 18
L 1ST ALL US
-117-
3-5. USING A PB-100 PROGRAM
Programs prepared for the PB-100 and PB-300 can be utilized with this
computer.
This computer is provided with more commands than the PB-100/PB-300;
its utilization is more convenient.
The BASIC language used by this computer is almost the same as that used
by the PB-100/PB-300.
• Different points
• Additional commands
PASS (Program protection)
BEEP (Buzzer sound)
READ (Reads data from a DATA statement)
DATA (Writes data)
RESTORE (Specifies data to be read)
ON-COTO (Indirect specification of a GOTO statement)
ON-GOSUB (Indirect specification of a GOSUB statement)
REM (Comment statement)
• Additional functions
DEG (Sexagesimal -*• decimal conversion)
DMS$ (Decimal -» sexagesimal conversion)
STR$ (Converts a numerical value to a character string)
• Modified commands
-118-
3-5. USING A PB-100 PROGRAM
• Modified functions
KEY$ KEY
MID$ MID
10 VAC
20 FOR A=1 TO 20
30 INPUT Z(A)
40 IF Z(A)>80i B=B+I:GOTO 90
50 IF Z ( A K 6 0 ; C = C + I : G O T O 90
60 IF Z(A)>40;D=D+I:GOTO 90
70 IF Z(A)>20;E=E+I:GOTO 90
80 F=F+1
90 NEXT A
This example is part of a program to enter data and distribute them accord-
ing to their size. Although the program could be used as it is, correct the
following items.
Change "VAC" on line 10 to "CLEAR".
10 CLEAR
-119-
CHAPTER 3 "BASIC" PROGRAMMING
Since memory expansion is necessary in this program, write the DEFM com-
mand, manually executed in the PB-100/PB-300, at the beginning.
5 DEFM 2 0
Example 2)
PB-100 program
10 INPUT *l=1/0=2/P=3",N
20 IF N<1 THEN 10
30 IF N>3 THEN 10
40 GOTO N*100
10 INPUT * 1 = 1/0=2/P=3*,N
20 ON N GOTO 100,200,300
30 GOTO 10
-120-
3-5. USING A PB-100 PROGRAM
LOAD "'==&ijj|
• ' • ' • • '
o / \J /
LOAD ALL o o
This computer - PB-100, PB-300, FX-700P, FX-802P
i'•.....
SAVE w d
LOAD PF AF MF
AF MF
LOAD o /
I. o /
o : Can be loaded.
\ / \ : Cannot be loaded.
[PRECAUTIONS]
• When a program prepared by this computer is transferred to other
CASIO'S computer, READ*, WRITE* and RESTORE* commands must
not be used.
KEY$ and MID$ should be changed to KEY and MID for the PB-100,
PB-300, FX-700P and FX-802P.
• When a program prepared by other CASIO'S computers is executed with
this computer, sometimes it cannot be properly executed as shown below.
* If a numerical expression is used for a branch location in an IF—THEN
statement, an error occurs. In this case, change it to an IF—THEN—
GOTO statement.
-121-
j_ CHAPTER 4
COMMAND
REFERENCE
The following descriptions apply symbols and terms frequently used in
the syntax.
• One of the elements inside | j must be selected.
loooor
oooo The element inside can be omitted
G°TOfLinenmoramflrMNo]
c # program area N o . )
There are two different ways to write this statement as shown below.
(1) GOTO line No.
(2) GOTO # program area No.
-124-
NEW [ALL]
| Function]
Program erase. Erases programs and variables.
[Parameter!
When ALL is specified, all P0 — P9 programs and variables are erased.
on
(1) If ALL is not specified, the program in the presently specified program
area is erased. Variables are not erased.
(2) If ALL is specified, the programs in all program areas and variables are
erased. The DEFM setting is released and the number of memories is
initialized to 26.
(3) Cannot be executed while a password is specified.
(4) Cannot be used in a program.
(5) Can only be executed in the WRT mode.
* NEW ALL can be abbreviated as NEW A.
0 H3Q3 NEW S3
-125-
P I 1KI [Execution start line] @
line No.
j Function)
Program execution.
ter]
When a line is specified, execution starts from the line.
'ion]
(1) Executes a program from a specified line (when the line number is omit-
ted, execution starts from the beginning of the program).
(2) When a specified line number does not exist, execution starts from the
line with the closest larger number.
(3) Variables are not cleared.
RUN SB LINE 16
RUN 20 6S LINE 28
126
LIST [[linAtLNa}]
[Function]
Displays the content of a program.
IParamAtwl
Line No.: No. of the first line to be displayed.
ALL: Displays the content of all P0—P9 programs sequentially.
^Explanation]
I. RUN mode
(1) Sequentially displays the content of a program from a line number if
it is specified, or from the beginning if it is omitted.
(2) Since the content of a program is automatically displayed sequentially,
press the [STOP] key to stop this. Press the M key to display the next line
and after.
(3) In the PRINT mode (when "PRT" is displayed), the display is not stopped
but is made sequentially at high speed.
II. WRT mode
(1) Displays the content of a program from a line number if it is specified,
and from the beginning if it is omitted.
(2) Since each line is displayed for edit in the WRT mode, if edit is not
required, press the IS key to advance to the next line. Also, if the S
key is pressed before the 6S key, the previous line is displayed.
• When ALL is specified, the content of all P0—P9 programs are sequen-
tially displayed. In this case they are sequentially advanced even in the
WRT mode, so edit cannot be performed.
• This command cannot be used while a password is specified.
• LIST ALL can be abbreviated as LIST A.
| Example I L I ST S3
LIST 3 0 023
-127-
"Password"
PASS Character string
[Function)
Specifies or releases a password.
•?r]
Password: String with 1—8 characters.
[Precaution |
If a password was forgotten after it was specified, press the ALL RESET
button on the back of the computer and clears all the programs and
memory.
-128-
["File name"!
SAVE [ALL] Character string
(1) When ALL is omitted, the content in the presently specified program
area is stored.
(2) When ALL is used, the contents of all P0—P9 program areas are stored.
(3) When a password is specified, the storing is performed with that pass-
word. Therefore, the password is the same as that stored when the pro-
gram is loaded by the LOAD command.
* SAVE ALL can be abbreviated as SAVE A.
[Example] SAVE 3D
SAVE'CASIO"SB
SAVE ALL*PB*EB
129
["File name"] <8>
LOAD [ALL] Character string
[Function]
Loads a program from a cassette tape.
[Parameter]
ALL: Loads the programs in all program areas.
File name: String with 1—8 characters. Can be omitted.
on]
(1) When ALL is omitted, a program stored by "SAVE" is read into the
presently specified program area.
(2) When ALL is used, programs stored by "SAVE ALL" are read into the
P0—P9 program areas.
(3) When a program stored with a password attached is loaded from a cas-
sette tape, this password is also loaded.
* Load ALL can be abbreviated as LOAD A.
SAVE
"File name" O O X X
SAVE ALL X X O X
SAVE ALL
"File name"
X X O O
-130-
["File name"] @
VERIFY Character string
Parameter
File name: String with 1—8 characters. Can be omitted.
(1) When a file name is specified, the file with this name is checked.
(2) When the file name is omitted, checks the first file that appears on the
cassette tape.
(3) The parity check system is used to check a storing format.
|Example| VERIFY ED
VERIFY *PROG1 * M
CLEAR ®
(1) Clears all variables; all numerical variables are cleared to 0 and all
character variables to a null.
(2) This command can be used both in a program and manually.
(3) Since control variables are also cleared in a FOR-NEXT loop (see page
140), an error occurs during NEXT statement execution.
* The CLEAR command functions the same as VAC.
131-
END
I
Terminates program execution.
STOP
Functic
Temporarily suspends program execution.
Explanation
(1) Temporarily suspends program execution and displays "STOP" after
which input waiting occurs.
(2) After suspension, execution is resumed by pressing the BS key.
(3) If the [HEkey is pressed while execution is stopped by a STOP state-
ment, the program area number and line number are displayed.
(4) During execution suspension by STOP, manual calculations can be per-
formed.
Assigns the value of the expression on the right to the variable on the left.
<pianationl
(1) A numerical expression corresponds to a numerical variable, and
a character expression corresponds to a character variable.
(2) LET can be omitted.
-132-
lExamDlel 10 LET X = 1 2
20 LET Y = X t 2 + 2 * X - 1
30 PRINT Y
40 A $ = * CASIO"
50 B$=*PB&FX "
60 PRINT A $ ; B $
70 END
Comment
REM Character string
•on
Statement that expresses a comment.
>n]
(1) Written in a program. Content after REM is treated as comment state-
ment and is threfore not executed.
(2) When a command to be executed is written on the same line, write
a multistatement sign (:) before the REM statement.
10 INPUT * R * ,R
2 0 S = ; r * R t 2 : R E M AREA
3 0 PRINT S
4 0 END
-133-
(1) Input data from the keyboard to a specified variable.
(2) When a message exists, it is displayed followed by "?".
(3) When there is no message, only "?" is displayed.
(4) Press the SS key after data input.
(5) When character data are entered into a numerical variable, an error
(ERR2) occurs and data input is requested again by the display of "?"
after the ES key is pressed. When a numerical expression is entered,
the result of this expression is assigned. When one alphabetical character
is entered, the value of the variable corresponding to this character is
assigned.
(6) When the 133 key is pressed during input waiting, it becomes null in-
put. So, an error (ERR2) occurs if the variable is a numerical variable.
fE^arnP'ej 10 INPUT A
20 INPUT * B $ ^ ' , B $
30 INPUT * C$= * , C $ , * D$= * , D$
KEY$ ®
I Z— I
(1) The input of only one character is accepted from the keyboard.
(2) Numerals, alphabetical characters, and symbols can be input.
(3) Since "?" is not displayed and input waiting does not occur, KEY$ is
usually combined with an IF statement.
* KEY$ can be abbreviated as KEY.
I Example I
10 PRINT * I N P U T < 6 > * ;
20 A $ = * *
30 K$=KEY$
4 0 IF K $ = * "THEN 30
50 A $ = A $ + K $
6 0 IF L E N ( A $ ) < 6 THEN 30
70 PRINT A$
8 0 END
* Six characters are accepted from the keyboard.
-134-
PRINT [ ° u t P u t element] [ [ \ ] [Output element]]* ®
I Function I
Displays an output element.
-135-
I Example
10 PRINT 1/3
20 PRINT * A » * ; A
30 PRINT " S I N 3 0 " , S I N 30
40 PRINT * E N D " ;
50 PRINT
60 END
DDDDDDDDDDDD
0 1 2 3 4 5 6 7 8 9 10 11
10 FOR l=0 TO 1 1
20 PRINT CSRi: *A*;CSR 11-i;*B*
30 NEXT I
40 END
A and B characters are shifted from the left and right respectively each
time the Si key is pressed.
136-
Branching line No. "^ (g)
GOTO line No.
# program area No.
Number 0 to 9
•xample
10 PRINT * START" ;
20 GOTO 100
30 PRINT 'LINE 30"
40 END
100 PRINT *LINE 100"
110 GOTO 30
-137-
i
ON Branch condition ^ ^ ^ ^ T ^ ^ [Branching location]
Numerical expression V ^ V ^ I > • [, [Branching location]]*
* Branching location
(£)
Branching line No.
^ # program area No.
| Function |
Branches to a specified location according to the branching condition.
EST]
(2) When the value of the expression is smaller than 1, or when an ap-
propriate branching location does not exist, the next statement is ex-
ecuted without branching.
(3) As many branching locations that can fit on one line can be written.
Exan \\
10 INPUT A
20 ON A GOTO 1 0 0 , 2 0 0 , 3 0 0
30 PRINT *OTHER*
40 GOTO 10
100 PRINT ' L I N E 1 0 0 " : G O T O 10
200 PRINT *LINE 2 0 0 " : G O T O 10
300 P R I N T L I N E 3 0 0 " : G O T O 10
-138-
Irjjj Branching condition T L I I Z K I ("Statement [: statement]*") (B)
Conditional expression 1 E M 1 1 1 [Branching location j
f Branching line No.
• Branching
a location { „
( # program area No.
| Explanation
(1) When the branching condition is true, the statements after THEN are
executed or branching is performed.
(2) When the branching condition is false, the next line is executed.
(3) The branching condition is tested by a conditional expression (=, ^F,
<,
The item on the left is equal to the item on the right.
The item on the left is not equal to the item on the right.
< The item on the right is larger than that on the left.
> The item on the right is smaller than that on the left.
< The item on the right is larger than or equal to that on the left.
The item on the right is smaller than or equal to that on the left.
(4) When two or more branching conditions exist, several IF-THEN state-
ments can be written sequentially.
IF — T H E N IF — T H E N
When a statement exists after THEN, " ; " can be used instead of THEN.
Example |
10 N=6
20 PRINT CSR N ; * t " ;
30 K$=KEY$
40 IF K $ = * 4 * T H E N N = N - K I F N<0THEN N=0
50 IF K $ = * 6 " T H E N N = N + i : i F N>11THEN N=11
60 PRINT
70 GOTO 2 0
• " t " is shifted to the left when the (D key is pressed and is shifted to
the right when the ED key is pressed.
-139-
r * A N f > Control variable name = Initial value l £\ Final value (g)
I V M Numerical expression I ^ ^ Numerical expression
lncrement
rQT P D 1 M F Y T Control variable name
I KJ I kal Numerical expression J B WI™H#% I
I r i l l H.UVJ |
ler J
Control variable name: Simple variable name.
An array variable can not be used.
Initial value: Numerical expression
Final value: Numerical expression
Increment: Numerical expression
The value 1 is taken in default of this.
ionj
(1) Repeats process contained between FOR and NEXT statements a number
of times specified by the control variable. The value of this variable is
changed, from the initial to the final one, by the increment for each
repetition of the process. When the value of the control variable ex-
ceeds the final value, repetition is terminated.
(2) When the initial value is larger than the final value, the execution be-
tween FOR-NEXT is performed only once.
(3) A negative number can be used for an increment.
(4) A NEXT statement must always correspond to a FOR statement and must
be written after it.
(5) FOR-NEXT loops can have the following nested structure.
10 FOR 1 = 1 TO 10 —|
20 FOR J - 1 1 TO 20n
30 PRINT I : * : * ; J
40 NEXT J J
50 NEXT I —I
60 END
(6) Nesting can be performed with up to 4 levels.
-140-
(7) When a FOR-NEXT loop is terminated, the value of the control varia-
ble exceeds the final value by the value of the increment.
(8) A branching out of a FOR-NEXT loop can be performed. If branching
inside a FOR-NEXT loop by an IF statement or GOTO statement is at-
tempted, an error occurs.
on1
(1) Performs a branching to a subroutine. A return from this subroutine is
performed by executing RETURN-
(2) To make a subroutine inside a subroutine is called nesting which can
be performed with up to 8 levels.
(3) Return to the statement next to the GOSUB statement is performed by
RETURN.
(4) Return to the main routine cannot be performed by an IF statement
or GOTO statement. Therefore, be sure to perform return by a RETURN
statement.
(5) When the branching line No. does not exist, an error (ERR4) occurs.
* A numerical expression can also be used for a branching line number
and a program area number.
-141-
[Example 1 10 PRINT * M A I N 1 0 "
20 GOSUB 100
30 PRINT * M A I N 3 0 "
40 END
100 PRINT *SUB 1 0 0 "
110 GOSUB 2 0 0
120 RETURN
200 PRINT *SUB 2 0 0 "
210 RETURN
RETURN
Functic
Provides a return from the subroutine to the main program.
j Explanation
Returns to a statement located just after the statement which called
the subroutine.
' Function |
Parameter)
Branching condition: Numerical expression.
Values below the decimal point are discarded.
Branching line No.: Line No. from 1 to 9999.
Program area No.: A character from 0 to 9.
-142-
ON B GOSUB 1000, 2000, 3000-
10 INPUT A
20 ON A GOSUB 100,200,300
30 GOTO 10
100 PRINT *SUB 1 0 0 " : R E T U R N
200 PRINT *SUB 2 0 0 " .'RETURN
300 PRINT *SUB 3 0 0 " : R E T U R N
[data] [.[data]]* ®
DATA Constant Constant
Stores data.
-143-
R E A D Variable name [, [ variable name]]*
Function]
Reads the content of a DATA statement.
[Parameter]
Variable name: Numerical variable or character variable. An array vari-
able can be used.
-144-
RESTORE —N°'
Numerical expression
Line No.: Numerical expression. Values below the decimal point are
discarded.
1 <line No. < 9999
10 DATA 1,2,3
20 DATA 4,5
30 READ A,B,C,D,E
40 RESTORE 10
50 READ F,G
60 RESTORE 20
70 READ H,I
80 PRINT A;B;C;D;E;F;G;H;I
90 END
-145
P I i-|- [ " File name " ] variable 1 [, Variable 2 ]* ®
t \ J I Character string
Function
Stores data on a cassette tape.
Parameter
File name: A string with 1—8 characters. Can be omitted.
Variable 1, variable 2: Specification of the variable to be stored.
•on)
(1) Stores the contents of variables on a cassette tape.
(2) Variable specifications are written as follows.
PUT A Content of variable A.
PUT A,Z Content of variables A—Z.
PUT A,A(100) Content of variables A—A(100).
PUT $,D,W Content of the exclusive character variable $
and of variables D—W.
When the content of the exclusive character variable $ must be stored,
write $ first.
(3) Can be executed both manually and in a program.
I Function]
Loads data stored on a cassette tape into a variable.
terj
File name: A string with 1—8 characters. Can be omitted.
Variable 1, variable 2: Specification of the variable to be loaded.
[Explanation)
(1) Loads data stored on a cassette tape into a specified variable.
(2) Variable specifications are written as follows.
GET A Loads in variable A.
GET A,Z Loads in variables A—Z.
GET A,A(100) Loads in variables A—A(100).
GET $,D,W Loads in the exclusive character variables $,
and in variables D—W.
-146-
(3) A variable name stored by PUT can be different from the name read
by GET.
(4) When the number of stored data is smaller than the number of varia-
bles to be loaded, only the data are loaded sequentially in the first
variables.
(5) It can be executed both manually and in a program.
BEEP [[•}] ®
[Function]
Generates a beep sound.
er]
0: Low sound
1: High sound
0 is taken by default.
Example)
10 $=*ABCDEFGHI JKLMNOPQRSTUVWXYZ*:N=0
20 FOR 1=1 TO 10
30 A $ = M I D $ ( R A N # * 26 + 1,1 )
40 PRINT CSR4;*<*;A$;*>*;
50 FOR J=1 TO 30
6 0 K $ = K E Y $ : IF K$#*"THEN80
70 N E X T J
80 IF K$=A$ THEN BEEP 1 :N = N + I :GOTO 100
9 0 BEEP 0
100 PRINT:NEXT I
1 10 PRINT NJ
120 IF N > 10 THEN END
130 FOR 1=1 TO 10
140 BEEP 0:BEEP 1
150 NEXT I
• Press the alphabetical keys that correspond to the displayed characters.
-147-
mZEIMI [ Size of memory expansion ] @
Numerical expression
| Function |
Provides memory expansion.
Parameter
Size of memory expansion: Numerical expression. Values below the
decimal point are discarded.
Can be omitted.
0 S Size of memory expansion < 69
oni
(1) Expands the memories (variable area).
(2) An arbitrary number can be specified according to the remaining num-
ber of program steps.
(3) Since 8 steps are required for each memory expansion, the number
of remaining steps is reduced.
(4) When the size of memory expansion is omitted, the number of cur-
rently specified memories is displayed.
(5) It can be executed both manually and in a program. When it is manu-
ally executed, the status (number of expanded memories + 26 basic
memories) is displayed. When executed by writing it in a program, the
status is not displayed.
(6) When an attempt is made to perform expansion larger than the num-
ber of remaining program steps, an error (ERR1) occurs.
(7) Specify DEFM 0 to cancel the memory expansion and to return to the
26 basic memories.
DEFM 10 M * * * U A R •" 3 6
DEFM US frfrfrUAR: 36
10 DEFM 10
20 FOR 1=1 TO 10
30 INPUT Z( I )
40 NEXT I
-148-
I v I O D E Numerical expression
[Function]
Sets the state of the computer.
Para.
Numerical expression: Values below the decimal point are discarded.
4 <« numerical expression < 9
lion |
(1) Sets the angle unit, print mode or releases this mode depending on
the numerical expression used.
(2) Settings are as follows.
M0DE4 Sets the angle unit to degrees.
M0DE5 Sets the angle unit to radians.
M0DE6 Sets the angle unit to grades.
M0DE7 Displays "PRT" and sets the print mode.
M0DE8 Releases the print mode.
(3) Same setting as by the B key. However, the RUN mode and WRT mode
cannot be set using this command. Also, input cannot be performed
with the B key, but by pressing the®[o}QlL(r) keys.
10 MODE 4
20 A=SIN 30
30 MODE 7
40 PRINT A
50 MODE 8
60 END
-149-
m ®
• n is an integer from 0 to 9.
| Function |
Specifies the output format for numerical data.
10 INPUT N
20 SET F 5 : P R I N T N
30 SET E 5 : P R I N T N
40 SET NrGOTO 10
150
CHARACTER FUNCTIONS
i Fund
Gives the length of the character string in a simple character variable.
er)
Simple character variable: An array variable can not be used.
10 INPUT A$
20 PRINT LEN(A$)
30 GOTO 10
-151-
( Location [ , Number of characters ] ) (?)
Numerical expression Numerical expression
| Function
Fetches the specified number of characters from a specified location of
the exclusive character variable ($).
lerj
Location: Numerical expression. Values below the decimal point are
discarded.
1 g location < 101
Number of characters: Numerical expression. Values below the decimal
point are discarded.
1 ^ number of characters < 101
When omitted, all characters after the specified location are fetched.
on]
(1) Fetches a specified number of characters from a specified location of
the exclusive character variable ($).
(2) When the specified location is out of the character string, a null is ob-
tained.
(3) When the length of the character string after the specified location is
smaller than the specified number of characters, all the characters af-
ter the specified location are fetched.
* MID$ can be abbreviated as MID.
-152-
V/\|, ( Simple character variable )
[Function]
Converts characters in a simple character variable into a numerical
value.
3rJ
Simple character variable: An array variable cannot be used.
lion |
(1) Converts characters in a simple character variable into a numerical value.
(2) When the content of a character variable includes +, - , •, E or l ~ ,
it is converted into a numerical value as it is.
When A$ = "-12.3 ", VAL(A$) -* -12.3
(3) When the content of a character variable starts with a character other
than a numeral, +, - , or •, an error occurs.
When A$ = " A45 ", VAL(A$) r* - error (ERR2)
(4) When a character other than a numeral is inserted in the middle, only
the part before this character is converted to a numerical value.
When A$ = " 78A9 ", VAL(A$) -» 78
10 INPUT A$
2 0 PRINT V A L ( A $ )
30 END
-153-
5 T R S ( Numerical expression ) ©
onj
(1) Converts the value of a numerical expression into a character string.
(2) When the numerical expression is a calculation expression, the calcu-
lation result is converted into a character string.
(3) When a numerical expression is positive, the sign digit is deleted and
only the numerals are converted.
10 PRINT STR$( 1 2 3 )
20 PRINT STR$( 4 5 + 7 8 )
30 A=963
40 PRINT S T R $ ( A )
50 END
154-
NUMERICAL FUNCTIONS
J A M Argument
I ^ ^ 1 T| Numerical expression
Function
:erj
Argument: Numerical expression
-1440° < argument < 1440° (degrees)
- 8 7r < argument < 8 ir (radians)
- 1 6 0 0 < argument < 1600 (grades)
However, for TAN,"| Argument | = ( 2 « - l ) * 1 right angle"
is excluded.
1 right angle = 90° = - y rad - 100 grad.
155-
A C M Argument A ^ O Augument (p)
f\>V? I X Numerical expression f^\f^J Tjumerical expression
A T M Argument
f^ I I ™ Numerical expression
| Function]
Inverse trigonometric function that obtains an angle for a given ar-
gument.
let |
Argument: Numerical expression.
For ASN, ACS, - 1 ^ argument g 1.
[Explanation]
(1) Inverse trigonometric function that obtains an angle for a given argument.
(2) The value depends on the angle unit setting (by the I B key or MODE
command).
(3) The values of the functions are given within the following range.
-90°s£ASN X ^90°
f/^ACS X =£180"
-90°SATN X S90°
-156-
P Y D Argument (F)
Numerical expression
(Function |
Gives the value of an exponential function.
Argument
SQR Numerical expression
Function
Gives the square root of an argument.
-157-
A D Q Argument ©
Numerical expression
[Function j
Gives the absolute value of an argument.
Parameter
Argument: Numerical expression.
Explanation
Gives the absolute value of an argument.
ABS |x I
Q f * M Argument (F)
wVjIlM Numerical expression
(Function]
Gives a value that corresponds to the sign of an argument.
Parameter
Argument: Numerical expression.
iExplanatic
Gives a value that corresponds to the sign of an argument.
When an argument is positive, 1
When an argument is 0, 0
When an argument is negative, - 1
I M T Argument ©
I™ Numerical expression
I Function
Gives the maximum integer that does not exceed an argument.
-158-
Gives the maximum integer that does not exceed an argument.
INT 12.56 -» 12
INT - 7 8 . 1 -* - 7 9
CDAP Argument ©
n M v Numerical expression
Gives the value of an argument which is rounded off at the specified lo-
cation.
Parai
Argument: Numerical expression.
Location: Numerical expression. Values below the decimal point are dis-
carded.
- 1 0 0 < location <100
(1) Gives the value of an argument which is rounded off at the specified
location.
-159-
(2) The argument is rounded off at the 3rd decimal place (10 3).
-» RND(;c, - 3 )
The argument is rounded off at the place of 100s (102).
- RND (x, 2)
RAN # (F)
| Function |
Gives a random number from 0 to 1.
tion [
(1) Gives a random number from 0 to 1.
0 < random number < 1
(2) The random number has 10 digits.
| Example | r
-160-
I Parameter!
Degree: Numerical expression.
Minute: Numerical expression.
Second: Numerical expression.
| DEG (degree, minute, second)| < 10100
[Explanation)
Converts sexagesimal expressed by degree, minute, and second to decimal
•xample
DEG( 1 2 , 3 4 , 5 6 ) BS
10 INPUT A,B,C
20 PRINT DEG(A,B,C)
30 END
Argument
DMS$ Numerical expression
on)
(1) Converts decimal to sexagesimal.
(2) The converted result is provided as a character string.
| Example |
DMS$(45.678) 45040:' 4 @ B 3
10 INPUT A
20 $ = D M S $ ( A )
30 PRINTS
4 0 END
-161-
DATA BANK COMMANDS
NEW#
| Function'
Erases data for Data Bank function.
| Example] ggrr]
NEWttEB
LIST# <8>
• • • . . .
[Sample] LISTttffll
-162-
[
Q AX/p 4t "File name" 1 @
Character string
rv)
Stores data for Data Bank function on a cassette tape.
[Explanation]
(1) Stores data on a cassette tape.
(2) Since data for Data Bank functions cannot be stored with SAVE or SAVE
ALL, be sure to use SAVE#.
(3) If a password has been specified, storing is performed with this pass-
word. Therefore, the same password must be specified when the load-
ing is performed by the LOAD# command.
(4) Cannot be executed in the input mode for Data Bank function.
(Example) SAVEttGB
SAVE#*CASIO*GB
iFunctonl
Loads data for Data Bank function from a cassette tape.
3
arameter
File name: A string with 1—8 characters. Can be omitted.
onj
(1) Loads data stored on a cassette tape.
(2) When data stored with a password are loaded, this stored password
must be specified.
(3) If data exist in the computer, new data are loaded after existing data
are cleared.
(4) Cannot be executed in the input mode for Data Bank function.
Parameter]
Variable name: Numerical variable or character variable.
An array variable can also be used.
ion]
(1) Sequentially reads stored data to a variable.
(2) Only numerical type data can be read for a numerical variable. If charac-
ter type data are used, an error (ERR2) occurs.
(3) After the necessary data are read by a READ # statement, the following
data are read by the next READ # statement.
(4) When data are punctuated by " , ", they are read in the order in which
they are written.
Example) DATA
No. 1 A , X , Y
No. 2 B,Z
No. 3 C
Reading sequence
A->X-^Y—B-»Z~+C
(5) When data to be read does not exist, an error (ERR4) occurs.
(6) The data sequence to be read can be modified by RESTORE # (see page
165).
(7) When a space exists at the beginning of a data, it is skipped.
(8) When data is inside " ", the character string inside " " is read.
[ f Line number ^1
[RjnctionJ
Searches data for Data Bank function and specifies the sequence of the
data to be read by READ#.
er]
Searched character string: Character expression. When a character string
is used, place it inside " ".
Line number: Numerical expression.
0 < line number < 10000
Program area No.: Numerical expression.
0 s program area No. < 10
(1) Searches data and specifies the sequence of data to be read by the fol-
lowing READ# statement.
(2) The relationship between a parameter and data searching is as follows.
0 RESTORE #
When the searched character string and after are omitted, data are
read from the beginning by the following READ #.
© RESTORE # "searched character string"
Searches data that begins with the searched character string, and
this data is read by the following READ#.
(3) RESTORE # "searched character string", f ® ]
When 0 is specified, it is the same as (2).
When 1 is specified, the first data of the line that includes searched
data is read by the following READ# statement.
® RESTORE # "searched character string", I" f ® j ~|»
p i n e number 1
L# program area No. j
When executing searching, it branches to the specified line or a
program area if appropriate data does not exist.
* ln(2)and(D, when appropriate data does not exist, an error (ERR4) occurs.
* I n ® , when a branching line number does not exist, or when a program
does not exist in the program area, an error (ERR4) occurs.
-165-
Example]
(Data)
No.1 FOSTER,347-4811 .NEW YORK
No.2 S M I T H , 0 4 5 - 2 1 1 - 0 8 2 1 .CHICAGO
No.3 J O N E S , 0 6 - 3 1 4 - 2 6 8 1 ,SAN FRANCISCO
No.4 BROWN , 0 7 5 - 3 5 1 - 1 1 61 ,LOS ANGELES
(Program)
10 RESTORE** ]
Data stored at the beginning
2 0 READ** $
is displayed.
30 PRINT $ J
4 0 RESTORE***S" ]
50 READ** $ Data whose initial letter is S is displayed.
6 0 PRINT $ J
70 RESTORE** * L O " , 1 j Searches data whose initial two letters are
8 0 READ** $ LO, and displays the first data on the line
which includes the data.
9 0 PRINT $
100 RESTORE***AA", 1 , 2 0 0 When data whose initial two letters are
1 10 READ** $ AA does not exist, branching to line 200
120 PRINT $ is executed.
130 END
2 0 0 PRINT*END*
2 1 0 END
RUN I
SMITH
BRQUH
END
-166-
[ Data [ , Data]*]
WRITE # expression expression
Function
Rewrites or deletes data for Data Bank function.
Example
10 REM WRITE
20 RESTORE**
New data is written.
30 WRITE***A,B,C*
40 RESTORE**
50 FOR 1=1 TO 3
60 READ** $: PRINTS,*
70 NEXT I
80 PRINT* *
90 REM CHANGE
100 RESTORE**
1 10 FOR 1=1 TO 3 -Data is rewritten.
120 WRITE** STR$(I)
130 NEXT I
140 RESTORE**
150 FOR 1=1 TO 3
-167-
160 READ** $ : PRINT $ ;
170 NEXT I
180 PRINT* *
190 REM CLEAR
200 RESTORE**
210 WRITE** Data erase
220 RESTORE**
230 READ** $
Operation Display
ABC
123
ERR4 P0- 230
1
Shortage of data due to data erase.
-168-
CHAPTER 5 _
PROGRAM
LIBRARY
1. Statistical Calculation
2. Cross Total
3. Car Race Game
4. Bonbardment Game
5. Athletic Game
1. STATISTICAL CALCULATION
This program can be used for both standard deviation calculation with one
variable, and regression analysis with paired variables. Its utilization is very
simple since the answer can be obtained by just entering data. As many
data as desired can be entered.
The calculation expressions are as follows:
n: Number of data Lx: Sum of x data
Ly: Sum of y data Ex 2 : Sum of squares of x data
£y 2 : Sum of squares of y data Lxy: Sum of products of data
T.x
Mean of x data (x):
n
Mean of y data (y):
n [When sample
Standard deviation of x data {xanA): / nlx'-gx) population data are
/ n(n-i) used]
TiS.x'~ (2X)' [When finite popula-
Standard deviation of x data (xa„) : J z? tion data are used]
-170-
1. STATISTICAL CALCULATION
-171-
CHAPTER 5 PROGRAM LIBRARY
• Variable contents
1 2 3 4 5
.v (Temperature) 10 15 20 25 30
y (Steel bar) 1003 1005 1010 1011 1014
Operation Display
RUN SB I START ?(
The program asks whether one variable or paired variables to be used. Since
paired variables are used in this example, press the E key.
IS I y, DfiTH 1 ?
-172-
1. STATISTICAL CALCULATION
101 K'HTH IV
10031 --3TR 27
151
10051 )HTH 37
301 jftTfi 57
10141 )HTfl 67
I t i D I
CO (0-1 7)
Next, to select the display of an answer, enter the corresponding code No.
(0—17). These code numbers are listed after this example.
First, obtain the means of x and y data.
(x) 41 MEfiNX== 20
•™i
I INPUT : 0 -• i 7 )
(tf) 91 MEflNV= 1008. ft
INPUT- 18-17)
•™i
* Contents inside dotted lines at the left of the display are sequentially moved
forward and disappear.
Next, obtain the linear regression constant term, linear regression coeffi-
cient, and correlation coefficient.
173
CHAPTER 5 PROGRAM LIBRARY
Next, obtain the estimated value of x (x) when y is 1000, and the estimat-
ed value of y (y) when x is 18.
161 DATA?
2/n) 10001 I_ E.JJ X =: 4. 64 k' ':• 5 r143
I INPMT(0-17)?
171 •X DHTH?
181 1007.4S
INPUT(0-17)?
To terminate the calculation, enter 0.
em t. I'-! V
RUNI STfiRT • : ! ( V / N )
B DflTR l OR 2?
m K DHTR 1?
101 K DHTH J
~ •''
••;:• .•••J
151 X DATA
_174-
1. STATISTICAL CALCULATION
• Point •
In this program, variables are used in two different ways which are as ordi-
nary variables from B to P, and as array variables A(1) to A(15).
Since variable B uses the same box as array variable A(1), the content is the
same although the names are different. Since a different calculation expres-
sion is used up to line 330, variables are treated as ordinary variables such
as B, C, D
The program can be shortened and simplified by entering the code num-
ber on lines 340 and after; an array A(1)—-A(15) is used.
-175-
2. CROSS TOTAL
This program consists of six independent programs. The "Data Input Pro-
gram" entered in PO is used to specify the vertical and horizontal items
of the table in w h i c h data are entered.
The "Display (Printing) Program" entered in P1 is used to sequentially dis-
play or print the data located in the table.
The " D a t a Edit Program" entered in P2 is used to correct stored data.
The "Calculation Program" entered in P3 is used to obtain the vertical sub
totals, horizontal sub totals, and grand total.
The "Data Storing Program" entered in P4 is used to store the data on a
cassette tape.
The "Data Loading Program" entered in P5 is used to load data from a cas-
sette tape to variables.
Let's execute this program w i t h the f o l l o w i n g data.
I I 2 3 | 4 | 5 6
I 376 159 248 767 311 351
2 320 85 287 833 291 541
3 480 41 166 750 426 367
~ 4 ~ 518 269 343 565 221 268
5 536 158 426 495 235 492
Operation Display
When a new table is prepared,
eg Hew [V- •HI? press Y.
Y UEF T I :AL? Enter the number of vertical items.
5131 HOP T 7 DNTflL?
.!. 1....
Enter the number of horizontal items.
6 8S 1) V
i—i.
( b £ .-'
159SS ( 1, '~\"'! ?
248S3 ( 1, 4) ?
235I ( 5: f,) •p
492I END Data input termination.
-176-
2. CROSS TOTAL
( 5? 6) 492
END
The Edit Program entered in P2 is used when entered data are incorrect
or when a part of the data must be modified.
For example, the data located at the intersection of vertical item 3 and
horizontal item 4 has been mistakenly entered as "450".
Operation Display
es
363
UERTICRL? Specifies the vertical item.
Specifies the horizontal item.
HORIZONTAL^
4333 ( 3, 4) 456? Data located at the intersection of
750SB vertical item 3 and horizontal item
4 is displayed. Enter the correct
numerical value.
To check the following data, press 63 S3 , and to check the previous data,
press O S S .
4, 1) 51?
After correction is completed, press Q BS to return to "VERTICAL?" dis-
play which allows to specify a vertical item and a horizontal item. If BBS
is pressed while "VERTICAL?" has been displayed, the program is ter-
minated.
i'H
177-
CHAPTER 5 PROGRAM LIBRARY
The program entered in P3 is used to obtain the vertical sub totals, horizontal
sub totals, and grand total.
Operation Display
HS F'r i n t e r [''!''.• i -i J :
• To output to the printer, press Y.
N H.TOTAL First the horizontal sub totals are dis
(SI played.
( 1) 2212
B31 (. 2) 235'?
Q3| U.TOTAL ••• Next, the vertical sub totals are dis-
(03 ( l) ??7M played.
ITH ( 2:) 712
The programs for data storage entered in P4 and P5 need an FA-3 cassette
interface.
The P4 program stores data on a cassette tape. Connect the mainframe and
a cassette tape recorder via the FA-3, and insert plugs in the microphone
jack and remote control jack.
The P5 program is for loading. Connect the mainframe and a cassette tape
recorder via the FA-3, and insert plugs in the earphone jack and remote
control jack.
Install a new cassette tape when storing is performed, and a cassette tape
on which data are stored when loading is performed.
• Point *
Since this program uses a total of 1,107 steps, the number of data (vertical
x horizontal) is within 57 when the RC-2 is used, and within 313 when
the RC-4 is used. When more data is to be handled, modify "57" on line
80 of P0 according to the remaining number of steps.
The calculation program entered in P3 is used to obtain the vertical sub
totals, horizontal sub totals, and grand total. If other calculations should
be performed, modify this program.
178
2. CROSS TOTAL
P9 P! P2
18 PRINT "New IY/N 18 PRINT "Printer! 18 INPUT "VERTICAL
]?•; Y/NI"; V*
28 K$= KEY*: IF K$ 28 K$= KEY*: IF K$ 20 IF *="=" THEN P
="Y" THEN PRINT •»* THEN 28 RINT "END";: EN
: GOTO 58 38 PRINT 0
38 IF K$=" THEN 2 48 IF K$='Y" THEN 38 IF *>"*" THEN I
8 NODE 7: PRINT " F $ < V THEN 58
48 PRINT .' GOTO 21 DATA" 48 GOTO 18
8 58 FOR 1=1 TO Y 58 INPUT "HORIZONT
58 CLEAR 68 FOR J=l TO X AL\P
68 INPUT "VERTICAL 78 PRINT • C ; I ; V 68 0= VflL(t)
>i v
;j;')';Z((i-D* 78 PRINT '(";0;","
71 INPUT "HORIZGNT W) ;p;")";Z((0-D*
fil",X 88 NEXT J X+P);: INPUT $
88 IF Y*X>57 THEN 98 IF K$="Y" THEN 38 IF $="=" THEN 1
68 PRINT • " 8
98 DEFh* X*Y 188 NEXT I 98 IF $="+" THEN 1
188 FOR 1=1 TO Y 118 HODE 8 48
118 FOR J=l TO X 128 PRINT "END" 188 IF *=•-' THEN 1
128 PRINT *( , ;IJV 151 steps 68
fj;")';: INPUT 118 IF $>"*" THEN I
$ F $<"x" THEN 13
138 IF $>•*' THEN I 8
F $ < V THEN 18 128 SOTO 78
8 138 Z((0-1)*X+P)= V
148 IF $*•=" THEN 1 AL($)
18 148 IF P+1>X THEN 0
158 IF J-l>8 THEN J =0+l:P=8: IF 0>
8J-1: GOTO 128 . Y THEN 0=l:P=l:
168 IF H < 1 THEN 1 GOTO 78
28 158 P=P+l: GOTO 78
178 I=H:J=X: GOTO 168 IF P-Kl THEN 0
128 =0-l:P=X+l: IF
188 Z«I-1)*X+J)= Y 0<1 THEN 0=Y:P=
flL($) X: GOTO 78
198 NEXT J 178 P=P-l: GOTO 78
288 NEXT I
218 PRINT 'END' 273 steps
281 steps
179
CHAPTER 5 PROGRAM LIBRARY
P3 P4 P5
18 PRINT "Printer! 18 PRINT "DATA PUT 18 PRINT "OflTR 6ET
• •
J
148 8=8
158 FOR J=l TO X
168 fl=8
178 FOR 1=1 TO Y
188 fl=fl+Z((I-l)*X+J
)
198 NEXT I
288 PRINT •(•;};")'
;fl
218 B=B+fl
228 NEXT J
238 PRINT "SRflNO TO
TBL'
248 PRINT B
258 NODE 8
289 steps
-180-
3. CAR
This is a race in which a long distance is traveled by turning a steering wheel
to the left and right over a complicated course without hitting fences.
• Program List
-181-
CHAPTER 5 PROGRAM LIBRARY
• Game Explanation
Only the @) and O keys are used. Press the (3) key to move the car to the
left, and press the (s) key to move the car to the right.
T T t
Fence Car Fence
The left and right fences are moved so that the course becomes wider and
narrower. Operate the keys skillfully so that the car does not hit one of the
fences.
When the car hits a fence, it crashes and the distance covered is displayed.
CR RSH i !
sc OR E: 4 51 (Yi
CR RSH i i
C" r OR E: 2 54 km
!_j r* HE OUE : • i
-182-
4. BONBARPMENT GAME
• Program List
18 PRIHT " <SUBNflR 188 IF $='X" THEN X 338 IF K-9 THEN M=8
INE>": =*+!: IF X>9 TH ' IF X=ft(K) THE
28 BEEP : SOSUB 59 EH X=9: GOTO 28 N SOSUB 988
8 ft 348 H=H-1
38 PRINT "HI-SCO:' 198 IF *i*$" THEN I 350 SOTO 188
'V, F U ' r THEN 60 368 NEXT K
48 BEEP = GOSUB 58 SUB 688 378 PRINT
8 298 IF H<K)<8 "HEN 388 IF S>8 THEN R=R
59 y=4:S=!88:R=8:N 368 +8
=H:L=3 219 If RANK,8 THEN 398 PRINT "SCORE:";
iM FOR 1=8 TO 2 388 R>
70 ft(l)= 5HT< RfiNt 228 fl(K)=fl(K)-i 488 IF K R THEN T=R
:
*18):!)(I>= INK 238 IF RflNI>,5 THEN FOR 1=1 T 0 18
RflNI*18) HfK)=fiiK)+2 : BEEP 1: NEXT
88 NEXT I 248 D<K)=0(K)-1 I
% FOR K=8 T 0 2 258 IF R9Nt>,5 THEN 418 IF S<8 THEN 448
188 PRINT n<K>=D<K>+2 428 IF L<1 THEN 448
119 S=S-1 268 IF R(n<8 THEN 438 END
128 IF K<2« THEN RE fi<K5=« 448 SOSUB 588
EP 1 279 IF H < K » H THEN 458 *="fi«f OVER !!
138 IF S<8 THEN 370 R<K)=9 "
140 PRINT 'llilllN 288 IF D(KK8 THEN 460 FOR l=i TQ 12
•IV CSRX?"#"; D<K>=« 478 PRINT *!D*(I,1)
;:
15« IF H<K)=X THEN 298 IF D(K)>9 THEN BEEP 1
PRINT CSRli"**" B(K)=9 488 NEXT I
; 388 IF X=fKD THEN 498 END
168 t- KEY*: IF *=* IF N=8 THEN IF 588 RE?! SUBTIHE
3
THEN 298 RRND.H THEN N= 518 FOR !j=1 TO 198:
178 IF t z ' F THEN X 1:H=*<(C> NEXT U
=X-l: IF X<8 TH 318 IF H=8 THEN 358 528 PRINT
FH x^fl: GOTO 28 328 PRINT ft§Rll;*t" 538 RETURN
8 ;: BEEP *** REM FIRE
-183-
CHAPTER 5 PROGRAM LIBRARY
• Game Explanation
The sea area is as follows.
"—Range of movement-*
Depthofii \\ rr~~
3
4
5
6
7
8
9
To move the destroyer to the left, press the GD key, and to move it to the
right, press the fJD key.
To use a depth bomb to attack a submarine, the depth must be specified
by pressing a key from @ to H I .
-184-
4. BONBARDMENT GAME
There are three destroyers and three enemy submarines; when all three sub-
marines have been destroyed, the game ends and the score is displayed.
Also, when all three destroyers have been sunk first, or when the destroyer
fuel runs out, the game ends.
When the game starts, the title and highest score are displayed.
RUNBB I ~
(or S S ) w i.". c r n : ' " ? .v?'
' T
Destroyer
Range of movement
When you move the destroyer to the left and right with the (XI and QD keys,
the sonar provides a response of the enemy submarine.
Enemy submarine
The submarine is just under the destroyer, but the depth is unknown.
Drop a depth bomb by pressing key from (3) to SI to indicate the presumed
depth. The depth bomb drops with sounds, and when it hits the subma-
rine, it explodes.
. I mMMMTsSMMSm
n H jk HE n
BE li ~--
,__J
When the depth bomb missed the submarine but was close (depth is ±1),
the sonar response changes.
^
A close hit
-185-
CHAPTER 5 PROGRAM LIBRARY
The enemy submarine escapes by moving to the left and right while chang-
ing its depth; follow it without losing it. When the submarine escapes from
just under the destroyer, the sonar response disappears.
s K S B Iff S B if IB B
IBIS SBt* SB? 8tt! S K >!- MS BE tSSl VR
Response disappears
Also, the enemy submarine not only escapes, but sometimes attacks the
destroyer with a torpedo.
• i i i i i i - i i
IBS 9 8 S t Stt Kn H H ™ Bfl MS
When the destroyer is attacked with a torpedo, you must escape at full speed.
However, since the efficiency of an enemy torpedo is high, it still follows
you even if you escape.
s t i l l i l l •''"• If il !
Also, when your fuel becomes low, a continuous beep sound provides a
warning. Since the fuel cannot be resupplied, when it is exhausted, the
game is over. When an enemy submarine is hit, some fuel in this subma-
rine is transferred to the destroyer.
[Scoring]
When a submarine is destroyed, points from 100 to 500 are scored.
Also, an additional score is provided for the remaining fuel.
-186-
5. ATHLETIC GAME
This game consists of three different events as follows.
1. (PO) 100 meter race
2.(P1) Broad jump
3. (P2) Hurdle race
Each program is stored in an independent program area. The 100 meter
race starts first. If a satisfactory result is obtained, the next event begins.
After the hurdle race (last event) is completed, the total score is displayed.
• Program List
P8
18 v=ft:Y=0:H=ft:Z=« 218 IF 9=9 THEN 5=0 129 V=28-H
:K=8:B=188 228 IF »<0 THEN Q=» 138 SOSUB 19: BEEF
28 PRINT "HI-SCO": : HOSUB *6 148 NEXT X
Q:"s": 238 SOSUB 19 158 FOR S=! TO 5
38 V=8: SOSUB #9: 248 IF D*15 THEN #8 168 $= KEV$
BEEP 1 258 PRINT "NEXT RRM 178 IF $iB8" THEN I
48 IF KEY$*"" THEN E ?"" F S="9" THEH 28
SOSUB t?: GOTO 268 IF KEY$="" TflEl 9
38 268 138 NEXT M
58 PRINT CSRX;"fiV 278 SOTO II 198 SOSUB #7: SOTO
CSRll:"!"! 343 steps 48
51 FOR 1=1 TO 5 P, 288 BEEP 1
78 IF KEVt*"" THEN „ m£ ^ 219 FOR J=l TO 88
.fl » ? > 2 28 PRINT iM
™c iHEH
38
98 N S I ™ ™! .238 NEXT J
188 PRINT CSRX:» '; « v=B? GOSMB l< ?** BEEP
Df
119 FOR Tr! TO 5 c„ M_g " 25H R=H/2*6-fl>* CU
128 IF KEV$-*" THEN « grrP , 3 HBS(45-J)/6
2
H=M-.2 79 F0RX=8 TO ii S *» F0R X=8 TO R ST
133 NEXT I rep c" ' • ' EP ,5
148 r - m \ W po ppj N f rRY..n.. 279 PRINT CSRX;"o":
158 IF !NTX*¥ THEN '"'" r ™ H . r . . ' '" 288 ¥=!«: SOSUB *9
BEEP :Y= INTX % *f^*t ' ' M * BEEP 1
168 IF X<8 THEN X=8 m ,p '{L.7, T „r H , 388 NEXT X
178 IF X<1! THEN 58 " ^ j ^ T H E N H= 318 BEEP
:
188 PRINT : REFP ! y , 328 PRINT CSRR:"SV
" F ! &p T W S sn 338 V=S: S0SUB 9
\% [,z RN0(Z/12,-3) M 9 IF $ i V THEN I *
TO 288
F $x»<t« THEN 80 OB 17: SOTO 48
358 IF E<2 THEN GOS
-187-
CHAPTER 5 PROGRAM LIBRARY
188
5- ATHLETIC
• Game Explanation
Start the game by pressing RUN IS or S O D .
100 Meter Race
Runner Goal
The runner turns on and off, press one of the keys while he js displayed
and he advances to the right. If a key is pressed while the runner is turned
off, he retreats to the left.
If the elapsed time (TIME) is within 15 seconds, the broad jump begins.
If a key is pressed before the runner is displayed, a foul occurs ("FOUL!!"
is displayed) which requires a restart. Only one foul is allowed. When two
fouls occur, the game ends.
Broad Jump
"JI"
^ ^ _ j
1
1 '
Jumping
When a jump is not performed even if the take off position has been passed,
or when the jump has failed, a foul occurs ("FOUL!!" is displayed) which
is allowed only once.
If the jump distance is less than seven meters, you are disqualified and cannot
advance to the hurdle race.
-189-
CHAPTER 5 PROGRAM LIBRARY
Hurdle race
~i r r
Runner Hurdle
To make the runner run, keep pressing an alphabetical key. When the run-
ner reaches a hurdle, press a numerical key with good timing to jump.
Jump
Goal
• Keys Used
Keys other thanBB,GE),(§D, @, S,EB,S,dloE),lffl, and S can be used for
the 100 meter race.
When a runner is running, any alphabetical key from S t o B e a n be used
for the broad jump and hurdle race, while any numerical key from E) to
PS) can be used when a jump is made.
-190-
CHAPTER 6
REFERENCE
fH%;:f
6-1. ERROR MESSAGE TABLE
Error
code Meaning Cause Corrective measure
-192-
6-1. ERROR MESSAGE TABLE
Error
code Meaning Cause Corn -,ure
-193
6-3. I LS
Symbol Meaning
r
(
> Entry or exit point
(start, return, end, etc.)
)
C )
< Output function
General processing
Processing in a subroutine
o -194-
Test (condition)
6-3. FLOWCHART SYMBOLS
Symbol Meaning
1
Output to a prfnter
_ ^
Flowline
-195-
6-4. ARRAY VARIABLE TABLE
A B C D E F G L M N 0 P Q R S T U V w X Y Z
H I J K
A 0 1 2 3 4 5 6 7 8 9
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
10
B - 0 1 2 3 4 5 6 7 8
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
9
C - - 0 1 2 3 4 5 6 7
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
8
D - - - 0 1 2 3 4 5 6
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
7
E - - - - 0 1 2 3 4
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
5 6
F 0 1 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
2 3 4 5
G 0 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
1 2 3 4
H 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
0 1 2 3
I 0 1 2
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
J 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
0 1
K 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0
L 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
M 0 1 2 3 4 5 6 7 8 9 10 11 12 13
N 0 1 2 3 4 5 6 7 8 9 10 11 12
0 0 1 2 3 4 5 6 7 8 9 10 11
P 0 1 2 3 4 5 6 7 8 9 10
Q 0 1 2 3 4 5 6 7 8 9
R 0 1 2 3 4 5 6 7 8
S 0 1 2 3 4 5 6 7
T 0 1 2 3 4 5 6
U 0 1 2 3 4 5
V 0 1 2 3 4
w 0 1 2 3
X 0 1 2
Y 0 1
z 0
A B c D E F G H 1 J K L M N 0 P Q R S T u V W X Y z
-196-
COMMAND/FUNCTION INDEX
ABS 44 158 MID$ 104, 152
ACS 41 156 MODE 149
ASN 41 156 NEW(ALL) 125
ATN 41 156 NEW# 162
BEEP 96 147 ON-GOSUB 102, 142
CLEAR 131 ON-GOTO 102, 138
COS 42 155 PASS 128
CSR 106 136 PRINT 52, 72, 135
DATA 98 143 PUT 115, 146
DEFM 95 148 RAN# 44, 160
DEG 45 160 READ 98, 144
DMS$ 46 161 READ# 164
END 132 REM 133
EXP 43 157 RESTORE 98, 145
FOR-TO-STEP/NEXT 81 140 RESTORE* 165
FRAC 44 159 RETURN 85, 142
GET 115 146 RND 44, 159
GOSUB 85 141 RUN 6 1 , 126
GOTO 70 137 SAVE(ALL) 112, 129
IF-THEN 74 139 SAVE# 114, 163
INPUT 52 133 SET 45, 150
INT 44 158 SGN 44, 158
KEY$ 106 134 SIN 42, 155
LEN 104 151 SQR 43, 157
LET 50 132 STOP 67, 132
LIST 127 STR$ 104, 154
LIST# 162 TAN 42, 155
LN 43, 156 VAL 104, 153
LOAD(ALL) 112, 130 VERIFY 131
LOAD# 114, 163 WRITE# 167
LOG '. 43, 156
-197-
SP IMS
• Type
PB-410/FX-720P/FX-820P
• Fundamental calculation functions
Negative numbers, exponents, parenthetical addition, subtraction, multiplica-
tion and division (with priority sequence judgement function (true algebraic
logic))
• Built-in functions
Trigonometric/inverse trigonometric functions (angular units — degree/radi-
an/grade), logarithmic/exponential functions, square roots, powers, conversion
to integer, deletion of integer portion, absolute value, symbolization, designa-
tion of number of significant digits, designation of number of decimal digits,
random numbers, x, decimal <-• sexagesimal conversion.
• Commands
INPUT, PRINT, GOTO, ON-GOTO, FOR-NEXT, IF-THEN, GOSUB, ON-GOSUB,
RETURN, READ, DATA, RESTORE, STOP, END, REM, LET, BEEP, PASS, RUN, LIST,
LIST ALL, MODE, SET, CLEAR, NEW, NEW ALL, DEFM, SAVE, SAVE ALL, LOAD,
LOAD ALL, PUT, GET, VERIFY, NEW#, LIST#, LOAD#, SAVE#, READ#,
WRITE #, RESTORE #.
• Program functions
KEY$, CSR, LEN, MID$, VAL, STR$
• Calculation range
± 1 x 1 0 " " t o ±9.999999999 x 10 99 and 0 (internal calculations use 12-digit
mantissa)
• Program system
Stored system using a RAM card
• Program language
BASIC
• RAM capacity
RC-2 — 2K bytes
RC-4 — 4K bytes
(including 272 bytes of system area and 208 bytes of fixed variable area)
• Program capacity
Maximum 10 programs (P0 through P9)
• Number of variables
Minimum 26 variables and exclusive character variable ($)
• Nesting
Subroutine — 8 levels
FOR-NEXT loop — 4 levels
Numerical value — 6 levels
Operators — 12 levels
• Display system and contents
10-digit mantissa (including minus sign) or 8-digit mantissa (7 digits for nega-
tive number) and 2-digit exponent.
-198-
SPECIFICATIONS
• Display elements
12-digit dot matrix display (liquid crystal)
• Main components
C-MOS VLSI and others
• Power supply
Mainframe — 2 lithium batteries (CR2032)
RAM card — 1 lithium battery (CR2016)
Built-in character printer (Only provided for FX-820P) — Built-in recharge-
able Ni-Cd battery.
• Power consumption
Mainframe — Maximum 0.03 W
Built-in character printer (Only provided for FX-820P) — Maximum 4 W
• Battery life (Continuous use)
Mainframe only (PB-410/FX-720P) — approximately 140 hours
(FX-820P) — approximately 90 hours
With option connected (PB-410/FX-720P) — approximately 70 hours
(FX-820P) — approximately 80 hours
RAM card (when stored separately from the mainframe)
RC-2 — approximately 2 years
RC-4 — approximately 1 year
Built-in character printer (Only provided for FX-820P) —
With a fully charged battery it prints approximately 3000 lines of
"5555555555" continuously.
• Auto power-off
Power is turned off automatically approximately 6 minutes after last operation.
• Ambient temperature range
0°C to 40°C (32°F to 104°F)
• Dimensions and weights
PB-410/FX-720P — 14.3mmH x 165mmW x 82mmD, 177g (Vi6"H x 6V2"W x
3V4"D, 6.2 oz) including batteries and a RAM card.
FX-820P — 26mmH x 173mmW x 95mmD, 335g (1"H x 63/4"W x 33/4"D,
11.8oz) including batteries and a RAM card.
RAM card — 3.8mmH x 60mmW x 50mmD, 17g (5/32"H x 2 3 / 8 "W x 2"D, 0.6 oz)
including the battery.
-199-
c AS5IC
^F®