Goto; For/Next; Read/Data/Restore; Gosub/Return - Casio FX-890P Owner's Manual

Casio personal computer owner's manual
Table of Contents

Advertisement

and assigns a value of 5 to N when the original value is greater. When a value of 5 or
less is originally assigned to N, execution proceeds to the next line, with N retaining
its original value.
Line 50 checks whether or not value assigned to N is zero. In the case of zero,
program execution jumps to nine 130, while execution proceeds to next line (line 60)
when N is any other value besides zero.
Note: Line 50 can also be abbreviated as follows:
50 IF N=0 THEN 130

5.5.6 GOTO

The GOTO command (lines 50 and 120) performs a jump to a specified line number
or program area. The GOTO statement in line 120 is an unconditional jump, in that
execution always returns to line 10 of the program whenever line 120 is executed.
The GOTO statement in line 50, on the other hand, is a conditional jump, because
the condition of the IF-THEN statement must be met before the jump to line 130 is
made.
Note: Program area jumps are specified as GOTO #2 (to jump to program area 2).

5.5.7 FOR/NEXT

The FOR/NEXT combination (line 60 and 90) forms a loop. All of the statements
within the loop are repeated the number of times specified by a value following the
word "TO" in the FOR statement.
In the example being discussed here, the loop is repeated N number of times, with
the value N being entered by the operator in line 30.

5.5.8 READ/DATA/RESTORE

These statements (lines 50, 180, 20) are used when the amount of data to be
handled is too large to require keyboard input with every execution. In this case, data
are included within the program itself. The READ command assigns data to
variables, the DATA statement holds the data to be read, and the RESTORE
command is used to specify from which point the read operation is to be performed.
In the program example here, the READ command reads the number of data items
specified by the input variable N. Though the DATA statement holds only five data
items, the RESTORE command in line 20 always returns the next read position to the
first data item, the READ statement never runs out of data to read.

5.5.9 GOSUB/RETURN

The GOSUB/RETURN commands (line 100 and 170) are used for branching to and
from subroutines. Subroutines (lines 140 to 170) are actually mini programs within
the main program, and usually represent routines that are performed repeatedly at
different locations within a program. This means that GOSUB/RETURN makes it
possible to write the repeated operation once, as a subroutine, instead of writing
each time it is needed within the main program.
Execution of the RETURN statement at the end of a subroutine returns execution of
the program back to the statement following the GOSUB command. In this sample
program, execution returns to line 110 after the RETURN command in line 170 is
executed.
34

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Z-1grZ-1

Table of Contents