Casio FX 720p Owners Manual

Download as pdf or txt
Download as pdf or txt
You are on page 1of 201

Personal Computer

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

CHAPTER 2 LET'S OPERATE


2-1 LET'S OPERATE THE COMPUTER 34
2-2 CONVENIENT DATA BANK FUNCTION 38
2-3 SIMPLE CALCULATION, AT THE BEGINNING 39
2-4 FUNCTION CALCULATION — A HIGHLIGHT OF
THIS COMPUTER 41

CHAPTER 3 "BASIC" PROGRAMMING


3-1 WHAT IS A PROGRAM? 48
3-2 PROGRAM PREPARATION 51
3-3 PROGRAM DEVELOPMENT 70
3-4 CONVENIENT OPTIONAL EQUIPMENTS 111
3-5 USING A PB-100 PROGRAM 118

CHAPTER 4 COMMAND REFERENCE


NEW [ ALL ] 125
RUN 126
LIST 127
PASS 128
CONTENTS

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

DATA BANK COMMANDS 162


NEW # 162
LIST # 162
SAVE # 163
LOAD # 163
READ # 164
RESTORE # 165
WRITE # 167
CONTENTS

CHAPTER 5 PROGRAM LIBRARY


1. STATISTICAL CALCULATION 170
2. CROSS TOTAL 176
3. CAR RACE GAME 181
4. BONBARDMENT GAME 183
5. ATHLETIC GAME 187

CHAPTER 6 REFERENCE MATERIAL


6-1 ERROR MESSAGE TABLE 192
6-2 CHARACTER CODE TABLE 193
6-3 FLOWCHART SYMBOLS 194
6-4 ARRAY VARIABLE TABLE 196

COMMAND/FUNCTION INDEX 197


SPECIFICATIONS 198

i
CHA

GENERAL GUIDE

Users who have not used a computer as well


as those who are accustomed to a computer
should read this chapter.
1-1. NOMENCLATURE AND OPERATION
<PB-410>
. • . . . .

• |

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>


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.

Since many additional keys are provided compared to an ordinary calcula-


tor, the key functions might be unclear. Therefore each key and operation
are explained.

• 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.

• Shift key (Red (3 key)


If this key is pressed, the shift mode is selected (" m " is displayed) and
the command or symbol printed above each key can be displayed. When
it is pressed again, the shift mode is released and " U3 " disappears. (To
distinguish this key from the alphabetical GO key, it will be written as
S from now on in this manual.)

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.)

• Numeral keys, decimal point key, calculation keys,


and execution key
Examine this key array carefully. It is the same as that Q
of an ordinary calculator. This part is used when the
four arithmetic calculations (addition, subtraction, CZIESIISQ
multiplication, division) are performed. However, the fHlfslfBlM
following differences exist. The • (multiplication) — — —'™
and B (division) keys are different and there is no mrg]|C3
0 key while there is an 633 (execution) key. This oc-
curs because a computer uses an * (asterisk) for x OdDSE!
and / (slash) for +, while the answer is obtained by
the US key instead of the B key.
-13-
CHAPTER 1 GENERAL GUIDE

For example, an operation is performed by an ordinary calculator as


12 0 4 8 3 0 7 0 5 5 while this computer uses 12 D 4 B 3 D
7 O 5 E9 •
This computer can be used as an ordinary calcula- CZD
tor as shown above. When followed by the @ key, P7 P8 P9
one of the numeral keys ( El to ED ) can be used to
specify a program area from P0 to P9 while P4 PS P6 -==

the GD key is used for power calculation (xy->x1y)


PI P2 P3
and the 0 0 0 0 keys are used to enter rela-
tional operators ( g , g , > , < ) .
c=^c=)ClxE]
• Alphabetical keys, space key

(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)
»» $ (

GOSUB RETURN GOTO FOR TO NEXT IF THEN LIST


CZD CZD CZD CZD CZD CZD CZD CZD CZZ
PRINT INPUT CLEAR DEFM LOAD SAVE RUN 71 A N S
( 1 i 1 I 1 i 1 I 1 t 1 I 1 r 1 I 1

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.

Extension mode functions:

(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• -

CZD ( = 3 CZD CZD CZD CZD CZD CZD CZD ANS


O D A X ^ • » • * I 1

CZD I I I II II I CZD CZD fJ^TTl . =*= , n


• • X n * [SPC| CZD CZD

(FX-820P)
CZD CZD CZD CZD CZD CZD CZD CZD CZD CZD
% . @ v ( ) 8. - i

CZD CZD CZD CZD CZD CZD CZD CZD CZD


O C I A X ^ « » « +

CZD CZD CZD CZD CZD CZD CZD *r *NS


• x n M CZD ( )

To release the extension mode, press B ED again.

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${< '

<=:> CZD CZD CZD CZD CZD CZD |=^q r = 1 n F l


VAL( STR»| LEN| M I D $ | DATA READffiSTOHfP " * ! I ] L5LJ

(FX-820P)

SIN COS TAN ASN ACS ATN LOG LN EXP SQR

ABS INT FRAC SGN RANO CSR RNDI DEGI DMS$(

CZD CZD CZD CZD CZD CZD CZD fED fi


VAL| STR$( LENI MID$I DATA READ RESTORE L E J l—

In the extension mode, capital alphabetical characters are displayed.

-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.

• Exponent/Pi key ( cf, )


When this key is directly pressed, it is used to provide an exponent. For
example, ope rate CD H O ESS) (IS for 1.23 X 104. When an exponent is
a negative number, press the B key after this key. For example, oper-
ate m Q a mm a s for 7.41 x 1 0 - 9 .
When this key is pressed after the S key, Pi (the ratio of the circumfer-
ence of a circle to its diameter) is displayed.

• Answer key ( ££?)


When this key is pressed after the S key, the result of manual or pro-
gram calculation executed immediately before 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

SO "PRT" is displayed for the performance of printing when a printer


is connected.
SO When "PRT" is displayed, print mode is released and "PRT" dis-
appears.
B® " S Q E " is displayed to indicate input mode for the Data Bank
function (see page 38). To release this mode, press BSE).

• 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.

• All clear key ( Q3 )


This key erases any display. Also, it is pressed when an error occurs, or
when the display blanks out by auto power off (see page 21). When a
program is being executed, program execution is suspended by press-
ing this key.

• 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.

• Stop key ((HE))


When this key is pressed during program execution, it is temporarily
stopped. To resume it, press the S3 key.

• Paper feed key ( H : Only provided for the FX-820P)


Press to advance the roll-paper.

-18-
1-1. NOMENCLATURE AND OPERATION

Display contrast control


When the display is dark or faint, depending on the battery condition
or display view angle, adjust it by moving the control located on the
left side of the computer.
(PB-410/FX-720P)

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

© Turn off the power and remove the screws


on the back, then remove the back panel.
(Use a precision screwdriver.)

All reset button

( After battery replacement^


press this using a pointed)
object. /

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

© Remove the two old batteries. (They can


be easily removed by lightly hitting the bat- (PB-410/FX-720P)
tery compartment while facing it down-
ward.) 1
© Wipe the surface of the new batteries with
a dry cloth and insert them with the plus
E
terminals on top. Precautions should be
taken so that a mistake is not made con-
cerning the plus and minus terminals. (FX-820P)

© PB-410/FX-720P:
Replace the battery holding panel.
FX-820P:
Replace the battery compartment lid.
Screw carefully.

© Replace the back panel. Screw carefully.


* Do not throw the exhausted batteries into
a fire because an explosion might occur.

Please keep the batteries in a location out of the reach of children. If they are
swallowed, contact a doctor immediately.

• Auto power off


The auto power off function prevents wasted power consumption when
you forget to turn off the power switch. The power automatically turns off
about 6 minutes after the last key operation (excluding program calculation).
In this case, the power is turned on again by turning the power switch off
and then on, or by pressing the B3 key.
* Although the memory contents are not erased when the power is turned off,
the angle and mode specifications ("RAD", "WRT", "TR", "PRT", etc.) are
released.

-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

• How to load the paper roll Fig. 1


1) Turn on the power switch.
2) Open the printer cover as illus-
trated (Fig. 1).
3) Hold the paper roll with the
leading end of the paper at the
bottom.
4) Insert the leading end of the
paper roll into the feed slot (Fig.
2) and keep pressing the ( H key
Fig. 2
until the leading end of the
paper comes out the other side
of the printer (Fig. 3).
5) Load the paper roll into the
compartment and replace the
printer cover.
Feed slot

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

Do not touch the connector surface.


Slide the metal tabs on both sides in the direction of the arrow, then
the connector surface is exposed. If the connector surface is touched
by fingers or a metallic substance, sometimes a RAM card cannot be
used. After it is removed from the mainframe, always close the connec-
tor cover.
If strong static electricity is applied to the RAM card; sometimes the stored
content may be changed or key input cannot be performed. If this oc-
curs, remove the RAM card battery, then reinsert it. (In this case, the
stored content is erased.)
-24-
1-4. RAM CARD

Do not disassemble a RAM card or apply force to it such as twisting


or bending.
When a RAM card is removed from the mainframe, place it in the case
and store it in a location that is not dusty and is not exposed to direct
sunshine.
A lithium battery is built in the RAM card to protect the memory. If it
is removed, the stored content is erased. Before replacing the battery,
the content of the card should be stored on a cassette tape, then load
this content to the RAM card again after battery replacement is com-
pleted (see page 111).
Do not remove the insulating paper since it protects the connector sur-
face of the mainframe when the RAM card is installed upside down by
mistake.
Be sure that a battery is inserted in the RAM card.
RAM cards should not be used for units other than CASIO's RAM card
computer models.

USING THE PB-410/FX-720P


• RAM card removal/installation

© T u r n the computer power switch


OFF. Turn over the computer and
slide the lock switch to the right.

©Slide the RAM card compartment


lid off in the direction of the arrow
while gently pressing the °^N tab.

-25-
CHAPTER 1 GENERAL GUIDE

© Remove the RAM card.

© Close the connector cover of the


RAM card by sliding the metal tabs
on both sides.

© T o install the RAM card, open the


connector cover of the RAM card
and place the RAM card with its
connector facing the computer
connector.

©Replace the RAM card compart-


ment lid and slide the lock switch
to the left.

USING THE FX-820P


• RAM card installation
©Turn the mainframe power switch
off.
©Slide the lock switch to the left.
(This also turns ot.' the mainframe
power supply.)
Note) If the card holder is pulled by
force without sliding the lock Lock switch
switch, the lock switch will be
broken.
1-4. RAM CARD

(3)Pull the card holder slightly by


pressing its projection lightly
downward.
Note) Since the card holder can only
be pulled up to the middle, if
force is applied, it will be
broken.

(4) Insert the RAM card into the card


holder with the connector surface
on top, and with the connector
cover closed.

\
\
(5) Press the card holder projection
slightly downward so that the RAM
card is horizontal, and insert it in
the card holder completely.

©Insert the card holder in the direc-


tion of the arrow until it clicks and
stops completely while slightly
pushing it upward.

®Slide the lock switch to the right.

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

• RAM card removal


© Turn the mainframe power switch
off.

© S l i d e the lock switch to the left.

Lock switch

Pull the card holder out lightly


while pressing its projection
downward.

Projection

® Pull the RAM card out by holding


both edges while pressing the card
holder projection slightly down-
ward. Precautions shall be taken
not to touch the connector sur-
face.

(D Since the connector surface of the


removed RAM card is exposed,
close its cover by sliding it.

Note) When a RAM card is not used, store it in its case.


When another RAM card is installed by replacing a previous one, please
refer to the "RAM card installation" ( ® — ®).

28
1-4. RAM CARD

• RAM card battery replacement


A RAM card utilizes one lithium battery (CR2016) as a memory protection
power supply. If a RAM card is kept out of the computer, the battery life
of RC-4 is about 1 year while that for the RC-2 is about 2 years. When uti-
lized by installation in the computer, the battery life of the RC-4 is prolonged
because it is backed up by the main power supply. However, since leakage
might occur if the battery is used for more than 2 years, it should be replaced
with a new one within 2 years.
* As a battery was installed in the attached RC-2 RAM card at the factory, it
might be exhausted before the prescribed battery life is attained.

* RAM card battery replacement


Since trouble might occur if the connector surface is touched, replace the
battery with the connector cover closed.

© Remove the screw of the battery


compartment lid on the back, then
remove the lid by slightly sliding
it in the direction of the arrow, and
Close the
remove the old battery. connector cover.

Screw

© Insert a new battery with the plus


terminal on top after wiping it with
a dry cloth, then replace the bat-
tery compartment lid. Screw care-
fully. Precautions should be taken
so that the plus and minus termi-
nals are not mistakenly reversed.
* Do not throw an exhausted battery
into a fire because an explosion
might occur.

Please keep batteries at a location out of the reach of children. If a battery is


swallowed, contact a doctor immediately.

-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.

• User's area and system area


The capacity of the RC-2 RAM card is 2048 bytes while that of the RC-4
RAM card is 4096 bytes. This capacity can be roughly divided into three
areas which are:
1. A system area that manages programs and variables,
2 .A fixed variable area that is utilized for variables from A to Z, and
3. A free area (user's area) that is used for programs and the Data Bank.

RAM catd System area Fixed variable area Free area


RC-2 272 bytes 208 bytes 1568 bytes
RC-4 272 bytes 208 bytes 3616 bytes

-30-
1-5. BEFORE CALCULATING

• Calculation priority sequence


Calculations have "priority sequence" rules in which multiplication and
division are performed prior to addition and subtraction. This computer
is provided with a function that automatically distinguishes the priority se-
quence. This function is so convenient that a correct answer can be ob-
tained by entering a calculation expression as it is.
The calculation priority sequence is determined as follows.

©Functions (SIN, COS, etc.)


©Power (-T )
(3>x(*)(, - ( / )
(D+s -

Although calculation is performed according to this priority sequence, if


two operations have the same priority, the left one has priority. If paren-
theses are used, operations inside parentheses have priority.

Example) 2 + 3 * S I N (17+13) t2 = 2.75


1
CD '
I (D 1

-31-
CHAPTER 1 GENERAL GUIDE

• Input/output number of digits and operation number of digits


The number of input digits are 12 digits for a mantissa and 2 digits for an
exponent. Internal operations are also performed using 12 digits for a man-
tissa and 2 digits for an exponent.
Although the number of output digits is usually 10 digits for an mantissa,
it differs depending on a displayed result of a manual calculation and that
of a program calculation. In the manual calculation, the result is displayed
up to 12 digits including mantissa, exponent and minus sign. While in the
program calculation, 10 digit mantissa and 2 digit exponent are displayed.
However, if 12 digits are exceeded, 12 digits from the beginning are dis-
played first, then the rest is displayed sequentially by shifting the display
to the left.

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

You should operate this computer to become


accustomed to if because it won't break even
••.••• • • " . • • ' •••••• '

ation in accordance with the proverb "Practice


makes perfect."
2-1. LETS OPERATE THE COMPUTER
Learn how to operate the computer by actually using it.
To start, hold the computer and turn the power on by sliding the power
switch to the right. Then the following is displayed.

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

Let's actually operate the computer to understand the display.


If a message stays displayed after using the corresponding mode, turn the
power switch off and then turn it on again.
Start with a simple calculation.
Example) 1 2 3 + 4 5 6 = 5 7 9

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

Next, try another calculation.

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.

When a mistake was found in the middle as mentioned above, it can be


easily corrected by using the cursor keys.
However, if the (31 key has been pressed, reenter the calculation expression
from the beginning.
-35-
CHAPTER 2 LET'S OPERATE

Now, let's enter characters by using the alphabet keys.


The array of the alphabet keys is the same as that of a QWERTY typewriter.
Most personal computers now have QWERTY type array keyboards; remem-
ber the location of the characters even though it may not be easy for a be-
ginner to do this.

Enter characters first.


Example) The characters used are "ABCXYZ".
Enter ABC.
SEE) A SC-
Enter XYZ next.
S E E AB DX' ;.... .....
Now put a space between ABC and XYZ.
Place the cursor on X.
. .„.,
e B H FiBC^
Make one character space.
@HB> ABC.....;: i 1 li

When a space is to be inserted between characters, place the cursor at the


location where it is to be inserted, then press H d .
When additional spaces are to be inserted, repeat this procedure.

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.)

Let's practice displaying some of these characters.


Example) Display £>£><><£> marks.
Specify the extension mode. -Displayed

For these marks, press alphabet keys after pressing the S keys.

36-
2-1. LET'S OPERATE THE COMPUTER

Example) Display 2 , fi , M symbols.


Since the extension mode is used, just perform the following operations.

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 2) 56X ( - 1 2 ) + < - 2 . 5 ) = 2 6 8 . 8


Operation) 5 6 D B 1 2 D B 2 . 5 SO 2 6!:
* To enter a negative number, press the O key before a number.

Example 3) 7 x 8 - 4 x 5 = 3 6
Operation) 708040503 • '•> b

* Multiplication is performed first, then subtraction is performed.

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 =

When the value of x is 123.456 in these calculations, it is troublesome to


press the same numerical value repeatedly. Is there any way to perform these
calculations without this trouble? The solution is to use a memory called
a variable. In these examples, since x is used for algebraic calculations,
the calculations are performed by using variable X.

-39-
CHAPTER 2 LET'S OPERATE

First, assign 123.456 to variable X.


S O 123.456531
" Q " does not mean equal but means that 123.456 is assigned to variable X.
Let's perform these calculations.

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.

Since this computer is provided with 26 variables from A to Z, many different


numerical values can be memorized.
In these examples, the numerical value for variable X is fixed and the cal-
culation expressions are different.
However, how about a case in which the calculation expressions are fixed
and the values of the variables are different?
When a calculation expression is determined to be "3x + 5 = " and the
value of x is changed to 123, 456, and 789, the operation is troublesome
if the procedure mentioned above is used. Actually, the calculation expres-
sion is memorized by the computer and it is only necessary to change the
value of variable X. This convenient calculation method is called "program
calculation". A strong point of this computer is program calculation. Manual
calculation, a previous step in which a program is used, is performed here.
See Chapter 3 "BASIC" PROGRAMMING for a Program.

-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

* For DMS $, DEG, and RND, the argument must be inside ( ).

Perform calculations with functions.

41
CHAPTER 2 LETS OPERATE

• Trigonometric functions (sin, cos, tan), and inverse trigonometric


functions (sin 1 , c o s 1 , t a n 1 )
When trigonometric functions and inverse trigonometric functions are
used, always be sure to specify the angle unit (DEG, RAD, CRA).

Example) sin 12.3456°=0.2138079201


Operation) OS)-.-* D E G "
E m ® 1 2 . 3 4 5 6 E3 3887920!
* From now on, alphabet keys are shown without frames.
* Using the FX-720P and FX-820P, the same result can be obtained by pressing
e S 12.3456 6S .

Example) cos 63°52'41"=0.4402830847


Operation) COS D E G S c b 6 3 ( I ] 5 2 ( Z I 4 1 ScbB
a.44U283H84 7
Example) 2 • sin45° X cos65.1° =0.5954345575
Operation) 2 D S IN 4 5 Q C O S 6 5 . 1 BE •3 . j y -J H- •„:> 4 j J i

Example) sin-'0.5=30°
Operation) ASN 0 . 5 B

Example) cos(frad) =0.5


Operation) B(5]->* RAD"
COSBc=S[fJB3Bc

Example) cos •=0.7853981634rad


Operation) A C S B c b S Q R 2 D 2 B i 0» 7 8 5 3 9 8 1 6 3 4

Example) tan(-35gra) = -0.612800788


Operation) •!(&->•* GRA*
TANQ35SB 0.612800788

42-
2-4. FUNCTION CALCULATION — A HIGHLIGHT OF THIS COMPUTER

• Logarithmic functions (log, In), and exponential functions (ex, xy).


Example) log 1.23( = logl01.23) =0.0899051114
Operation) LOG 1.2 3 SB S.0 8 99051114
Example) In 90( = logf 90) =4.49980967
Operation) LN90EB 4 . 4 9 9 88 9 67

Example) e5=148.4131591
Operation) E X P 5 SB 148.4131591

Example) 10' "=16.98243652


(The anti-logarithm of common logarithm 1.23 is obtained.)
Operation) 10 g A 1.2 3 SB 16. 9:3243

Example) 5.62 3 = 52.58143837


Operation) 5 . 6 H c b 2 . 3 SB •J i . 3143 8 3 7
Example) 123i ( = VTZ3) = 1.988647795
Operation) 1 2 3 S c b S c b 1 Q 7 HcbB 1. 9 l"! 1
3647 795
* When x < 0 , y is a natural number.

Example) log sm40° + log cos35° =-0.278567983


The anti-logarithm is 0.5265407845 (logarithmic calculation of
sin 40° x cos 35°).

Operation) CB@]^ X V DEG"


L O G S I N 4 0 S 3 L O G COS 35E -U.2785b<ya
8 . 5 2 65 487 84!

• Other functions (V", S G N , R A N # , R N D , A B S , INT, FRAC)

Example) /!+/5=3.65028154
Operation) SQR 2 S 3 S Q R 5SB 3.65028154
43
CHAPTER 2 LET'S OPERATE

Example) Gives "1" if it is a positive number, " - 1 " if it is a negative number,


and 0 if it is "0".
Operation) SGN 6 SB i
SGN 0HB
SGNQ2EB

Example) Random number generation (Pseudo random numbers with the


range of 0 < RAN # < 1).
Operation) RAN BC=DSD y . 7 y y 3 73yy7b

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.

Example) 1-78.9-^5.61 = 14.08928571


Operation) A B S B c b O 7 8 . 9 D 5.6BcbEB 1 4 . 6 8 9 : .,..............
:, o j ! 1

Example) Integer of 7800/96 81


Operation) I N T B i 7 8 0 0 O 96BcblHl 81
* The maximum integer that does not exceed the original numerical
value is obtained by this function.

Example) The fraction of 7800/96 0.25

Operation) F R A C B 6 7 8 0 0 H 96BcbSl

-44-
i
2-4. FUNCTION CALCULATION — A HIGHLIGHT OF THIS COMPUTER

• Designation of number of significant positions, and designation of


number of decimal positions.
The number of positions are designated by the "SET" command.
Designation of number of significant positions SET E n ( n = 0 t o 8 )
Designation of number of decimal positions SET F n ( n = 0 t o 9 )
Cancellation of designations of number of positions ... SET N

In a manual calculation, "SET E0" designates an 8 significant positions.


Even if a designation is performed, the original numerical value remains
in the memory.

Example) 10(R6 = 16.66666666


Operation) SET E4EJ (Designation of 4 significant positions.)
100Q6EB I i „ h6 7 E 8

Example) 123-^7 = 17.57142857


Operation) S E T F 2 E3 (Designation of 2 decimal positions)
123Q7IBJ i''. b I

Example) 1 ~ 3=0.3333333333
Operation) S E T NEB (Designation cancellation)
..T „ T .„,. „.,. „.r ...,. ...,.
1 B 3 1

• Decimal *-> sexagesimal conversion (DEG, DMS $)

Example) 147536"=14.42666667
Operation) DEGHc=. 14CD25[U36SdDl2i
i 4 « 4Zbbbbb

45
CHAPTER 2 LET'S OPERATE

Example) 12.3456° = 12°20'44.16"


Operation) D M S e ^ B c b 1 2 . 3 4 5 6 gcbG •! V" ->iA- A

Example) sin 63°52'41"=0.897859012


Operation) B@]
SIN DEGec=363[I]52CI]4ie[iDE

46
3
CHAPTER
"BASIC"
PROGRAMMING

In this chapter, BASIC programs and program-


ming are explained. Users who are not ac-
customed to programming should read this
• . . • • • •
3-1. \ IS A F
The word "PROGRAM" may sound like something difficult. However, there
are very simple programs and more complicated ones. For example, calcu-
lation, in which algebraic expressions are memorized and numerical values
are assigned to these expressions, is also a program.

3-1-1 A Program Is Convenient.


We are concerned with many different kinds of calculations such as those
for financial business accounting, measurements, or for housekeeping and
expenses. Although it is not so troublesome if these calculations are per-
formed only once, it is tedious to perform calculations repeatedly with the
same calculation expression while changing numerical values. Because of
this, these calculations can be best performed by using your computer. For
example, if the calculation expression y=2x2 +5x+~\3 is used, to obtain the
value of j when the value of x is changed, the same calculation must be
repeated. To eliminate this trouble, the following expression is placed in
memory.

10 INPUT X
20 Y = 2 * X t 2 + 5 * X + 1 3
30 PRINT Y

In this program a calculation expression is memorized. A detailed expla-


nation will be provided later. This program allows the calculation to be
easily performed.
Simple programs can be conveniently used just by memorizing a calcula-
tion expression as mentioned above.
Next, the program will be sequentially explained.

3-1-2 Program Construction


Remember program construction.

10 INPUT X
20 Y = 2 * X t 2 + 5 * X + 1 3
3 0 PRINT Y

-48-
3-1. WHAT IS A PROGRAM?

This program can be divided into 3 parts as follows.

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

In the following line,


20 Y=2*Xt2+5*X+13
Line No. Assignment statement

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

LET is a command and the assignment statement is an operand.


Line 30 consists of a line number, command, and an operand the same
as line 10.
30 PRINT Y
Line No. Command Operand

Program construction is as mentioned above. Additional commands, oper-


ands, and line numbers are used to construct a large program.

3-1-3 Easy Program Preparation


When program construction is understood, it is not so difficult to prepare
a program.
After the three main parts (input, calculation, and output) are understood,
they can be used to prepare a program. It is unnecessary to remember all
the commands at one time. It is advisable to try simple calculation by just
using "INPUT", "PRINT", and an assignment statement.
The secret of quick program mastery is not to just remember a program,
but to actually prepare a program by selecting a problem that can be easi-
ly placed into a calculation expression from among those around you such
as the calculation of bills or financial calculation repeatedly performed in
a company, measurements, housekeeping and time calculation for cassette
recording often performed at home. The best way to master programming
is to first prepare a program for the subject to process, memorize the re-
quired commands, then improve the program.
Another secret is not to prepare the entire program at one time but to pre-
pare its different parts and put them together later.
Prepare a program gradually and slowly by using this concept. After fun-
damental program construction has been understood, a program can be
prepared by referring to each command function in the "CHAPTER 4 COM-
M A N D REFERENCE" and by actually using them.

-50-
3-2. PROGRAM PREPARATION

This section and after cover the main subject, BASIC Programming, in which
a program is actually prepared.

3-2-1 Preparing A Flowchart


You may not be accustomed to a flowchart. It is a chart which describes
a work sequence.
It is often heard that a flowchart is not required for BASIC; this is correct
for a user who is accustomed to utilizing a computer. However, since the
entire work procedure is hard to understand for a beginner, it is important
to draw a simple flowchart to understand the program flow.
While there are formal and dedicated symbols for drawing flowcharts, it
is unnecessary to remember these symbols. Just place each work item in-
side | land connect them with lines.
Let's prepare a program to explain each item.
For example, make a program to obtain the square of a numeral by enter-
ing it. First, a calculation part is required. Since a numeral is entered, an
input part is necessary, and since an answer is displayed, an output part
is necessary. The three parts are placed inside I las follows.

Calculation Data input Display

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.

(1) Data input

(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.

INPUT A ••• Indicates input

B=AT2 Indicates processing

PRINT B Indicates output

Refer to the flowchart symbol at the end of this manual

52
3-2. PROGRAM PREPARATION

3-2-2 Preparing A Program


To provide a simple example, enter 2 numerical values and obtain their
sum, difference, product, and quotient.
Prepare a flowchart based on the input, calculation, and output parts which
are the three important items.

Enter 2 numerical
values.

Obtain their sum,


difference, product,
and quotient.

/ 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.

First, For addition of A+B, C=A+B is used.


For subtraction of A - B , D = A - B is used.
For multiplication of A * B , E = A * B is used.
For division of A/B, F=A/B is used.

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

The program format can be placed in a flowchart as follows.

INPUT A,B

c==A+B
D==A-B
E==A*B
F==A/B

PRINT N
C.D.E.Fy 1

Complete the program by placing line numbers.


10 INPUT A,B
20 C=A+B
30 D=A-B
40 E=A*B
50 F=A/B
60 PRINT C.D.E.F
Next add "END" to indicate program termination.

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

125 -789 458

/
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.

Numerical variables Character variables


The numerical value The characters
f is entered. > are entered. „
123 741 ABC CASIO PB&FX
f r r
/ / / / / /
B C$ Z$<5)
/ / /

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

< Precautions when using variables >


If a numerical variable has the same name as a character variable when
a program is used, data will be entered into the same place.

/ ' A character or numerical value is entered.

A*

As a result, the numerical variable A and the character variable A$ cannot


be used simultaneously in the same program.
Also, when an array variable is used (see page 92) precautions must be
taken so as not to give several equivalent names to one container.

H(6)
A( 1 3 ) / /
N N
A$(13) N(0)

All names are for the same container.

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)

N=A(13)=B(12)= =N(0)=N$=A$< 1 3 ) = N$(0)

Z=A(25)=B(24)=C(23)= =Z$=A$(25)= Z$(0)


Same precautions must be taken when memory is expanded by a DEFM statement.

3-2-3 Program Input


Memorize (input) a program.
Use the previous program in which four basic calculations are performed
after entering two numerical values.

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.

WRT mode indication 1 i Number of remaining steps


EG
WRT° I5 6 S
n ft i -i T .i cr .•- -? r-. n
r tf1 •£•_•'4-J b i o :

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

NEW ALL 633

This is a command that erases all programs. Store a program with the fol-
lowing procedure.

-57-
CHAPTER 3 "BASIC" PROGRAMMING

HIB'SaHB Press this key at the end of each line.


' This operation can also be performed by pressing CDBBEKB.
d K D t S B E O E l SB
H i B H S a S HI

(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.

• A mistake was noticed before the 133 key was pressed.


If this occurs, place the cursor at the location where the mistake occurred
by using the E l (D keys and correct it.
Example 1) | y INF LIT S_. "S" was pressed instead of "A".
Place the cursor under the "S" by pressing t ie HD key once.
0 1 0 I HPUT £
Press the correct key.
E 10 INPUT P....
Complete the en iry then press the 133 key.
QB US 10 INPUT fi,B
:: An extra "E" was entered.
Example 2) 4 0 EE 'fl*B
Press the GE) key 5 times and place the curse)r under the second "E".
[EHJS0S 4 0 E E:::- Fi + B
Since 1 characte ' is to be deleted, press the Ht) key once.
& | 4 i,i j~ = fl * B
After the deletior is made, press th e 133 key.
4 j,i L =H * B

58
3-2. PROGRAM PREPARATION

Example 3)[ R I H T C? ? E.- F..... 1 " D " on line 60 was skipped.


Press the {§} key 4 times to place the cursor next to the insertion location

Provide one character space.


gigs
Insert "D".
CD

After the correction has been completed, press the 139 key.
BIB

* A mistake was noticed after the BE key was pressed.


Since a line is stored as part of a program after the 133 key is pressed, recall
it by using the LIST command to correct.
Example) Line 50 was mistakenly entered as "50 F=A/N".
Recall line 50 by using the LIST command.
BS 5 0 B3 iM
Pressing QXDSJCD provides the same result.

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.

If lines 60 and after are stored,


line 60 is displayed.
If no other correction is required, press the ES key to clear the display.
03
After the 133 key is pressed, a correction can be performed by recalling the
line with the LIST command. Also, the line can be rewritten with a new
line number.
When a new line is stored with a number which has been already used,
the line stored later has priority, and the old one is erased.

59
CHAPTER 3 "BASIC" PROGRAMMING

A program is stored as mentioned above. After the storage operation has


been completed, press HUES to return to the RUN mode. If the WRT mode
is maintained, a stored program may be erased or changed by mistake. There-
fore, be sure to return to the RUN mode after completion of the storage
operation.

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 •

Example) B E ) - * READY P3 Program area P3

-60-
3-2. PROGRAM PREPARATION

3-2-4 Program Execution


Perform calculation with the program that was previously stored.
Press BBSS and confirm that the computer is in the RUN mode ("RUN"
is displayed).
There are two different ways to execute a program.

(1) Execution by specifying the program area.


After pressing the S key, press the numeral key from i to S which
specifies a program area. If a program is stored, it will start.
Example) (SrlS
(2) Execution by the RUN command.
Example) B S (same as GO GDI!)) 63

The difference in these two execution methods is as follows. In method


(1), execution always starts from the beginning of the program area while
in method (2), execution can be started from the beginning or from an ar-
bitrary line number.
Execute a program with method (1).
Operation Display
B S '""'
Enter 2 data.
Example)
45 S3 '"!'
36 US 81 _Jp
When the PRINT statement is
executed, "STOP" is lit.

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

Next, execute a program by using the RUN command. If RUN IS is en-


tered, the result is the same as that obtained by method (1). Therefore, exe-
cute it from line 20.
Operation
BK20E3 | 61
(Same as RUN 20 623 .)
03
S3 [1628
S3 | 1. 25
If no line number is specified when the RUN command is used, program
execution starts from the beginning, and if a line number is specified, exe-
cution starts from that line number as mentioned above.
Actually there is another difference between these two methods.

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

HOW TO COUNT THE NUMBER OF STEPS


This computer is provided with a memory capacity of 1568 steps with RC-2
RAM card and 3616 steps with RC-4 RAM card.
A step is the unit that indicates the memory capacity in which a program
can be stored. As a program is stored, the number of remaining steps is
reduced.
When the WRT mode is specified by pressing BBCD, the current number
of remaining steps is displayed.

-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.

Example) 1 INPUT A 5 steps

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

100 PRINT * B = * . * B m lOsteps

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

3-2-5 Debugging (error correction)


After a program has been prepared and executed, it often happens that an
error is displayed and a result cannot therefore be obtained. Don't be dis-
appointed since the cause of this error can be found.
Eliminating errors is called "debugging".
The debugging method depends on the cause of the errors. In some cases,
an error is displayed during execution, and in other cases, an error is not
displayed but a result cannot be obtained as it is supposed to be. When
an error is displayed during execution, its location and its type are shown.
As a result, the cause can be easily found. However, when a correct result
is not obtained without displaying any error, this is troublesome.

(1) Debugging with the error display.


The error display provides "error message" which indicates the following
three items.

Line number where an error occurred


' Program area where an error occurred
' Error type

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

An error message is displayed; it indicates that a syntax error occurred on


line 20 in program area P0.
Check line 20.
Operation Display
03 Error release
ESQ] P ..... i 2T .-i r .- - I-I a
SS20E3 20 C =HB
Check if the line is correctly written. Since " + " between A and B was left
out, correct this.
Operation Display
0 :fiB
85 :
\A
= fl.
am

Since "ERR2" is mostly caused by erroneous program input, when "ERR2"


occurs, check the line whose number is indicated in the error message.
When data is read-in by a READ statement (see page 98), if character data
is read into a numerical variable, "ERR2" is also displayed. When a READ
statement exists at an "ERR2" location, check the data in the DATA state-
ment, too.
Check points for various errors are as follows.

-65
CHAPTER 3 "BASIC" PROGRAMMING

• ERR1: Shortage of memory. Stack over.


Confirm the number of remaining steps. Check if the memory
has been mistakenly expanded beyond the capacity by a DEFM
statement. Check if the calculation expressions are too com-
plicated.
• ERR2: Syntax error
Check if there are any errors in the stored program.
• ERR3: Mathematical error
Check if the arithmetic result of a calculation expression is more
than 10", or if the input range of a function is exceeded. When
variables are used, check their contents.
• ERR4: Undefined line number
The specification of a line number in a GOTO, GOSUB, or RE-
STORE statement is not correct. Confirm this line number.
• ERR5: Argument error
Check the value of an argument or parameter for a command
or function. When variables are used, check their contents.
• ERR6: Variable error
When an array variable is used, check if the memory is expand-
ed by a DEFM statement. Also, check if the same variable is used
for both character variables and numerical variables at the same
time.
• ERR7: Nesting error
If the line where an error occurred is a RETURN statement or
NEXT statement, check if the GOSUB statement or FOR state-
ment correspondence is correct or not. Also, if the line where
the error occurred is a GOSUB statement or FOR statement, check
if there are more than 8 nesting levels for a GOSUB statement,
and more than 4 for a FOR statement.
• ERR8: Password error
When a password is specified, check if another password was
entered, or if LIST, NEW, NEW ALL, etc. were used.

-66-
3-2. PROGRAM PREPARATION

• ERR9: Option error


Check if the FA-3 cassette interface or FP-12S character printer
are connected properly or not. Check if the rechargeable bat-
tery of the FP-12S is charged or the FP-12S is clogged with paper.
Also, adjust the volume or tone of the tape recorder connected
to the FA-3, clean the tape recorder head and replace the tape
with a new one. Or operate the tape recorder by using only the
white plug when recording is performed, and only the black plug
during tape playback.
The commands mentioned above will be explained later. See "COMMAND
REFERENCE" on page 123 and after for details.

(2) Although no error is displayed, the desired result cannot be ob-


tained.
Since this often happens when a calculation expression or variable in a
program was incorrectly used, check the operation of calculation expres-
sions and variables. Especially when a correct result is not obtained, com-
pare the original expression with the expression used in the program.
When the program execution does not stop or stops without work being
accomplished, check the operation of the variable that controls the pro-
gram flow. In regard to a calculation expression, check its location in the
WRT mode (press BB CD ).
The program flow can be checked by stopping it with a STOP statement
after entering data into the control variable, or by displaying the value of
a variable with a PRINT statement.
Store the following program.

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

This program obtains factorial of data entered by an INPUT statement. Ac-


tually line 50 is not required, and the variable used for FOR loop should
not be changed.
The FOR-NEXT statements on lines 30 and 60 form a loop in which calcu-
lation is repeatedly performed. (These statements will be explained later.)

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

Press Q3BB3 0 to specify the RUN mode.

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.

Check the value of variable C again


cm
Although the value of variable C must be increased by one each time, it
is increased by 2. Therefore, it was found that the FOR-NEXT loop opera-
tion (flow) is not correct. Check the increment of variable C again. It was
found that the problem is line 50 which is not required. Therefore, delete
line 50 and the STOP statement that was added on line 55.
Operation Display
EJJ[T] p \ 5456' :!8 9
/z:
50ES / ^
55BB
nainmi RE ft, Pi
Debugging has been completed.
There is another way to debug besides using the STOP statement. It is debug-
ging in the trace mode (Press fSBM • "TR" is displayed.) In regard to debug-
ging in the trace mode, a program is executed and stopped after each
command. Since the value of a variable, etc. is checked while the program
is stopped, debugging is performed by pressing the 63 key to advance to
the next command.
Try this with the previous example. The program area and line number are
displayed each time the S3 key is pressed.
Press I B 0 to release the trace mode; "TR" is erased.

Since debugging can be performed as mentioned above, when an error


is displayed or when the desired result cannot be obtained, don't be disap-
pointed but try debugging.

-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.

3-3-1 Changing The Program Flow (GOTO statements)


In addition to the three parts of a program, GOTO statements are very con-
venient when the same calculation must be repeated many times, or to trans-
fer program flow to an arbitrary line instead of following line numbers
sequence.
For example, let's prepare a program to obtain the square of a certain value.
This program can be broken down in three parts which are "data input",
"square calculation", and the "answer display". Make a flowchart.

INPUT A

Square calculation B— A^A

Answer display I PRINT B

Prepare the program in accordance with this flowchart.

10 INPUT A
20 B=A*A
30 PRINT B
40 END

-70-
3-3. PROGRAM DEVELOPMENT

For example, square 15 and 43.


Operation Display
RUNES
15D
RUN SB
45 S3

Since execution has to be performed each time as mentioned above, it is


very inconvenient when lots of data exist.
Do you think it is very convenient that calculation can be repeatedly per-
formed? It is the GOTO statement that makes this possible. The function
of a GOTO statement is to transfer program flow to a line number or pro-
gram area specified by the numerical value following GOTO. Replace the
END statement on line 40 with a GOTO statement.
4 0 GOTO 10
This means that the flow after line 40 is transferred (jumped) to line 10.
Execute the modified program.
Operation Display
RUN 133
15EJ3

43IB 1849

A GOTO statement is convenient for the repetition of calculation as men-


tioned above.
Since a GOTO statement can cause a return to the beginning of a program
to repeat execution, and can also cause a jump to an arbitrary location,
there are many convenient ways to use it.
For example,
10 INPUT A
20 GOTO 50
30 PRINT B
40 GOTO 10
50 B=A*A
60 GOTO 30

-71-
CHAPTER 3 "BASIC" PROGRAMMING

The flow of this program is as follows.

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.

When a jump is made to a program area, execution continues from the


beginning of the program in this area.

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.

Example) Try this by using the following program.


10 A = 1 2 3
2 0 B$=*ABC"
3 0 PRINT A , B $ After displaying the content of A, the
content of B$ is displayed by press-
ing the (S3 key.
4 0 PRINT A ; B $ The content of A and B$ are dis-
played continuously.
5 0 PRINT B $ ; After displaying the content of B$,
the execution advances.
6 0 PRINT A After displaying the content of A, the
7 0 END execution stops.
This program is executed as follows
Operation Display
RUN 333 12.j PRINT A,B$
HBC
12;ifiBC •PRINT A ; B $
/PRINT B $ ;
RBC 123 1 PRINT A
A one character space exists before the numerical value (123). This is the
space for a sign (+ or - ) ; since the positive sign is always omitted, a space
is opened.

-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

3-3-2 Condition Test By A Program


(IF-THEN statement)
If a size could be determined or control could be automatically performed
in a program, it would be convenient.
An IF statement makes a test in a program; it makes a test on a conditional
expression.

ine No. or program area


IF conditional expression THEN
ftInstruction statement
If the conditional expression is true, a jump is made to the line number
or program area following "THEN", or the statement following "THEN" is
executed. If the conditional expression is false, program execution advances
to the next line.
Let's check the function of an IF statement.
-74-
3-3. PROGRAM DEVELOPMENT

Example) Enter an arbitrary number. If it is larger than 10, a return is made


to the data input status. If it is 10 or smaller, its square is calcu-
lated and displayed then a return to the data input status.
This program consists of 4 parts (Input, Condition test, Calculation and Dis-
play). The following symbol is used for a condition test flowchart.

YES (True)

NO (False)

1£ 1 —-
Data input INPUT A

<^ Number larger^-^ 'ES IF A > 10 THEN 10


^ \ t h a n 1 0 ? - ^

30 |N°
Square calculation B= A*A

( Answer display PRINT B

I GOTO 10

The numerals at the left of the flowchart are line numbers.


10 INPUT A
20 IF A>10 THEN 10
30 B=A*A
40 PRINT B
50 GOTO 10
-75
CHAPTER 3 "BASIC" PROGRAMMING

Line 20 uses an IF statement. If the condition is true, the item following


THEN is executed. In this case, the program jumps to line 10.

The following relational operators are used for conditional expressions.


Left side > right side ... Left side is larger than the right side.
Left side < right side ... Left side is smaller than the right side.
Left side = right side ... Left side is equal to the right side.
Left side g right side ... Left side is larger than or equal to the right side.
Leftside g right side ... Left side is smaller than or equal to the right side.
Left side ^ right side ... Left side is not equal to the right side.

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.

This program can be divided into "Input", "Condition test", "Calculation"


and "Display" parts. The "Calculation" part includes three procedures;
obtaining the total, counting the number of items, and obtaining the aver-
age. Since the average calculation is only executed when " 0 " is entered,
it will follow the "Condition test" part.

-76-
3-3. PROGRAM DEVELOPMENT

Prepare a flowchart based on this analysis.

•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

As can be seen in this flowchart, the IF statement checks if data entered


to variable A is 0. If it is not 0, the total and number of data are obtained
after which a return is made to data input status. If it is 0, the average is
displayed and the execution terminates. Note that if the first input is 0, a
division by zero causes an error.
This example is slightly difficult compared to the previous one. In regard
to the calculation part, the input data are added to the variable for the total
calculation. Since B is the variable for the total, the calculation is "B^=B+A".
(The content of variable A is added to the content of variable B.)
In regard to the number of data, when a data is entered, 1 is added to the
counting variable (C in this case); "C=C+1" is realized.
In regard to the condition test part, which is the main part, if A is 0, the
average is displayed by a PRINT statement. Since a statement can be writ-
ten following THEN of an IF statement, "PRINT B/C" is written in this ex-
ample; the result of the calculation expression (B/C) is displayed.

77-
CHAPTER 3 "BASIC" PROGRAMMING

In regard to variables B and C, if values were previously entered into them,


they are continuously incremented and a wrong answer is obtained. As
a result, zero must be entered into these variables ("B=0", "C=0").
Although separate line numbers can be used for these two assignment ex-
pressions, it will be easier to use a multistatement (written as "B=0:C=0"
on one line with punctuation by a " : " (colon)).
Prepare the program.

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

Using an IF statement, a test is performed by the conditional expression


as shown above.

• 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

When a multistatement is used after THEN in an IF statement, it is execut-


ed only when a condition expression is true. Therefore, precautions shall
be taken.
Example 3)

IF A<0 THEN A=10:B=20:


Executed only when
condition is true.

A multistatement is convenient when arranging a program. However, since


one line is not easy to see if it is too long, make one line with an appropri-
ate length, and write the remaining items on the next line.

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.

< HINT >


After a numerical value is input, an IF statement determines which varia-
ble is used for totalization.
0 (zero) must previously be assigned to the variables for totalization.

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

< Display of two \


totalizations J

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

3-3-3 Repeating A Program (FOR-NEXT statement)


If combined GOTO and IF statements are repeated a certain number of times,
the program becomes too long and too complicated. When the number
of repetitions is known, the program can be arranged in a more simple way.
The command that performs this repetition is the FOR-NEXT statement.
In the FOR-NEXT statement, the calculation between the FOR statement
and the NEXT statement is repeated a specified number of times.
The format of a FOR statement is as follows.
FOR control variable = initial value TO final value STEP increment
The format of a NEXT statement is as follows.
NEXT control variable
A numerical variable with only one character, such as A or B, can be used
as a control variable in a FOR statement, but an array variable cannot be
used. The initial value, final value, and the increment can be a numerical
expression or numerical variable. The control variable is repeatedly changed,
by the increment, from an initial value to a final value. The increment can
be omitted and becomes 1 when omitted.
Store and execute the following program to easily understand the function
of a FOR-NEXT statement.

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

This program is executed as follows.

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

Prepare the flowchart.

•D=0

•INPUT A

1
/Total and average] PRINT D D/A
\display J

I
Totalization
c End
> •END

* This symbol for a FOR-NEXT loop indicates


that variable B is sequentially incremented
from 1, and when its value becomes larger
than the number of data, the program exe-
cution leaves the FOR-NEXT loop to make
a transfer to the next work.

Prepare a program based on this flowchart.

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

Answer display ) PRINT C

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

3-3-4 A Convenient Subroutine For Complicated


Programs (GOSUB-RETURN statement)

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".

A subroutine recalled by a main routine performs part of the work.

Main routine only With subroutine


. L
C J T.

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.

Example) Prepare a program to obtain permutations and combinations.

Expression: Permutations „p r =
Ut^T)\
Combinations „cr=—rr1^—rr

This program obtains permutations and combinations of two entered data


items («, r). I

85
CHAPTER 3 "BASIC" PROGRAMMING

Prepare a simple flowchart.

C
Answer
display

Now prepare detailed flowcharts for the calculation of permutations and


combinations.

( Permutation ^ \ /^~ Combination


calculation
D
calculation / I

n! calculation

n! calculation

r\ calculation

(n - r)\ calculation

(n - r)\ calculation

n\l(n~r)\ calculation

«!/r!/(« - 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

PROGRAM EXAMPLE (1) VARIABLE CONTENTS

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 •

120 P = E / F (n-r), calculation


130 A=1
140 FOR B=1 TO R
150 A = A * B • r! calculation
160 NEXT B
170 G=A _,
180 C = E / G / F .. ,, n! —^-calculation
r (n— r)
190 PRINT P ,c
2 0 0 END

In this program, three factorial calculations utilize a common program ex-


cept for the final value in the FOR statements. If this final value can be
controlled by a common variable, these three calculations can be made
in common. Here using a subroutine is very effective.
Use the variable H for the final values in order to make these calculations
common. It is necessary to sequentially enter the values of n, n-r, and
r into variable H. |
Now this program is changed and includes a subroutine system; a com-
mand that transfers the work to the subroutine, and a command to provide
a return after work termination are necessary. These commands are
"GOSUB" and "RETURN".

•87-
CHAPTER 3 "BASIC" PROGRAMMING

PROGRAM EXAMPLE (2)


10 INPUT N,R
20 H=N
30 GOSUB 150
40 E=A
50 H=N-R
60 GOSUB 150
70 F=A
80 P=E/F
90 H=R
100 GOSUB 150
1 10 G=A
120 C=E/G/F
130 PRINT P,C
140 END
150 A=1
160 FOR B== 1 TO H
170 A=A*B Subroutine
180 NEXT EI
190 RETURN

A program that has a common part can be simply prepared by using a


subroutine as shown above.
Although this program is shorter by only one line, it has an important func-
tion when a program is more complicated or longer.

[ 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

< HINT >


After data input, if " 0 " is detected by an IF statement, a return is made to
the main routine to obtain the standard deviation. SQR is used for square
root.

Main routine Subr Dutine

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

In this program, execution is transferred to the subroutine by line 20; data


input, sum calculation, sum of squares calculation, and the number of data
counting are performed from line 100 of this subroutine.
The IF statement on line 110 is the condition test for data input termina-
tion. If 0 is entered, the execution advances to the statement following
"THEN" and returns to the main routine.
Also, be sure to add END at the end of the main routine as shown on line 50.

3-3-5 Using Functions


Functions can be used in a program. Some program examples are explained
below.

Example 1) Trigonometric function


Obtain the length of side B of the triangle
on the left by entering side A and angle a.
Expression: B = A • sina
Angle unit: Degree
PROGRAM EXAMPLE Operation example Display
10 MODE 4 RUNE!
20 INPUT A , D (Side A) 1 5 GEQ
30 B=A*SIN D (Angle a) 3 0 SB
40 PRINT B
50 END

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.

Example 2) Trigonometric function

p(*.«/) Obtain the coordinates (x, y) of point P of


the circle on the left by entering the radius
r and angle 6.
Expressions: x = r- cos 0
y = r- sin 8
Angle unit: Radian

90
3-3. PROGRAM DEVELOPMENT

PROGRAM EXAMPLE Operation example Display


10 MODE 5 RUN El
20 INPUT R , T (Radius) 5BB
30 X=R*COS T (Angle 0) 7T/3BB
40 Y=R*SIN T m 4!33012701'
50 PRINT X , Y
60 END

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.

Example 3) Inverse trigonometric function

Obtain angle a of the triangle on the left


, by entering side A and side B.
Expression: «=tan _1 -S.
A
Angle unit: Degree
PROGRAM EXAMPLE Operation example Display
10 MODE 4 RUNGS •"!'

20 INPUT A,B (Side A) 100 S3 •~i

30 D=ATN(B/A) 2003 1 1 . 309 9 32 4 7


40 PRINT D
50 END
Example 4) Decimal <-• Sexagesimal conversion
Prepare a program that performs time calculation.

PROGRAM EXAMPLE Operation example Display


•™i
10 T=0 RUN US
20 INPUT D . E . G (Hour) 1 US •~i

30 S=-1 (Minute) 2 5 Si •"!•

40 IF M I D $ ( 1 , 1 ) = " - " (Second) 36 BS 1 il -_i -J b


THEN S = - 1 US •~i

50 D=ABS(VAL($) ) (Hour) 2 US *"'


60 T=T+S*DEG(D,E.G) (Minute) 1 5 US •~!
70 PRINT D M S $ ( T ) (Second) 5 US 3"40'41
80 GOTO 2 0

-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 5) Random number generation


Generate random numbers from 1 to 99.
PROGRAM EXAMPLE
10 R=INT(RAN#*99)+1
20 PRINT R
30 GOTO 10

A random number is generated on line 10. The number being from 1 to


99 in this example, multiply the generated random number by 99 and add
1 to the result to obtain a number from 1 to 99 (see page 160).
When the random number is from 5 to 9 -»I NT( R A N # * 5 ) + 5
When the random number is from 10 to 20 - H N T ( R A N # * 1 1 ) + 10

3-3-6 Using An Array


Being different from general variables from A to Z, an array variable is
managed by a number (subscript).
An alphabetical character from A to Z can be used for the variable name
with a subscript attached.

Example) A( 1 )
' Subscript
' Variable name

-92-
3-3. PROGRAM DEVELOPMENT

An array is convenient when a large amount of data is handled.


For example, to enter 10 data items:

10 FOR A=1 TO 10
20 INPUT N(A)
30 NEXT A

In this case, the array is arranged as follows.

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)

To select the largest data item from among 50:


10 A=0
20 FOR B=1 TO 50
30 IF P(B)>A THEN A=P(B)
40 NEXT B
50 PRINT A

When an array is used, precautions should be taken concerning its arrange-


ment. Some array containers are commonly utilized as those for general
variables. For example, the container for A(0) is the same as that for A, and
A(1) is the same as B. Therefore if A(0) and A are used in the same pro-
gram, data in the variable is changed.
The common parts are as follows.

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)

X(0) X(1) X(2)


Y(0) Y(1)
Z(0)
* For details, see page 196.

-93-
CHAPTER 3 "BASIC" PROGRAMMING

For example, perform the following operations.

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.

Example 1) When 10 array variables are used,


Array variables: A( 0 ) — A( 9 )
Unused general variables: K — Z

Example 2) When 50 array variables and 15 genera! variables are used,


General variables: A — 0
Array variables: P ( 0 ) — P ( 4 9 ) [ Operate DEFM 39 SS . ]

Example 3) When variable A is used for FOR-NEXT loop, variable B


for totalling and 100 array variables are used,

10 DEFM 76 Increase variables by 76 to obtain


102 variables.
20 B=0
30 FOR A=0 TO 99
40 INPUT C(A) Array variables C(0) to C(99) can be used.
50 B=B+C(A)
60 NEXT A

94
3-3. PROGRAM DEVELOPMENT

When a large amount of data is handled by an array, precautions shall be


taken so that these array variables do not overlap other general variables.

Also, precautions shall be taken on memory expansion when an array is


used. When the general variables A to Z are sufficient for the size of the
array, expansion is not required. However, when these variables are not suffi-
cient, be sure to expand the memory.
Memory expansion is performed by the DEFM command which specifies
the amount of expansion.
For example, when an expansion of 10 variables is performed,
Manually: DEFM 10 SB
In a program: Line number DEFM 10

This command can be used manually or in a program. Write it at the be-


ginning of a program when an array is used. Now, analyze a program that
uses an array.
Example) Assign random numbers from 0 to 99 to array variables from
G(0) to G(99) and arrange them in the descending order for
display.
PROGRAM EXAMPLE
10 DEFM 80
20 FOR B=0 TO 99 ]
Assign random numbers
30 G(B)=INT(RAN#*100) 0—99 to G(0)—G(99).
40 NEXT B
50 BEEP 1
60 FOR B=0 TO 99
70 A=-1
80 FOR C=B TO 99
Arrange them in the
90 IF G(C)>A THEN A=G(C).*D=C descending order.
100 NEXT C
1 10 E = G ( B ) : G < B ) = G < D > : G ( D ) = E
120 NEXT B
130 BEEP 0
140 FOR B=0 TO 99 ]
150 PRINT G(B) Display them sequentially.
160 NEXT B J
170 END
-95-
CHAPTER 3 "BASIC" PROGRAMMING

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.

1st time 2nd time 3rd time 4th time


73 99 99 99
90 c 90 3 90 90
65 65 65 73
99 73 G 73 65
71 71 71 71 :

The DEFM statement on line 10 is used to expand the memory. Since 20


variables (G to Z) are remaining and 100 variables (G(0) to G(99)) are
necessary, memory expansion for 80 of them is required.
An array is convenient when a large amount of data is handled.

-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

'PRINT "\ SET N


< 'B)/AXI00/ \
End
( )

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.

3-3-7 Data Read-in (READ, DATA, RESTORE statements)


When an INPUT statement (data input method) is used, "?" is displayed
during program execution to ask data input from the keyboard. A READ
statement reads data written in a DATA statement and assign them to
variables.

Example) Read 10 data items in a DATA statement and display them.

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

A READ statement must be used together with a DATA statement since a


data item fetched from a DATA statement is assigned to a variable follow-
ing "READ".
Several variables can be written after a READ statement by punctuating them
with commas (,).

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

A DATA statement can be placed anywhere in a program. After program


execution, data are assigned to variables sequentially from the first data
of the DATA statement that has the smallest line number. When data writ-
ten in a DATA statement are numerical values, use numerical variables for
the variables in the READ statement, and when they are characters, use
character variables.
Example)
PROGRAM Operation Display
10 RESTORE RUNBB ABC
20 READ A$ G33 123456
30 PRINT A$ m fiE:i
40 READ B
50 PRINT B
60 RESTORE 90
70 READ C$
80 PRINT C$
90 DATA ABC
100 DATA 123456
110 END

When no line number is specified by a RESTORE statement, the first data


in the first DATA statement in the program is read by the next READ state-
ment. When a line number is specified, the first data in the specified DATA
statement is read by the next READ statement.

-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

PROGRAM EXAMPLE MEMORY


10 FOR A=0 TO 4 A : FOR-NEXT
20 READ G $ ( A ) statement use
30 PRINT G $ ( A ) ; B : FOR-NEXT
40 INPUT L ( A ) statement use
50 NEXT A C : Maximum value
60 FOR A = 0 TO 4 D : Number of maximum
70 C=0 value
80 FOR B=A TO 4 E : Arrangement use
90 IF L ( B ) > C THEN C = L ( B ) F$»: Arrangement use
D=B •
G $ ( 0 ) — G $ ( 4 ) : Names
100 NEXT B L ( 0 ) — L ( 4 ) : Data
1 10 E = L ( A ) : L ( A ) = L ( D ) : L ( D )
=E
120 F $ = G $ ( A ) : G $ ( A ) = G $ ( D ) :
G$(D)=F$
130 PRINT G $ ( A ) ; L ( A )
140 NEXT A
150 DATA CHICAGO, LONDON, PARIS, ROME, TOKYO

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

3-3-8 Indirect Specification (ON-GOTO, ON-GOSUB


statements)
Although GOTO statement and GOSUB statement specifications are per-
formed by writing the line number or program area directly in a program,
sometimes the branching depends on the arithmetic result or the data for
processing convenience. In this case, testing the condition with an IF state-
ment is not convenient.
The commands that determine and specify a branching in a program are
indirect specifications (ON-GOTO and ON-GOSUB).
The function of an ON-GOTO statement is similar to that of an ON-GOSUB
statement.
Example)
ON A GOTO 100, 200, 300, 400
A=2
A=3
fir=A

ON A GOSUB #1 #2. #3, #4


AF1
J AF=2
A=3
A=4

Branching is performed to the 1st location if the value of A is 1, and to


the 2nd location if this value is 2, etc. It depends on the numerical varia-
ble or the result of the calculation expression that follows " O N " . When
the number of branching locations is less than the value of the variable
or calculation expression, or when a branching location does not exist,
program execution advances to the next line, or command in case of a
multistatement.

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

MODE 4 MODE 5 MODE 6


I
(~ RETURN J) ( RETURN J Q RETURN )

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

3-3-9 Character Handling Functions (LEN, MID$,


VAL, STR$)
While SIN and COS are called numerical functions because they handle
numerical values, there are character functions that handle characters. This
computer is provided with " L E N " , " M I D $ " , " V A L " and "STR$" charac-
ter functions.

• 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) Operation Display


10 A=123:B=456 RUNSB •j i
20 PRINT A+B M 12345 6
30 PRINT STR$(A)+STR$(B)
40 END

Example)
10 INPUT $
20 FOR A=1 TO LEN($)
30 PRINT MID$(A,1);
40 BEEP 1
50 NEXT A
60 END

This program fetches a character entered in the exclusive character varia-


ble ($) with the MID$ function. One character is fetched each time. The
starting location is specified by a FOR-NEXT statement,and the final value
is determined by the LEN function.
" ; " is added at the end of line 30 so that the program does not stop be-
cause a continuous display is desired.
Example)
10 A=1:B=0
20 PRINT * < * ; S T R $ ( A ) ; * > " ;
30 INPUT $
40 IF $=*END* THEN 100
50 B=B+VAL($)
60 A=A+1
70 GOTO 2 0
100 PRINT B / ( A - 1 )
110 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.

3-3-10 Input/Output Control Functions (KEY$, CSR)


Although the KEY$ function is used to enter data, it differs from an INPUT
statement as follows.

INPUT statement KEYS function

• Within a 12 digit mantissa and a 2 • Reads the character of the key


digit exponent for a numerical which has been pressed and as-
value. signs it to a character variable.
• Up to 7 characters for a character
variable and up to 30 characters
for the exclusive character varia-
ble ($).

• Input waiting is indicated by a " ? " • No input waiting display occurs.


display.

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

The CSR function specifies a data display location; it is used in a PRINT


statement.
Example)

10 PRINT *A"
20 PRINT CSR 2;*A"
30 PRINT CSR 8;*A"
40 END

The CSR function can be understood by executing this program.


When this function is used, display starts from the specified location (0,
1, 2, . . . or 11 from the left).
When it is not used, display starts from the extreme left.

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

A PRINT CSR 8;*A"

Example)

10 A=INT(RAN#*12)
20 PRINT CSR A;*t"
30 GOTO 10

This program generates a numerical value from 0 to 11 by using the RAN #


function and displays " T " with the CSR function. After a certain time, " T "
is displayed at different locations. An interesting game can be prepared
by combining the KEY$ and CSR functions.

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

This is a game program. Numerals from 0 to 9 are displayed. One of these


is displayed as " T " . Press the numeral key ( E) to M ) which corresponds
to the location of " T " .
On line 50, " t " is displayed at the location corresponding to the numeral
from 0 to 9 generated by the RAN # function on line 40.
Line 30 is used to wait until the pressed key is released.
Line 60 and after test if a key is pressed, in which case, repetition ceases
and a test is made to see whether the correct key is pressed or not.
Lines 100 and 110 test if a numeral key is pressed. Input of a character
other than 0 to 9 causes branch to line 130; a beep sound is generated
as an incorrect answer signal.
Line 120 is used to test if the answer is correct. Since KEY$ reads a charac-
ter, the condition test is performed after converting this character to a nu-
merical value with the VAL function.
Whether a key is pressed or not is simply checked as shown on line 30,
so the test can be performed without assigning KEY$ to a character varia-
ble. However, when several tests are performed to check if the answer
is correct as shown on lines 70 to 120, KEY$ is assigned to a character
variable. Store this program to play.
Operation example
Display Operation
011345 6 789 Press
01234567T9 Press
8123t56789 Press

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

This computer has optional equipments: a cassette tape recorder interface


(FA-3), and a character mini printer (FP-12S) for the PB-410 and FX-720P.
The FA-3 allows programs and data to be stored from the computer on a
tape, or to be loaded from a tape to the computer.
The FP-12S can print programs, data and arithmetic results.
The functions of these equipments are explained below.

3-4-1 Storing A Program Or Data


To store a program or data on cassette tape, the FA-3 is necessary. To con-
nect the FA-3 to the computer and to a tape recorder, see the Instruction
Manual that comes with the FA-3.

• Program storing and loading


Since programs are memorized in the computer, sometimes the next pro-
gram cannot be memorized because of memory capacity. In this case, if
the previous program is erased, it cannot be used again. Also, when the
battery of the RAM card is replaced, programs and data are erased. In such
cases, the FA-3 is very helpful.
Commands for storing programs on a tape are "SAVE" or "SAVE ALL". "SAVE"
can only store a program located in one program area, while "SAVE ALL"
can simultaneously store programs located in all program areas.

SAVE command

mm READY Pn
Z The program located in this program area
can be stored.

-Ill-
CHAPTER 3 "BASIC" PROGRAMMING

SAVE ALL command


Programs located in all program areas can be stored.
The SAVE and SAVE ALL commands are manually executed.
Example)
SAVE m
SAVE *CAS 10" S3!
SAVE ALL IB
SAVE ALL *PB* US
Characters enclosed with the quotation marks ( " ) after SAVE and SAVE ALL
are file names which are placed with stored programs. These programs can
be loaded later by specifying these names. Up to 8 characters can be used
for a file name.
LOAD and LOAD ALL commands are used to load programs from a tape
to the computer. The proper use of these commands depends on whether
programs were stored by SAVE or SAVE ALL.

'}. — ^

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

When programs are loaded by LOAD or LOAD ALL, a display depending


on the storing format appears.

Sttrina format Display

SAVE PF:

SAVE "file name" PF: file name

SAVE ALL AF:

SAVE ALL "file name" AF: file name

A program stored by a SAVE command can be loaded to any of the pro-


gram areas by a LOAD command.
Example) Stores the program of P0.
I
Loads it to P9.

Precautions:
Sometimes a program cannot be stored or loaded smoothly. If this hap-
pens, check the following items.

• "ERR9" is displayed during storing.


[Check point]
Check if the computer is properly connected to the FA-3.
• "ERR9" is displayed during loading.
[Check points]
If the tape is stretched, replace it with a new one.
If the head of the tape recorder is dirty, clean it.
Set the tone control of the tape recorder to medium.
• No error is displayed but loading is attempted without success.
[Check points]
If the tape recorder output volume is low, increase the volume near MAX.
Check if the output standard of the tape recorder is in accordance with
that of the FA-3.

-113-
CHAPTER 3 "BASIC" PROGRAMMING

• Storing and loading of data for DATA BANK function


When stored data for DATA BANK function are transferred to another unit,
or when the RAM card battery is replaced, they must be stored on tape.
"SAVE#" is used to store all the data for DATA BANK function at once.

SAVE# 'file name*


1
Up to 8 characters.

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.

LOAD** "file name*


i
Up to 8 characters.

Example)

LOAD** *MEMO" Ed

When data for DATA BANK function are being loaded, a display depend-
ing on the storing format appears.

Storing format Display

SAVE* MF:

SAVE# "file name" MF: file name

-114-
3-4. CONVENIENT OPTIONAL EQUIPMENTS

• Data storing and loading


A program always has data; it is troublesome to enter these data from the
keyboard each time.
Try a method by which data in the memory are stored on tape and loaded
again.
To store data on a tape, "PUT" is used.
Variables are specified in a PUT command. A file name can also be specified.

PUT "file name" $,A,Z


1 r
Up to 8 characters. Stores 26 variables from A to Z.

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.

GET "file name* $,M,W


1 — i —
Up to 8 characters. Loads to variables from M to W.

-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)

When data is being loaded by a GET command, a display depending on


the storing format appears.

Storing format Display

PUT $, A, Z DF:

PUT "file name" G, P DF: file name

3-4-2 Keeping A Record


If the content of a program can be printed after preparation, it is convenient
to perform debugging or to modify its content. It is also convenient to be
able to keep an arithmetic result after it is printed.
Perform printing with the character printer.
To perform printing the print mode ("PRT" is displayed) must be specified
by pressing BSE]. This mode can be released by pressing B S3.
To print the content of a program, execute the LIST command after
pressing B ( 2 .
Example)
Input the following program.
10 INPUT A
20 PRINT A*A
30 GOTO 10

116
3-4. CONVENIENT OPTIONAL EQUIPMENTS

Then perform printing.

• 0 L I S T S3 Print example
LIST
16 INPUT fi
20 PRINT fl*fl
38 SOTO 18

When the contents of all program areas are to be printed, perform

L 1ST ALL US

Release the print mode by pressing B E ) after printing is completed.


To print an arithmetic result, specify the print mode by pressing B E ] o r
by writing "MODE 7" in the program. When B E ) is pressed, all key oper-
ations after that are printed. Therefore, if only one part is to be printed,
it is more convenient to write "MODE 7" in the program.
* In this case, input must be performed by pressing the (M) E l E l (Xl keys
instead of the B key.
Example)
Only the arithmetic result is printed.
10 INPUT A
20 MODE 7
30 PRINT A*A
40 MODE 8
50 GOTO 10
In this program, the print mode is specified after data input and is released
after printing to return to input waiting status.
The display by the PRINT statement is not stopped during printing, and
the program execution advances to the next command after printing.
Release the print mode by writing "MODE 8".

-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

This computer PB-100/PB-300

NEW (NEW ALL) CLEAR (CLEAR A)


CLEAR VAC
IF-THEN IF-;
SAVE ALL SAVE A
LOAD ALL LOAD A
VERIFY VER
DEFM (Can be written in a program) DEFM (Can only be performed manually.)

-118-
3-5. USING A PB-100 PROGRAM

• Modified functions

This computer PB-100/PB-300

KEY$ KEY
MID$ MID

In spite of these different points, a program prepared by the PB-100/PB-300


can be fundamentally utilized with this computer.
However, it is better that programs be rewritten for this computer so that
it can be easily used or can be easily reconsidered later.
Example 1)
PB-100 program

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

Change " ; " on lines 40 to 70 to "THEN".


40 IF Z(A)>80 THEN B=B+1:G0T0 90

-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

This program is used to determine branch locations according to the work.


To adapt it for this computer, modify it as follows by using an ON-GOTO
statement.

10 INPUT * 1 = 1/0=2/P=3*,N
20 ON N GOTO 100,200,300
30 GOTO 10

The program is simplified by utilizing an ON-GOTO statement as mentioned


above; testing the data N is deleted.
Programs and data stored on tape by CASIO'S handheld computers can
be loaded as they are to this computer. However, the reverse operation is
not always possible. Therefore precautions shall be taken. The relationships
are as follows.

-120-
3-5. USING A PB-100 PROGRAM

This computer -» FX-710P

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

• OOOO* The element with * on the top right can be repeat-


edly used.
• Numerical expression
Numerical value, calculation expression, and numerical variable
such as 10, 2+3, A, S*Q.
• Character expression
Character constant, character variable, and character expression such
as "ABC", X$, N$+M$.
• Parameter An element that accompanies a command.
• ® Can only be executed in a program.
• (0) Can only be executed manually.
• (§) Can be executed both manually and in a program.
• (£) Function instruction that can be executed both manu-
ally and in a program.

<Example> DATA [data] [,[data]]*


Since all data are provided with a bracket [ ] , it will also be possible to
write "DATA" only. Since ,[data] is provided with [ ]* this element can be
written repeatedly. This can therefore be written "DATA data, data, ..." If
we omit the first [data], this can also be written "DATA, data, data, ....."

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.

10 PRINT ' L I N E 10"


20 P R I N T ' L I N E 20"
3 0 END

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.

(1) If this command is executed when a password is not specified, a pass-


word is specified for all program areas (P0—P9).
(2) If this command is executed while a password is specified, this pass-
word is released only when entering the corresponding password. When
passwords do not correspond, a protect error (ERR8) occurs.
(3) A password consists of a 1—8 character string in which spaces, alpha-
betical characters, numerals, special symbols, etc. can be used. However,
(") cannot be used.
(4) While a password is specified, commands such as LIST, LIST ALL,
LIST#, NEW, NEW ALL and N E W # cannot be used. Also no writing
(WRT mode) can be made; if it is attempted, an error (ERR8) occurs.
(5) Cannot be used in a program.
(6) A password can be maintained while the power switch is off.
(7) If a program is stored on a cassette tape by a SAVE or SAVE ALL com-
mand while a password is specified, this password is also stored. When
a program with a password attached is loaded from a cassette tape by
a LOAD or LOAD ALL command, the password is also loaded. Also,
when a currently specified password in the mainframe and the pass-
word of a program loaded from a cassette tape are different, the pro-
gram cannot be loaded from a cassette tape (ERR8).

[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.

PASS' CAS IO"B0

-128-
["File name"!
SAVE [ALL] Character string

Stores a program on a cassette tape.

ALL: Stores the programs in all the program areas.


File name: String with 1 — 8 characters. Can be omitted.

(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 and LOAD Relationship


LOAD LOAD ALL LOAD ALL
LOAD "File name" "File
SAVE O X X X

SAVE
"File name" O O X X

SAVE ALL X X O X

SAVE ALL
"File name"
X X O O

* File names are identical. O... Can be loaded.


x ... Cannot be loaded.

-130-
["File name"] @
VERIFY Character string

Checks the status of a program and data stored on a cassette tape.

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 ®

Clears all variables.

(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.

Since program execution is terminated, the next program is not executed


even if it exists.

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.

[LET] ( Numerical variable = numerical expression]


(Character variable = character expression J

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

I M P I I T f " M e s s a 9 e statement","[variableT, |""Message statement","]variable]'


I I M l %J 1 |_ Character string J name |_ |_ Character string J name J

Inputs data from the keyboard to a variable.

Message: Character string


Variable name: Numerical variable name or character variable name.

-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$ ®

A function that enters one character from the keyboard.

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.

Output element: Output control function (CSR), numerical expression,


character expression.

(1) Displays an output element. When an output control function is add-


ed, the element is displayed at the location determined by this
function.
(2) Values are displayed for numerical expressions and character expressions.
(3) When an output element is a numerical expression, a position for sign
(+, - ) is placed before the value. However, the + sign is displayed
as a blank.
• Character display ^^^ ,_,
Output element
• Numeral display ^ ^ ^ ^ ._,
Sign Output element

(4) When an output element is a numerical expression and the mantissa


is more than 10 digits, the 11th digit is rounded off. When an exponent
exists besides the mantissa, an exponent sign (E) and a two digit expo-
nent are displayed.
(5) " , " and " ; " can be used as punctuation between output elements.
When " , " is used, the execution stops (STOP is displayed) after the
first output element is displayed, then the next output element is dis-
played by pressing the BS key. When " ; " is used, the next output ele-
ment is displayed continuously after the first one.
(6) When no output element is specified (only PRINT is written), the dis-
play is cleared and is not stopped.
(7) The display is not stopped during printing in the print mode (BBS).
(8) The output format of the numerical value can be specified by a SET
statement.

-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

p e p Output location specification


V / w r l Numerical expression
exDression

Displays an output element from a specified location.

Output location specification: Numerical expression. Values below


decimal point are discarded.
0 g specification < 12
| Explanation]
(1) Used in a PRINT statement to specify the location of an output element.
(2) The output location of the left end is 0.

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

Unconditionally branches to a specified location.

Branching line No.: Line No. from 1 to 9999.


Program area No.: A number from 0 to 9.

(1) Branches to a specified location.


(2) When a branching location is a line number, branches to the specified
line in the current program area and executes the program. When the
branching line number does not exist, an error (ERR4) occurs.
(3) When the branching location is a program area number, branches to
the specified program area and executes the program from the beginning.
* A numerical expression can be used for the branching line number and
the program area number.

•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]

Branching condition: Numerical expression. Values below the decimal


point are discarded.
Branching line No.: Line No. from 1 to 9999.
Program area No.: A number from 0 to 9.
iion~|
(1) Branches according to the integer part of the value in a branching con-
dition expression. Branching locations are allocated sequentially ac-
cording to

ON A GOTO 1Q0, 200, 300,


A = 1 A =2 A =3

(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

• When 1—3 is entered, branchings to 100—300 are performed respectively,


otherwise "OTHER" is displayed.

-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.

When a branching condition is true, the statements after THEN are


executed. Also, when a statement after THEN is a branching location,
branching is performed.

Branching condition: Conditional expression


Branching line No.: Line No. from 1 to 9999.
Program area No.: A number from 0 to 9.

| 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 |

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 repeti-
tion of the process.

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.

Branching line No.

GOSUB Line No.


# program area No.
A character from 0 to 9

Performs a branching to a specified subroutine.

Branching line No.: Line No. from 1 to 9999.


Program area No.: A character from 0 to 9.

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.

f \ k | Branching condition / " * ^ Q | I D ' Branching location ] (g)


V^IM Numerical expression V j U O U D [, [ Branching location ]]*
• Branching location f B r a n c h i n 9 line No.
) # program area No.

' Function |

Branches to a subroutine according to a branching condition.

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.

(1) Performs a subroutine branching by the integer part of the value in a


branching condition expression. Branching locations are allocated se-
quentially according to the value of the expression.

-142-
ON B GOSUB 1000, 2000, 3000-

(2) When the value of the expression is smaller than 1 or an appropriate


branching location does not exist, the next statement is executed without
branching.
(3) As many branching locations as can fit in one line can be written.

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

• When 1—3 is entered, a branching to the corresponding subroutine occurs,

[data] [.[data]]* ®
DATA Constant Constant

Stores data.

Data: Character constant or numerical constant.

(1) Used to write data that is read by a READ statement.


(2) Plural data can be written by punctuation with " , ".
(3) If only a DATA statement is executed without a READ statement, no
function is performed.
(4) When a character constant includes " , ", place it inside " ".
DATA ABC. DEF, " G H I . J K L " ,
1st 2nd 3rd

(5) When data is omitted, a character string with a length of 0 is taken


by default.
DATA A, ,B — DATA A,*",B
DATA , — DATA **,**
DATA — 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.

(1) Allocates data in the currently specified DATA statement sequentially


to a specified variable.
(2) Only numerical type data can be read for a numerical variable.
(3) Data in DATA statements are read sequentially with the smallest line
number first, and sequentially from the beginning in a statement.
(4) After the necessary data are read by a READ statement, the following
data are read by the next READ statement.
(5) The first data in the program area where a READ statement exists is
read by the first execution of this statement after which data in the pro-
gram area at that time are read sequentially.
(6) The specification of data to be read can be changed by a RESTORE
statement.
(7) When the number of data in a DATA statement is smaller than the num-
ber of variables in a READ statement, an error (ERR4) occurs.
(8) When a space exists at the beginning of data, it is skipped.
[Example]
10 DATA 1,2,3
20 READ A,B
30 PRINT A;B
40 DATA 4,5
50 READ C.D.E
60 PRINT C ; D ; E
70 END
• Reads data sequentially from a DATA statement and displays them.

-144-
RESTORE —N°'
Numerical expression

Specifies the location of data to be read by a READ statement.

Line No.: Numerical expression. Values below the decimal point are
discarded.
1 <line No. < 9999

(1) Specifies a DATA statement where data to be read by a READ state-


ment exist.
(2) When a line number is omitted, the data specification is cancelled.
After this, the first data in the program area where a READ statement
exists are specified and read by the first READ statement that is executed.
(3) When a line number of the program area is specified by a RESTORE
statement, data of the DATA statement with this line number are read
sequentially by the READ statement.
(4) When a specified line number does not exist or a DATA statement does
not exist on a specified line number and after, an error (ERR4) occurs.

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.

[ " File name " ] variable 1 [, Variable 2 ]* ®


GET Character string

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.

(1) Generates a high or low beep sound.


(2) Can also be used manually.

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.

En: Specifies the number of decimal places.


En: Specifies the number of significant digits.
N: Releases a specification.

(1) Specifies the number of decimal places or significant digits.


(2) For specifying the number of decimal places (En), a value from 0 to
9 is used.
(3) For specifying the number of significant digits (En), a value from 0 to
9 is used. Also "SET E0" indicates a 10-digit specification.
(4) Both specifications are released by " SET N ".
(5) It can be executed both manually and in a program.
(Ixin^ie"]

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

LEN (Simple character variable)

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.

(1) Counts the number of characters in a simple variable.


(2) The character variable used is a simple character variable (A$, Y$, etc.);
an array character variable (B$ (3), etc.) cannot 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.

10 $ = * ABCDE FGH I JKLMNOPQRSTUVWXYZ "


2 0 INPUT M , N
3 0 PRINT M I D $ ( M , N )
4 0 END

-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 ) ©

Converts the value of a numerical expression into a character string.

Numerical expression:Numerical value, calculation expression, numerical


variable, numerical array variable.

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

C I M Argument ^ /^ >^ ^A OC Argument


^ J l l ^ l Numerical expression V ^ V ^ ^ J Numerical expression

J A M Argument
I ^ ^ 1 T| Numerical expression

Function

Obtains the value of a trigonometric function for a given argument.

: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.

(1) Obtains the value of a trigonometric function for a given argument.


(2) The value depends on the angle unit setting (by the B key or MODE
command).

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°

I f\^* Argument I |k| Argument (p)


L H V ^ V ^ I Numerical expression l « I M Numerical expression

Gives the value of a logarithmic function.

Argument: Numerical expression.


0 < argument

Gives the value of a logarithmic function.


• LOG Common logarithmic function logTOx, log*
• LN Natural logarithmic function logex, Iru

-156-
P Y D Argument (F)
Numerical expression

(Function |
Gives the value of an exponential function.

Argument: Numerical expression.


- 2 2 7 ^ argument ^ 230

Gives the value of an exponential function.


EXP ex

Argument
SQR Numerical expression

Function
Gives the square root of an argument.

Argument: Numerical expression.


0 g argument

Gives the square root of an argument.


SQR 4x

-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.

Argument: Numerical expression.

-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 decimal part of an argument.

Argument: Numerical expression.


Gives the decimal part of an argument. The sign is in accordance with the
sign of the argument.

DKin (Argument , digit location) (F)


rilML/ Numerical expression 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

Provides a random number with 1 digit from 0—9.


INT (RAN# * 10)
Provides a random number with 1 digit from 1—5.
INT (RAN # * 5) + 1
Provides a random number with 2 digits from 10—99.
INT (RAN# * 90) + 10

l^r^^N ( Degree [, Minute [, Second ] ]) (p)


L ^ E B \ M Numerical expression Numerical expression Numerical expression

Converts sexagesimal to decimal.

-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

Converts decimal to sexagesimal.

Argument: Numerical expression.


| numerical expression | < 10100

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.

(1) Erases all stored data.


(2) Cannot be executed when a password is specified
(3) Can only be executed in the WRT mode.

| Example] ggrr]
NEWttEB

LIST# <8>

• • • . . .

Displays all data for Data Bank function.

(1) Displays stored data sequentially from the beginning.


(2) Displayed contents are a sequential No. and data.
(3) Since data are automatically displayed sequentially, press the (HOP) key
to stop display. Press the M key to resume the display of the next data.
(4) In the Print mode (BBS)), the display is not stopped but is performed
sequentially at high speed.
(5) Cannot be executed when a password is specified.
(6) Cannot be executed in the input mode for Data Bank function (BBS)).

[Sample] LISTttffll

-162-
[
Q AX/p 4t "File name" 1 @
Character string

rv)
Stores data for Data Bank function on a cassette tape.

File name: A string with 1—8 characters. Can be omitted.

[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

I A A H •*#• ["File name"] (g)


^AJfAU TT" Character string

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.

Fxamplej LOAD #331


LOAD#*CASIO"Sa
-163-
Vanab,e
HEADTT name [, variable name ] *

Reads data 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.

llxample <Data> (Program)


No. 1 1,2 3 10 A=0
No.2 4,5 6 20 READ#$
No. 3 7,8,9 30 IF $=* " THEN 6 0
No. 4 10, 40 A=A+VAL($)
50 GOTO 20
60 PRINT *2*=*;A
70 END
Reads numerical data to obtain a sum.
-164-
D C C T H D C •4+ [""Searched character string"[" f f O ] ] (P)
• • C O I \ J I ! C TT" L ' Character expression L ' LU 3 J

[ f Line number ^1

>^# program area number J J

[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.

Data: Numerical expression or character expression.' When a character


string is used, place it inside " ".

(1) Writes data in the record area currently specified by RESTORE#.


(2) Data are newly written without any relationship to data existance in
the appropriate record area.
(3) When no data is specified, stored data in the record area are deleted.
(4) When plural data exist, these data can be written on the same record
area by using " , " for punctuation.
(5) After the necessary data are written by the first WRITE # statement, the
following data are written by the next WRITE # statement.

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]

Standard deviation of v data (yanA)\ /nSy'-(Zy)'


/
n(n-i)
Standard deviation of y data (yon) : / niy' (iy)'
v n
S y - L R B
Linear regression constant term (A): '^—

Linear regression coefficient (B) : ""^sx'^saO^


n-Zxy-ZX'-zy
Correlation coefficient (r) : AnZx'-CZxy^nZy'-CLy)'
Estimated value of x (x) . J/n-LRA
LRB
Estimated value of y (y) LRA+Xn-LRB

-170-
1. STATISTICAL CALCULATION

• P r o g r a m list 18 PRIHT "START ?< 390 L= 5QR«B*I-H*H


Y/N)"; >/<B*e>>
28 *= KEY! 319 0=(B*H-C*H)/<B*
38 IF $="H* THEN 1 D-C*C)
88 329 M=<H-0*C)/R
48 IF $*"Y" THEN 2 339 ?=(B*«-C*H)/ SQ
8 R((B*D-C*C)*(B*
58 PRINT : BEEP 8 I-H*H)>
68 CLEAR 349 INPUT "INPUT(8-
79 PRINT "DATA 1 0 17)",Z
R 2?"! 358 IF Z=9 THEN PRI
88 A$= ,<EY$ NT "END"" END
98 IF A$*M" THEN 369 ON Z-15 GOTO 45
IF AJ*'2" THEN 8,488
88 378 RESTORE
tee e=e+i 338 FOR H=l TO Z
398 READ V*
118 PRINT : BEEP 1 488 NEXT H
128 PRINT "X DATA": 418 PRINT V$;"="!A(
B?
138 INPUT X$: BEEP Z)
1 428 DATA N,SUMX,SUH
148 IF X$='En THEN X2,HEANX.SDX,SD
8=8-1: BEEP 8: XN,SUHY
4 3 8 DATA SUNY2,NEAN
GOTO 248
Y,SDY,SDYN,SUHX
158 oc+ mm) Y,LRA,LRB,C0R
168 0=D+ VRL<X*)t2 448 GOTO 348
178 IF A$="l" THEN 458 INPUT "Y DATA',
189 Y
188 PRINT "Y DATA": 468 PRINT "E0X=";(Y
B; -NVO
198 INPUT Y 478 GOTO 348
289 H=H+Y 488 INPUT 'X ORTR1,
210 !=HY*Y X
229 H=«+ Vfil(X$>*Y 498 PRINT •EOY=,;N+
239 SOTO 198 X*0
249 E=C/B 588 60T0 348
259 F= SQR((B*D-C*C
)/<B*(B-l))) Total 728 steps
268 G= S8R((B*D-C*C
>/(B*B)>
278 IF A*='l' THEN
340
280 J=H/B
298 K= S««B*I-H*H
)/(B*<B-l)))

-171-
CHAPTER 5 PROGRAM LIBRARY

• Variable contents

A Decision of use of one L A(11) Standard deviation of v data


variable or paired variables
B A(1) Number of data M A(12) (K)
Sum of products of data
C A(2) Sum of x data N A(13) Linear regression constant
term
D A(3) Sum of squares of x data O A(14) Linear regression coefficient
E A(4) Mean of x data P A(15) Correlation coefficient
F A(5) Standard deviation of x data V$ For output name
(Xa„ j)
G A(6) Standard deviation of x data W Used in a loop
(XfT )
H A(7) Sum of y data X For x data input
1 A(8) Sum of squares of y data Y For y data input
J A(9) Mean of y data Z For output selection
K A(10) Standard deviation of y data $ For KEY$ function

Let's utilize the program.


The following data is used as an example.

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 ?(

If new data input is required, press the H key.

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

After this, enter x and y data sequentially.

101 K'HTH IV
10031 --3TR 27
151
10051 )HTH 37

301 jftTfi 57
10141 )HTfl 67

After data input is completed, enter |T) (END) as a termination sign.

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.

(A) 131 :fl= 997. 4


I INPUT 0 3 - 1 7 ) ?
(B) 141 LRB= 0 . 5 6
I INPUT(8-17)7
(r) 151 COR- 0 . 9 8 2 6 0 7 3 6 8 9
INPUT03-17)

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

To enter data continuously, press (S after starting the program.

RUNI START ? < V / r


IS X D H I H b'?

Also, when one variable is to be used, it is as follows.

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

Code Number Table


Code e
1 Number of data (n) 10 Standard deviation of y (yan.,)
2 Sum of x(Lx) 11 Standard deviation of y {ya„)
3 Sum of squares of x (Ex2) 12 Sum of products of data (T.xy)
4 Mean of x {x) 13 Linear regression constant term
5 Standard deviation of x (xan.,) (A)
6 Standard deviation of x (xa„) 14 Linear regression coefficient (B)
7 Sum of y [Ly) 15 Correlation coefficient (r)
8 Sum of squares of y (Ly2) 16 Estimated value of x (x)
9 Mean of y (J) 17 Estimated value of y (y)

• 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.

Enter the data sequentially.


376SS
••".'

( b £ .-'

159SS ( 1, '~\"'! ?
248S3 ( 1, 4) ?

235I ( 5: f,) •p
492I END Data input termination.

-176-
2. CROSS TOTAL

Next, confirm the entered data.


Operation Display
8S F r i m e r [Y/ Nl? •To output to the printer, press Y.
N ( U 1) 376 • Each time I S is pressed, a data is dis-
played.
( 1, 2) 159
( U 3) 248

( 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

If a numerical value is entered when a data is displayed, the new numeri-


cal value releases old one.

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

U9 GRAND TOTr ••• The grand total is displayed last.


jU3 811325

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

28 K$= KEY$: IF K$ 28 PUT "SUTPX,? 28 SET "DfiTR'X.Y


= " THEN 28 38 PUT Z(1),Z(X*Y) 38 DEFH X*Y
38 IF K$='Y" THEN 48 PRINT "->EHD* 48 SET Z(1),Z(X*Y)
NODE 7 58 PRINT "+END"
53 steps
48 PRINT
58 PRINT "H. 10THL 60 steps
Total 1107 steps
68 FOR 1=1 TO Y
78 H=8
38 FOR J=l TO X
98 ft=fl+Z((!-l)*X+J
)
188 NEXT J
118 PRINT • ( M ; 1 ) "
:fi
128 NEXT I
138 PRINT "V, TOTAL
R

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

18 PRINT " CRR RflC 228 Z=Z+R:Y=Y+Q


E !"; 238 SOTO 68
28 BEEP 8: GOSUB 5 588 REM TIME
98 518 FOR U=l TO 188:
38 PRIHT 'HI-SCO:" HEXT I!
SSS'ltt"! 528 PRIHT
48 SOSUB 588 538 BEEP 8
58 X=;&:Y=J;Z=9:T=& 548 RETURN
:C=8 688 REM CRASH
68 PRIHT 618 FOR 1=1 TO 18
78 PRIHT CSRY;"1"; 628 PRINT CSRX;"*":
CSRX;"A"! CSRZ 638 BEEP 1
;"•"; 648 PRINT CSRX;"fi":
88 IF X= INTY THEH 658 HEXT I
GOSUB '688 668 PRIHT CSR8;"<<C
98 IF X= IHTZ THEH RASH !!»*;
GOSUB 688 678 GOSUB 588
188 T=T+1 688 PRIHT "SC0RE:"r
118 t- KEY* T*3:"ka":
128 IF $="4" THEH X 698 SOSUB 588
=X-1 788 X=6:Y=3:Z=9
138 IF $="6" THEH X 718 !>C+1
=X+t 728 IF C<3 THEN RET
148 BEEP 8 !JRH
158 R= RAMI*.9 738 T=T*3
168 IF RRNt>.5 THEH 748 IF T>S THEH S=T
R=-R 758 PRINT
1T8 IF Z+RM2 THEH 768 t="GflHE OVER !!
I
R=8
138 0= RHNt*.8 7?ft FOR 5=1 TO 12
198 IF RfiHD.5 THEN 788 PRINT MID$(I,1)
0=-Q " BEEP 1
288 IF Y+Q<8 THEH Q 798 HEXT I
-8 888 END
218 IF 2-Y<3 THEN 2 -r«*«i CAI~\ n*^n~

-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.

The car is close to the left fence. I1

When the car hits a fence, it crashes and the distance covered is displayed.

CR RSH i !
sc OR E: 4 51 (Yi

mes, the game is over.

CR RSH i i
C" r OR E: 2 54 km
!_j r* HE OUE : • i

-182-
4. BONBARPMENT GAME

In this game, an enemy submarine is destroyed by skillfully controlling a


destroyer navigating on the sea. The destroyer's sonar is defective, and
responds only when the submarine is directly under the destroyer. Also,
the depth is unknown, and the destroyer has minimum fuel. In this situa-
tion, the destroyer has to fight while escaping from enemy's torpedoes.

• 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

m BEEP 788 RETURN


528 IF fl<K)=X THEN 718 FOR 1=1 TQ 5
IF m.)= VRL<$) 728 PRINT CSR!1;"8*
THEH 658 •: BEEP 8
638 IF H(K)=X THEN 738 NEXT I
IF RBS(D«K)- m m RETURN
L«*)X2 THEN ?! 988 RE* DEAD
8 918 FOR 1=1 4) 18
648 RETURN 928 PRINT CSRX:ux"-
658 FOR 1=1 TO 18 : BEEP l: PRINT
668 PRINT CSRil;"*" CSRX;"*"-
" BEEP 1 938 NEXT I
678 PRINT CSRllJH" 948 L=L-1
;: BEEP 8 958 IF L<! THEN PRI
688 NEXT I NT : SOTO 388
698 fl«)=-!:R=R+ IN 968 RETURN
T( RflN#»5+l)*10
8:s=s+5« Total 999 steps

• 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?'

First, a destroyer and the range of movement are displayed.


1 : ; :
^ S £ £ 1 s:
ggj gn> aa: J. sis s= aas sn a n

' 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

+ and * turn on and off alternately.

When the depth bomb missed the submarine but was close (depth is ±1),
the sonar response changes.

n£ infi tns nut 9E ^L &tts 9us tut S H •£ *•

^
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

A torpedo is shot (T and * turn on and off alternately)

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 !

A torpedo hits the destroyer


( * and x are turned on and off alternately)

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

368 PRINT "SCORE:*: 168 PRINT CSR8;"! ?(•.

18 FOR 1=1 TO 18:


370 IP P<E THEN P=E ;79 PPIHT tm-'il'- BEEP l: BEEP :
: SOSUB #6 188 Z-Z+l NEXT I
388 V=B: GOSUB 19 198 B*= KEY* 28 RETURN
398 IF E<7 THEN 18 298 IF P*i"9" THEN 22 steps
48ft PRINT "NEXT SfiH TF R*i"0" THEN
E 9"; M=;; REE? 1.: PR
418 IF KEYt=" THEN INT r:SRX;V: 18 PRINT i PRINT "
418 218 IF FRflC(Y/4)-8 FOUL !!"'" PEEP
J BEEP
428 GOTO 12 THEN X=X+1" IF
H*i THEN Z=Z+3= 29 IF K=8 THEN K=l
456 steps
SOSUB 17 : RETURN
n 229 IF H*i"Z" THEN 38 SOTO #8
18 t=* ! I IF P$i"R" THEN 39 steps
! I 1":X=»: X=X+i: BEEP
K-8:Y=2:H=8:Z=8 238 H=8 18 PRINT
28 PRINT : PRINT " 248 IF X<12 THEN 16 29 $="SHHE OVER !
HI-SCO":0;'s"; 9 li

38 V=R: SOSUB #9 258 BEEP : PRINT 39 c 0R T Z , T0 12


48 BEEP 1 48 PPINT «IDt(I,l)
268 F= RND(Z/l.l,-2
58 IF KEY**"" THEN } :: BEEP
SOSUB *?: SOTO 58 NEXT I
278 PRINT "TIHE:":F
38
68 pRINT CSR8: HID
288 IF 0=8 THEN 0=F
$CM1>;
298 IF F<0 THEN 0=F
78 PRINT CSRX:"8"; : GOSUB »6 ;M FOR U=! ;0 V! N
88 Z=Z+1 388 SOSUB #9
98 8$= KEY* 29 PRINT
318 IF F>68 THEN #8
188 IF m * V THEN 328 R= !NT( C0S(0*3
39 RETURN
IF R$i"8" THEN 50 steps
)*288+ SIN(E*3)
H=t: BEEP !: PR
•288+ C0S(F*3>*
INT C S M * V ; Total 1533 steps
288)
i|H IF Y=! THEN Y=Y
338 PRINT "TOTAL SC
+l: IF H*l THEN
ORE":R;" points
Z=Z+3: SOSUB I
348 IF T=« THEN T=R
128 IFfi*4"Z"THEN 358 IF T<R THEN T=R
ip Hfi'R" THEN
: 60SUB 16
V=VtlHWHls BE
603 steps
138 IF Y>4 THEN Y=l P 0 : 100 m e t e r r a c e P6 : Beep sounds
148 H=8
P1 : B r o a d j u m p P7: Foul processing
158 IF I4<38 THEN 68
P2 : Hurdle race P8 : Game over processing
P9 : To stop the execution for
a certain period of time

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

Runner Take off position

The speed of the runner is increased by pressing a key from B t o d ) .


Although the runner advances even if a key is not pressed, the jump results
in a failure. When the runner has reached the take off position, press a
key from EltotS). Since the jumping angle is changed depending on the
period of time in which one of these keys is pressed, the key depression
must not be too short or too long.

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

After several hurdles are jumped, the goal can be seen.

Goal

If you start before the runner is displayed, or if a hurdle is knocked down,


a foul occurs which is allowed only once.
If the elapsed time exceeds 60 seconds, you are disqualified and the total
score is not displayed.

• 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

• Number of steps are insufficient. • Clear unnecessary programs


Memory over-
Program cannot be written. or reduce the number of
flow or opera-
memories.
1 tor level
• Operator level overflow • Divide the formulas and make
overflow.
them simpler.

•Format error in program, etc. • Correct error in input program,


• Left-hand and right-hand formats etc.
2 Syntax error
differ in an assignment statement,
etc.

• The result of a numerical expres- • Correct the calculation formula


sion calculation exceeds ±1 x or data.
Mathematical 1 0 100
3 error • The argument of numerical func- • Verify the data.
tion is outside the input range.
• Result is indefinite or impossible.

• No designated line number for • Designate the line number.


GOTO statement or GOSUB
statement.
Undefinition
4 error
• A READ or READ# statement is • Check the relation between the
executed when there is no data READ and DATA statements.
to be read. Create data in the statement to
be assigned to the variable.

• For a command or function that re- • Correct the argument.


Argument
5 error
quires an argument, the argument
is outside the input range.

• Attempt was made to use a • Expand the memory properly.


memory which has not been ex-
panded.
6 Variable error • Attempt was made to use the • Do not use the same memory
same memory for a numerical vari- for a numerical variable and a
able and a character variable at character variable at the same
the same time. time.

• RETURN statement is executed • Remove unneeded RETURN


when subroutine is not being exe- statements or NEXT
cuted. statements.
7 Nesting error • NEXT statement is executed when • Keep the subroutines or
not in FOR loop. FOR-NEXT statement loops
• Subroutine nesting levels exceed 8. wihtin required levels.
• FOR-NEXT loop nesting levels ex-
ceed 4.

-192-
6-1. ERROR MESSAGE TABLE

Error
code Meaning Cause Corn -,ure

• When the password is specified, • Cancel the password error by


a) another password is specified. entering the correct password.
8 Password b) a command such as LIST or
NEW which can not be used is
executed.

• SAVE or PUT command was ex- • Connect a tape recorder.


ecuted without a tape recorder be-
ing connected.
• Input signal used by LOAD or GET • Lower the tape recorder
command cannot be read. volume.
9 Option error • Set the tone control of the tape
recorder to middle position.
• Replace the tape.
• Clean the tape recorder heads.
• Printer battery is weak. • Charge the battery.
• Printer paper jammed. • Unjam the printer paper.

6-2. CH R CODE TABLE


n
SPACE +
- * / t / # $ > 2: = < < %
Numbers 0 1 2 3 4 5 6 7 8 9 • 71 ) ( E E
Capital B C D E F G H I J K L M N 0 P
letters Q R S T U V W X Y Z
Small a b c d e f g h i J k 1 m n o P
letters
q r s t u V w X y z
Symbols ? t 9 •
Graphic 2 o A @ X -f- * «- V • + M Q i -»
symbols
% ¥ 9 •' ] \

[ & _ •
The characters and symbols in the above table are lined in sequence, with
SPACE being the smallest and " \ " being the largest. ( " V ' c a n be displayed
by pressing 8 0 . )

-193
6-3. I LS

Symbol Meaning

r
(
> Entry or exit point
(start, return, end, etc.)
)

Data input from the keyboard

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

o Transfer or continuation point

-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

This table indicates the relations between variables.


Example) H( 0 ) ~ H ( 9 ) ^ H ~ Q

-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®

026G SA ® F rinted ir Japan

You might also like