142
The
VIC
20
User
Guide
process. Back
at
line 100, the integer variable EDITING% was set to
O.
At
the end
of
each statement group, the logical test
of
EDITING% would cause
program logic to fall through to the next group. Now that EDITING%
is
nonzero (equal to
-1),
program logic can randomly access each statement
group, thus allowing each entry line to be changed in a random fashion.
Lines 520 through
540
call the "yes-or-no" subroutine; if the operator
enters N in response to ANY CHANGES?, the program ends.
If
the opera-
tor
enters
Y,
program logic continues.
Lines
570
and 580 set variables for the numeric entry subroutine, and
line 590 calls it. The subroutine returns the number
of
the entry line to
change
(1,
2,
3,
4,
5,
or
6)
in the integer variable NM%, and program logic
proceeds to line 600.
The ON-GOTO statement on line 600 uses the number entered in NM%
to change one
of
the six name-and-address lines by branching back to any
of
the six statement groups. EDITING% plays a critical
part
here, because the
logical test
at
the end
of
each statement group will now cause a branch
directly to line 500, which
is
the start
of
the ANY CHANGES? routine.
If
EDITING% was zero, this would not happen. Program logic would plod
along to the next entry line unconditionally. Try changing line
510
to
EDITING%
= 0, and note the difference in operation.
DATA
ENTRY
SUBROUTINES
There are six subroutines in this program. Each subroutine has a
specific function. One
of
the subroutines
is
not used by the main program,
but
is
called by the other subroutines.
First look
at
the subroutine starting
at
line 3000
and
ending
at
line 3060.
This asks a question that requires a Y
or
N response. The subroutine
displays the question which was passed to it in string variable QU$.
It
calls
the subroutine
at
line 5000, which in turn gets a character from the key-
board.
If
the character
is
Y
or
N, the subroutine ends and returns the
response in C$.
3000
REM
ASK
A
QUESTION
AND
RETU~N
A
~ESPONSE
OF
V
OR
N
IN
CI
3020
PRINT
QUI;
3030
GOSUB
50e0:REM
GET
A
CHARACTER
3840
IF
C'(>"V"
AND
CIO""'''
THEN
3030
3858
PRINT
el;
3068
RETURN