Page 1

agvanced
programming
techniques
on
powerful
david
the
commodore
ideas
lawrence
and
applications
64
Page 2
Page 3

aovanced
programming
techniques
on
powerful
david
the
commodore
ideas
lawrence
and
applications
64
Page 4

First
published
Sunshine
12-13
Little
London
WC2R
Books
Newport
1983
(an
3LD
by:
imprint
Street,
of
Scot
Press
Ltd.)
Reprinted
1984
Copyright © David
ISBN 0 946408
All
rights
in a retrieval
electronic,
the
prior
23
8
reserved.
system,
mechanical,
written
permission
Lawrence
No
part
of
.or
transmitted
photocopying,
of
the
this
publication
in
recording
Publishers.
any
may
form
and/or
be
reproduced,
or
by
otherwise,
any
stored
means,
without
Cover
Design
Illustration
Typeset
il
and
by
Graphic
by
Stuart
printed
Design
Hughes.
in
England
Ltd.
by
The
Leagrave
Press
Ltd.
Page 5

CONTENTS
Page
Notes
Introduction
1
2
3
4
5
6
7
8
9
on
Program
Modular
Debugging
Strings
Inputting
Error
Storing
Logical
A
Data
Trapping
and
Conditions
Jungle
Structures:
Listings
Programming
Information
Retrieving
of
Sorts
I
1X
1
3
17
2/
41
53
65
79
93
111
10
Data
11
Inserting
12
Odds
13
Formatting
Postword
Structures:
Data
and
Ends
II
127
141
149
159
171
Page 6
Page 7

Contents
in
detail
CHAPTER
Modular
A
guide
planning
hints
and
CHAPTER
Debugging
Information — single
—
interpreting
CHAPTER
Strings
Concatenation
into a string — moving
—
regular
variable
CHAPTER
Inputting
Entering
of
several
GET — GET
—
GET
with
GET — simple
1
Programming
to
writing
the
program — writing
tips.
programs
2
error
messages.
3
or
string
string
structures — multiple
length
strings — garbage
4
Information
information:
items
using
and
creating a waiting
and
timed
responses — GET
screen
that
work — defining
the
modules — entering
line
error
messages — non-obvious
addition — string
items within a string — searching
collection.
INPUT — simple
the
same
screen
editing
using
subtraction — inserting
element
entries
line — INPUT
state — moving a cursor
and
inverse
INPUT.
string
with
boxes — screen
your
program
the
program
error
messages
items
within
arrays — data
INPUT — INPUT
to
screen
strings
boxes
with
editing
GET
—
—
in
—
CHAPTER
Error
Trapping
Avoiding
common
5
errors — error
sense
error-trapping — DIY
trapping — setting
error
messages.
limits — garbled
entries
—
Page 8

Advanced
Programming
Techniques
CHAPTER
Storing
Saving
to a file — loading
disk.
and
programs — saving
6
Retrieving
from
CHAPTER7
Logical
The
IF — IF...
AND
conditions — setting
the
—
with
odd
CHAPTER
A
The
the
Sort.
Conditions
humble
value
multiplying
numbers — POKE
or
IF — protecting
THEN...ELSE
and
OR
of a condition — using
and
even?
8
Jungle
of
whys
Bubble
Sorts
and
wherefores
Sort — the
—
combining
dividing — avoiding
and
loading
tape
—-
against
—
IF
limits — IF
with
AND
of
sorting — the
Delayed
data — saving
Save
and
illegal
with
>,<
AND
and
with
NOT — using
conditions
isolation
and
OR — storing
Replacement
to
tape — printing
Load
routines — variations
values — errors
and = —
OR
Bubble
IF
with
—
unpacking
logical
as
values — plus
by
IF — AND
with
Sort — programming
Sort — the
Shell-Metzner
for
arising
the
conditions
AND/OR
from
operators
complex
—
or
minus?
and
OR
—
CHAPTER
Data
Structures:
Simple
numbers
in
strings
CHAPTER
Data
Linked
problem.
CHAPTER
Inserting
Normal
searching
data
strings — stacks — string
using
Structures:
lists — pointer
9
I
structures — data
in
integer
numeric
Data
search and
with
arrays — storing
10
IT
|
11
shift — binary
pointer
array
arrays.
structures
directly
data
structures — packed
pointers.
strings — deleting
searching — pure
for
numbers — single
in
free
with
pointers — the
byte
memory — numbers
strings — packed
black
hole
searching — binary
Page 9

CHAPTER
Odds
and
User
defined
—
timing
12
Ends
functions — terminating
with
TI
and
TI$ — rounding
FOR
with
loops — DATA
INT.
statements
CHAPTER
Formatting
Cursor
simulating
controls — use
PRINT
13
of
cursor
USING — justifying — easy
control
characters — TAB
logos
and
designs.
—
SPC
—
Page 10
Page 11

Notes
For
the
follow
have
on
program
sake
been
of
clarity,
set
listings
control
out
as
follows:
characters
in
the
program
lines
whicly
CURSOR
UF
CURSOR
CURSOR
CURSOR
CLEAR
HOME
SCREEN
CURSOR
REVERSE
REVERSE
Colours
control
are
represented
character
[YELLOW
J
Where a number
instance:
DOWN
LEFT
RIGHT
ON
OFF
for
yellow
of
by
the
1s:
control
colour
name
characters
in
are
required
square
CCU
CCD
I
CCL
CCR
I
CCLRI
CHOME
CRV&S
CTRVS
brackets.
the
format
J
ONI
OFF
Thus
is,
J
the
for
rigsg*xCbDJ
Within
and
should
program
be
replaced
listings,
single
when
quotes
listings
are
are
used
entered.
in
place
of
double
quotes
Page 12
Page 13

Introduction
This
book
is
intended
is
not a collection
available
to
write a two
The
64,
of
The
the
only
problem
There
most
something
then
and
How
will
have
claim
in
book
to
those
uses
that
Working
era
when
for
games
is
is a lot
of
it
outputs
addresses,
the
information
simply
complex
to
give
how
that
that a micro
behind
go
it
deal
memory,
storing
What
on
alongside
is
more
with
can
likely
errors,
how
comprehensible.
application
how
they
can
The
complexity
chapters
single
objectives
and
that
line
like
complex
of
BASIC.
line
subroutine
is
dedicated,
who
want
are
normally
Commodore
people
is
over
to
design
of
is
bunkum.
allows
it
again
products
have
to
mathematical
guidance
can
store.
it.
be
done
the
to
work,
economical
to
sort,
The
will
be
made
be
achieved
of
follow
of
program,
aligning
routines
to
be
unlike
programs,
It
is
not a collection
to
like
to
set
termed
64,
were
happy
for
good.
the
programs
mystique
An
the
input
in
some
and
needs
to
be
stored,
on
all
the
It
depends
Is
to
give
core
of
the
how
how
lion’s
share
up
of
economically
the
material
you
will
two
the
decimal
to
allow
any
other
it
is
not
an
convert
its
their
Fahrenheit
predecessor
:micro
loose
‘applications
already
into
to
use
People
the
want
that
attached
to
applications
of
information,
useful
way.
The
prices,
some
procedures
financial
be
processed
sorted
different
on
some
guidelines
program.
to
debug
and
fast
to
format
of
such
things
performed
ways
the
How
it,
ways
output
the
and
and
in
this
book
find
many
techniques
or
three
line
points
data
to
be
inserted
you
have
introduction
of
trivial
routines
to
Centigrade.
The
Working
on
useful
programs’.
its
fourth
edition,
power
will
applications
program
of a micro-computer
to
set
micros
do
it.
programming
is,
Stores
it,
information
records,
is
also
the
infinitely
into a desired
on
to
process
information
for
the
processes
to
design a program
how
to
accept
to
put
information
so
that
programming
this
book
sets
successfully.
varies
immensely.
which
routines
on a series
of
into
to
numbers,
large
on
your
shelf.
to
the
commands
such
as
Commodore
tasks,
the
The
success
shows
to
work:
at
its
simplest,
processes
may
be
names
list
1s
endless.
varied,
order,
some
it.
No
book
the
information
and
the
purpose
that
so
information
into
it
is
clear
for
any
serious
out
to
explain
In
require
achieve
arrays
only
simple
lengthy
at
how
kind
that
the
and
it
and
some
will
can
will
that
and
the
and
the
high
It
of
a
Page 14

Advanced
Programming
Techniques
speed.
intended
They
to
are
be a book
techniques I use
common
not
The
seen
book
themes
used
to
does
and
good
micro-computing.
own
right.
Of
course
but
only
as
much
you
want
to
go
Kosniowski’s
Apart
from
information
again a specialist
My
thanks
like
this
are
also
Master,
our
next
and.
Tom
sometimes
a
rock
on
I
hope
I
hope
that
some
light
all I hope
programming
tools
but
new
what
the
book
area
go
to
one: I hope
due
to
Mark
for
waiting
book
together.
for
understanding
be
more
which
everything
that
the
it
is a book
on
the
it
is a book
and
when
you
all
included
of
theory.
myself
and
methods.
advantage
not
attempt
That
is a specialist
there
is a little
as
is
absolutely
further
book
is
all
it
into
for
necessary
does
not
ofits
own.
the
readers
is
at
least
England,
so
patiently
Finally,
important
else
final
product
you
will
inevitable
that
will
it
will
have
put
them
to
because
What I have
at
the
There
in
to
they
are
tried
work
of
other
is
nothing
solving a particular
deal
with
the
area
worthy
bit
of
mathematics
necessary
to
make
mathematics I suggest
the
64,
Mathematics
to
obtain a clear
attempt
who
partly
co-author
for
that
than
can
is
come
problems
give
done
new
have
what
this
and
most
sitting
playing
be
built.
worth
back
you
its
job not
uses.
to
deal
encouraged
they
of
Commodore
to
be
finished
importantly,
in
front
and
all
the
encouragement
to
time
that
programming
ideas.
when
with
to
useful,
to
do
for
is
people
in
the
book
problem.
use
of
mathematics
of
at
least a book
from
something
you
on
the
Commodore
and
attractive
graphics
me
to
were
hoping
64
Machine
before
thanks
of a computer
my
wife
Jane
and
time
brings.
It
is a book
you
understand
this
is
not
to
look
at
the
and
to
find
that I have
in
time
to
time
work.
buy
Czes
64.
display
techniques,
write a book
for.
Thanks
Code
starting
to
Barny
can
for
being
and
help.
again
to
shed
Most
of
tools
for
those
in
its
If
of
on
of
Page 15

CHAPTER
1
Modular
A
guide
It
may
to
begin
problems
why
this
micro-owners
more
of
understanding
approach
The
and
in
that
sections.
in
that
whichever
programming,
philosophy
we
are
computer
In
a
successful
before
to
seem
strange,
with a chapter
of
program
chapter
aware
that
to
the
technique
my
own
means
Most
form.
of
of
really
programs.
this
chapter
program,
you
ever
Programming
writing
is
included.
who
are
often
of
actual
of
programming
programs
writing
of
the
They
your
however,
programming
talking
we
touch
programs
in a book
which
style
and
writing
the
how
the
task
of
is
called
programs
practical
can
be
own
programs
goes
about
shall
discuss
steps
the
keyboard
As I deal
only
putting
lifted
style
is
which
about
techniques
is
not
so
layout.
their
own
thing
BASIC
BASIC
that I always
‘modular
which
examples
from
that
much
further
and
if
applying
some
begin,
of
your
that
work
of
BASIC
much
about
BASIC
There
is,
however, a simple
with
questions
programs, I become
holding
language
are
the
that
common
them
back
works
to
work
in a program.
use
myself,
programming’.
made
up
given
in
this
page
and
might
of
or
64.
than
sounds
the
steps
at
least
need
that<
too
sense
involved
should
programming,
but
about
and
problems
more
is
not
the
but a confused
both
in
At
its
simplest
of
self-contained
book
are
written
grafted
It
easily
them.
implies a whole
grand
to
then
the
writing
begin,
Modular
in
writing
the
reason
from
and
lack
books
into
what
of
long
Defining
The
worst
enthusiastic
full
of
practice.
put
the
instance,
space
something
then
something
(which
of
course
your
programs
about
confidence,
If
they
core
that
in
the
is
added
always
there
program
before
they
know
of
the
program
there
program
to
to
deal
happens
have
that
rush
what
is
no
or
take
with
when
to
be a few
anyone
they
start.
to
the
they
into
way
of
tag
onto
account
invalid
someone
ever
writes
They
keyboard
are
doing
working
properly
the
end a routine
of
the
inputs
else
lines
added
are
get
an
idea
and
then
order.
inputting
need
to
which
would
gets
their
to
store
the
ones
into
try
to
put
they
quickly
Then
data
remove
crash
hands
some
that
their
head
the
vision
manage
they
realise,
so
they
to
do
that.
incorrect
the
on
data
they
are
and,
into
for
find
Then
items,
program
it).
Then
on
tape.
to
a
Page 16

Advanced
Then
program
instructions.
disorderly
everywhere.
By
Programming
there’s
the
so a better
Then
the
end
line
When
much a problem
a
process
The
but
When
you
crossed
a
successful
A
central
addresses.
information
of
making
it
must
of
these
the
Even
to
want
Do
want
to
cover
year
to
handle
up
Do
every
All
A
couple
need
that
actually
you
world
The
write
able
It
will’
that
best
programs
don’t
really
you
are
sit
down
and
the
first
program.
program
task,
It
is a complex
and
clear
allow
corrections
tasks,.and
routine
at
its
when
accomplish
to
calculate
you
want
to
to
allow
for
and,
if
to
year
(or
‘what
by
78.70
per
you
want
to
time
you
these
are
questions
of
hours’
to
know
seemed
perfectly
think
to
write
something
are
full
of
first
task,
down
in
to
do.
Once
seldom
can
Techniques
problem
there
of
the
numbers
that
of
identifying
take
want
not
confident
think
and
in
does
not
like
calculating
the
proper
the
way
many
core.
you
consider
it,
the
your
be
able
expenses
it
is
more
even
if’
questions
month’,
be
able
run
the
thought
before
the
purposes
programs
then,
plain
English
that
seem
that
no-one
‘menu’
has
is...
process
the
program
and
tangled
inevitable
bug
what
days
or
even
weeks.
are the
to
about
many
first
tax,
or
don’t
that
the
ways
simply
of
functions
display
in
which
to
be
more,
only
idea
but
to
look
to
be
ones
really
you
task.
the
consist
tax
or
of
it
is
made
are
the
that
what
at
the
deducted.
than a year,
during a year).
like
‘what
without
to
program.
store
affecting
the
information
Is
your
which I include
and
you
you
can
sit
down
obvious
in
is
as
when
of
the
program
that
works
that
work
but
writing a program
what
it
done,
leave
perfect
on
else
to
be
GOTOs
is
encountered,
it
is
as
one
that
people
know
can
write
The
moment
most
of
the
storing
which
that
information,
to
be
used,
if
incorrect
just
as
central
central
you
have
do
you
want
effect
How
what
happens
Do
you
would
the
spouse’s
‘off
the
could
fill a page
and
it
first
but
discarded
are
not
is
that
it
for a while
the
second
understands
added
consists
and
of a dog’s
pointing
of
discovering
know
they
how
to.
The
the
program
you
important
method
must
data
cope
it
must
hurdle
of
files
information
to a useful
task
and
the
is
seldom
to
include
of
different
long a period
if
tax
want
the
program
happen
data
or
you
will
if
have
you
income
top
of
my
with
begin
to
program
occurred
through
may
cassettes
really
useful.
is
to
sit
down
you
want
the
and
examination,
how
to
use
perhaps
some
dinner
here
there
it
becomes
not
where
have
to
reason
do
1s
you
want
that
you
in
designing
simple.
accomplishing
of
names
with
the
input
it
must
be
capable
deal
with
errors,
is
input.
program
lines
necessary
the
best.
So
in
that
ability.
tax
rates.
Do
do
you
rates
vary
to
be
my
income
already
put
to
head’
the
input.
it
in
afresh
be
included.
as
it
things
were.
something
to
you.
Failure
well
still
allow
all
over
and
think.
program
come
back
to
to
so a few
the
of
and
so
it
is,
write
then
have
its
and
of
All
as
you
you
want
from
able
went
you
to
the
To
be
it.
4
Page 17

Chapter 1 Modular
Programming
functions
be
into
to
convince
have
really
it
doesn’t.
if.
The
specification,
may
things
More
wanted.
you
Planning
Planning?
you
have
exactly
done
be
into
This
defining
processing,
comes
out
The
into
always
units
to
programs
shorter
together.
properly
by
different
Take
display
figures
are
used
by
account
written
like
conclusion
be
that
will
often,
It
will
come
haven’t
been
as
the
task
done
on
units
which
is
probably
the
the
of
which
rule
separate
to
go
is
always
the
inevitable
than
you
the
of
to
two
aligned
will
be
someone
what
your
is
it
to. A program
If1t
doesn’t
plan
when
have
you
is
the
back
the
Hasn’t
even
defining
you
want
properly,
the
broad
storage
more
the
here
units,
together. A program
the
which
those
The
reason
will
parts
example
the
data
decimal
when
added.
else,
they
will
children
exciting
and
then
is
that
it
with
you
come
to
be
dropped
will
find
programs
to
time
program
that
already
been
thinking
is
an
it
performed.
to
64|The
the
64
can
best
areas
and
complex
program
is
to
split
even
easiest
process
are
properly
where
for
find that
of
the
program
of
you
places
the
figures
If
you
are
however
expect
that
infrequently,
it
the
brilliant
enjoyable,
either
does
you
have
you
should
far
more
to
the
for
lack
that
you
which
cover
and
time
been
about a computer
ideal slave.
what
you
task
nowlis
handle
done
so
one
will
the
and
as a two-stage
of
the
on.
Once
of
identifying
be
built
functions
if
that
means
which
to
write
and
of
debugging.
divided
all
the
program
this
is
that
certain
our
will
functions
in
different
hypothetical
need
to
and
in
are
printed
writing a program
then
to
do.
It
is
no use
new
educational
if
it
doesn’t
what
people
wasted a great
always
than
the
detailed
of
memory
can
write
all
the
deal
overdo
basic
necessities
planning
or
the
ground
again.
covered?
Something
You
know
to\break
which
have
how
you
Well
that
paid
to
up
your
can
no,
no
do,
program.
process.
program,
that
like
fairly
simple
the
actual
input,
up.
of
the
program
splitting
is
strictly
always
into
functional
functions
divided
the
In
addition,
easiest
functions
if
you
break
are
used
places.
tax
program.
write a little
such a way
that
routine
all
in a column
which
is
you.
must
whatsoever
program
do
what
they
want
and
of
time
your
in
and
writing,
lack
of
knowledge.
program
which
you
are
because
program.
will
perform a task
heed,
if
or
indeed
ideal
specification
The
first
output,
task
is
units,
or
as
far
as
which
into
when
paradoxically,
units
will
are
tightly
down
the
time
and
time
For
the
to
format
the
decimal
‘(see
Chapter
going
to
also
take
trying
you
would
expect
in
or
writing
program
mind.
It
some
really
the
ones
up
to
now
What
you
you
have
what
can
stage
is
data
achieved
modules,
possible
seem
functional
it
comes
often
be
packed
program
again
screen
the
places
13).
Page 18

Advanced
You
program
items
can
Programming
could
you
see
exactly
tag
with
would
input — you
Because
part
anywhere
That
in
repetition
function
often
be
of
the
may
the
back
you
added
you
program,
else
sound
happening
can
will
simply
Most important
programs
task
really
you
out
you
The
describe
‘In
this
data
errors,
the
data
In
identified
down.
end
Now
down
be
echoed
was
format
function
If
you
a
new
making
would
particular
search
As
where
of
writing
very
have
written
and
using
would
use a child’s
basic
each
section
should
ask
the
into
this
simple,
at
Go
through
up
with a list
comes
further.
to
correct.
routine,
mentioned,
were
item
room
find
item
routine
with
the
few
technique
be
the
least
ordering
would
out
Techniques
the
three
no
problems.
like
to
what
is
would
have
embedded
and you
ludicrous
of
computing
be
accessed
find
that
by
calling a series
of
every
subsequent
important
them
them
to
aspect
of
of
the
program I want
input,
accept
user
to
correct
relatively
five
all
of
of
functions
the
task
For
instance,
the
screen,
If
you
want
as
discussed
inserting
items
involve
for
the
new
when
which
will
is
tied
up
overall
program
or
four
line
routines
However,
display
being
like
there
have
them
deleted.
to
echo
your
is
no
to
write
but
it
little
way
it
look
magazines
all
the
time.
In a properly
from
anywhere
in a properly
all
in
the
separate
programs
written
of
functions
long
term,
function
is
techniques
into a program
assemble
construction
for
the
confirm
place
further
toy.
achieving a properly
program
data
that
in
the
to
from
this
memory.’
non-technical
functions
the
of
identifying
presumably
later
with
and you
broad
which
we
mentioned
to
format
above.
the
in
alphabetical
first
searching
item.
These
you
be
recalled
lines
that
program
look
the
for
that
Another
data
want
and
areas,
onto
then
you
in
the
same
The
same
to
the
screen
formatting
that
you
again
each
at
the
kind
and
you
in
the
program
in a new
once
is
clearly
enormously
in
serious
you
will
find
programs
yourself:
to
give
instructions
the
user,
check
is
the
data
sentence
should
areas
sufficient
functions
earlier
the
user
display
example
into
the
correct
or
date
for
the
are
two
different
to
allow
displayed,
also
insert
go
through
the
output
find
that
when
format
goes
so
that
when
in
formatted
something
routine
can
actually
time
you
of
programs
will
written
program.
new
use
need
find
that
program
Indeed,
capabilities
order.
you
have
three
identified,
simplified.
programming
yourself
with
structured
the
lifting
same
program
about
the
data
intended
immediately
in
this
to
provide a program.
which
that
to
confirm
then
order,
correct
the
only
an
item.
each
and
you
have
write
way
and
could
the
input
that
there
has
would
place
in
then
place
processes,
user
to
to
find
of
your
part
of
the
deleting
the
user
form.
in
another
it
from
it.
published
kind
of
every
very
can
or
four
then
the
There
are
and
once
them
ease
that
is
to
the
way
for
certain
then
put
already
them
you
will
be
broken
would
the
input
to
be
be
the
last
memory.
inserting
and
then
as
you
specify
that
your
program
is
a
a
Page 19

Chapter 1 Modular
Programming
functions
or
three
you
At
which
want.
it
will
problems
would
a
substitute
‘Switch
I
want
If
all
eventually
Writing
By
keyboard
place
a
piece
will
can
model
you
but
and
describe
distinct
have
identified a candidate
the
end
of
you
think
You
will
have a picture
be,
the
sort
with.
As a final
like
to
be
for
the
on,
RUN
to
enter
data,
1s
well,
your
will.
the
now,
the
temptation
is
almost
to
write a computer
of
paper.
make
up
the
be
entered.
of
each
of
when
you
come
they
will
probably
itself.
Probably
detail
matter
owners
known
daunting,
has
become a technical
programmers
complex
will
look
In
writing
the
is
the
use
how
much
seldom
if
as a ‘program
and
indeed
to
beast
but
something
an
input
them
to
yourself.
actions
this
your
able
for a particular
process
64
will
of
structure
check,
to
perform
for
you
need
of
the
it
run
with
further
should
might
64:
(whoops
confirm
notes
no
menu
entry,
should
modules
to
reach
for
irresistible,
By
this I don’t
program
This
is
the
the
separate
to
enter
not
best-known
of
flowcharts.
computer
ever
use
development
in
the
understand,
to a straightforward
like
the
module I might
but
program
mean
must
be
stage
at
program
each
be
anywhere
method
The
professionals
them.
More
hands
of
tool
which
let
alone
finished
If
you end
function
then
division.
end
up
with a list
in
order
to
execute
whole
program,
have,
the
through a few
your
program,
to
tell
me
what
enter
another
function
the
64
the
time
is
on a computer,
that
noted
down
which
functions.
function
near
of
developing a program
problem
item.....
almost
and
start
is
still
every
line
perfectly
you
need
These
as a module
as
detailed
with
advocate
realistic, I think,
language’
many
is
use. I am
mix
module
end
high
very
up
with
of
but
or
PDL.
power
difficult
not
BASIC
is
much
something
up
talking
it
is
possible
of
the
program
the
kind
areas
you
might
typical
operations
using
it
does),
,
as
well
banging
not
right.
the
best
of
the
BASIC
your
specify
as
away
place
before
to
design a working
models
of
the
as
the
such
charts
their
use,
is
to
use
This
may
programmers
for
most
referring
and
English
quicker
like
about
two
that
functions
you
of
length
have
you
notes
as
that
your
64
at
the
The
worst
is
on
which
anything
will
guide
program
module
in
some
is
that
no
micro
what
sound
PDL
BASIC
to
such
which
to
write.
this:
is
a
HH
FRINT
PRINT
CTITLES
CCOMRANDS
AVATLABLET
NEW
ITEM/QUIT
Page 20

Advanced
%%
INFUT
IF
Programming
‘AMOUNT’:
TA
=
Techniques
—-9999
TA
THEN
RETURN
GOSUB
IF
ERROR
ERROR
[INFUT
GOSUB
CLEAR
FRINT
INFUT
GOUSUB
GOSUB
GOTO
FORMAT
FROM
TDO#s
“CORRECT’s
FLACE
DATA
+4
[TVARTABLES
VARIABLES
TA=temporary
TD$=temporary
USED:
Q$=temporary
FRMAT$=formatted
CHECK
GOTO
“Zz
“DESCRIFTION’:
MENU
°s
“sg
FRMAT#
SEARCH
INSERT
REQUIRED:
storage
storage
for
amount
for
description
input
amount
provided
DOWN
@¢
TD#
=:
’N’
noned
by
format
GOTO
routine
“%
Written
to
Notice
as
to
it
have
and
description
but
a
8
in
this
kind
do
and I have a perfectly
that I have
describing
the
display
to
the
to
menu
final
be
cleared
are
them
of
entry
to
of a procedure
know
is
soluble
note
can
be
made
of
form I can
spelled
items
be
in
English.
on
of
the
if
the
printed
some
the
item
with a little
next
to
see
exactly
clear
idea
things
out
Other
functions,
screen,
module
in.
it
is
to
decide
has
to
be
Sometimes I may
that I can’t
thought
the
line
and a supplementary
what
how I am
in
full
especially
easier
just
how
re-input
see
at
the
and
experiment.
the
module
going
because
to
mention
many
or
what
well
include a one
moment
ts
to
program
it
is
just
those
lines
colour
how
In
these
sheet
intended
it.
as
short
referring
and
leave
of
display
the
title
line
to
write
cases
can
be
Page 21

Chapter 1 Modular
Programming
written
spell
writing.
are
put
know
since
also
the
it
for
and
containing
variables
variables
They
determine
are
either
storage,
cause
different
module.
mathematical
however, a method
enable
it
intended
All
and
later.
There
are
no
out
what
every
One
or
enough.
GOTO
the
note
names
comes
each
will
At
used
Clearly,
far
that
understandably
When I come
*****
the
number
line
number
that
the
of
other
to
entering
module,
note
the
the
program
the
end
of
required.
which
will
also
that I am
only
for
forgotten
can
have
chaos
if
times.
such a happy-go-lucky
Some
calculation
you
to
build
more
quickly
that
you
is
necessary
line
two
destinations
the
must
be
or
they
of
numbers,
line
labels
for
jumps
of
the
of
routines
the
program I shall
preferably a separate
location
functions.
listing
Some
be
used
not
the
duration
transferred
their
names
are
the
like
up a clear
than
should
is
to
by
adopting
partially
will
be
but
also
at
the
beginning
to
actually
forward
destination
the
destination
that I may
at
of
declared
to
make
duplicating
inadvertently
modules
and
this,
if
you
slavishly
recognise
line.
of
the
GOSUBS
or
the
top
you
will
these
will
before
up a list
names.
of
the
to
another
duplicated
approach
may
these I would
freely
adapted
picture
went
directly
copy
that a program
this
kind
enter
and
first
notice
module
of
because I haven’t
because
will
may
block
of
be
used
contain
the
the
of
it
of
lines
the
module
then
re-edit
Jumps
back
already
are
not
have
decide
of
at
each
of
that
there
used
to
the
module
of
variables
Temporary
and
variable
in
other
modules.
for
different
will
one
spell
out
to
your
program
to
the
style
shown
can
approach.
would
such
as
on
the
will
be
known.
not
specified,
written
upon a block
least
the
separate
is a list
remind
can
variables,
whose
for
not
work
or
in
full.
own
and
keyboard.
in
be
written
attempted
slow
down
##
and
the
64 I shall
line
when
be
no
problem
You
merely
yet.
of
1000
for
me
be
called
so
that I can
contents
permanent
Others
purposes
for
two
lines
In
general
needs,
then
to
It
the
example.
quickly
to
the
%%
I
will
When
lines
each,
sheets
of
the
of
the
up.
which
are
will
at
every
of
will
enter
is
not
Entering
Now
you
can
to
enter
which
a
sheaf
of
notes
you
do
not
want
and
enter
it
Modular
of
programs
as
you
enter
the
program
turn
to
the
is
close
to a working
containing
to
do,
however,
straight
programming
as
they
each
through
are
module
64
in
the
the
various
is
to
the
lends
entered
than
confidence
program.
to
start
end.
itself
almost
and
it
to
track
that
Your
functions
at
the
beginning
|
perfectly
is
far
easier
down
errors
you
have
raw
materials
of
the
program.
of
the
to
the
to
debug a program
when
something
will
be
What
program
debugging
the
whole
Page 22

Advanced
Programming
Techniques
program
since
interacting
nevertheless.
which
purposes,
the
They
appropriate
could
the
you
done
and
exactly
one
without a line
(RUN
will
PLACE
Despite
everything
every
correct
entered.
The
program,
start
program
program
some
are the
In
the
case
presence
could
not,
ERROR
will
be
with
that
inputs
It
is
never
right.
or
two
would
have
and
these
error
since
result
to
finish.
will
is
running.
errors
with
In
and
of
of
simply
start
however,
CHECK
able
it
but
possible
You
variables
number)
wipe
to
enter
DATA
as
soon
you
there
of
but
there
without a single
have
Your
will
only
each
other
order
to
debug a program
modules
enter
the
the
them
input
SEARCH
be
lines
test
which
replaced
of
and
to
input
you
will
are
accepted
to
get
will
often
in
and
out
the
two
or
INSERT,
exceptions
as
possible
discover
is
is a 95%
all
this,
will
be
At
the
very
been
run
debugging
become
but
you
are
first.
module
PLACE
the
blocks
the
input
FORMAT
data
to
be
able
and
tested.
the
sequence
find
yourself
direct
mode
then
entering
variable
more
since
to
the
rule
after
going
to
chance
as I have
far
less
bugs
least
SYNTAX
before
will
apparent
can
save
most
often
listed
above,
by
two
they
module
routines.
your
heart’s
to
see
(eg
you
have
modules
they
you
you
be
relatively
that
said,
than
you
should
ERROR,
the
program
never
be
when
yourself a lot
as
you
go,
used,
it
could
or
INSERT
RETURN
will
eventually
without
Having
content.
that
the
screen
in
which
you
having
GOTO
will
should
have
to
LET
A$=‘TAX
the
just
entered).
together,
normally
always
entered
simple
it
is
in
the
is
not
going
if
you
were
end
since
is
completely
perfect
all
you
of
the
of
need
at
modules
heartache
to
probably
be
tested
DATA
statements
occupy.
having
first
entered
Nothing
display
enter
the
declare
the
REBATE’
start
of
the
Sometimes
such
as
SEARCH
work
in
attempt
it,
knowing
to
track
last
module(s)
to
be a bug-free
to
bash
away
up
with a complete
every
line
entered.
this
stage
are
identify
for
trivial
without
routines.
at
the
You
entered
these
two
will
be
is
clear
modules
value
of
routine
you
tandem.
to
test
that
down
and
you
from
of
the
Hints
Given
program
kind
of
1)
Programs
I
always
LHOG
14601
10
and
tips
below
are a few
in
modular
points
which
are
clearer
use a format
REM
REM
NAME
of
the
things
to
watch
form.
The
list
is
not
exhaustive
are
all
too
often
neglected
if
all
modules
such
as
the
HHH
HHRKEEEKHKEEKKKHEHEREHREEE
OF
MODULE
are
following:
given
out
in
micro
an
explanatory
for
when
writing
but
represents
programming:
heading.
a
the
Page 23

Chapter 1 Modular
Programming
LQH?P
This
when
2)
the
this
of
REMER
clearly
you
Having
heading
is
that
the
module,
come
UNDEFINED
The
position
make
to
the
3)
Do
decorate
statements
later,
when
you
took
the
take
several
4)
In
any
names
produce
which
above,
the
is
two
actually
during
make a program
some
are
also
FRMAT$
‘FOR’
that
it
is
letters)
the
the
HEHEHE
marks
out
the
back
to
the
put a heading
in
any
GOTOs
you
may
well
or
delete
LINE
errors
of
the
heading
main
body
of
your
program
whenever
you
little
hours
program,
you
want
to
extra
trouble
to
work
especially a substantial
interesting
the
start
of
has
the
at
the
beginning.
very
easy
to
duplicate
without
same
writing
realising
variable. This
stage
should
HRKRKRKRKRKHREKEHHKRERERKREKEEKE
module
listing
on a module,
want
the
the
do
modify
out
in
after
or
GOSUBs
to
add a new
present
cropping
will
never
routine
will
liberally
anything
the
program,
involved.
again
just
the
program
some
always
to
first
line.
up
every
change,
cause
with
comments
in
the
Without
what
time.
refer
the
first
time
no
least
you
is
one,
easier
to
errors
BASIC
‘O’
missing
The
it
prove
understand.
if
they
keywords.
so
other
the
effective
eg
PAYMENT
is
where
invaluable.
Such
contain
Note
that
it
is
problem
part
the
list
and
will
to
the
line
routine.
line
This
so
any
The
to
the
will
leave
the
module
modifications
problems.
contained
obscure.
will
Three
bless
comments
going
on.
descriptive
names
can,
combinations
that
in
the
not
rejected
with
descriptive
of
the
name
and
PARAMETER
of
variables
be
invaluable
number
reason
working
you
is
called.
in
months
the
day
it
could
variable
however,
of
letters
listing
because
names
(the
made
of
for
part
with
you
REM
when
well
given
of
first
are
up
5)
The
majority
be
temporary
variable
if
it
turns
which
out
to a temporary
names
will
of
6)
listed
were
placed
to
in
do
the
the
module.
Some
above
actually
into
begin
each
job
variables
the
the
the
variable
of
variables
variables.
contains
that
your
there
If
is
variable
module,
without
data
going
main
confusion
are
less
was
to
data
normally
be
name
used
you
accept
permanent
an
error
and
there
temporary
stored
passed
arrays
with T to
in a modular
an
input
data
in
the
input.
is
no
need
one
or
two
since
they
than
in
two
variables
to
two
other
of
the
program.
show
that
program
straight
it
is
much
Inputs
to
call
such
as
will
be
others.
(TA
modules
In
this
is a temporary
will
into
the
harder
should
these
by
T$,
Q$,
forgotten
In
the
input
and
TD$)
before
this
case
(or
should)
array
to
correct
be
made
different
T,
and
at
the
module
which
being
it
is
helpful
variable
or
Q
end
1]
Page 24

Advanced
but
always
7)
the
a)
placed
b)
a
program
logical
amounts
program
which
routine
that
8)
and
module
up
is
to
if
section
arrays
have a line
The
memory,
line
equal
Programming
do
add
remembering
Take
some
program.
Frequently
towards
On
the
other
order.
If
you
are
of
so
are
in
the
you
will
The
initialisation
variables,
of
the
program
subsequently
set
the
arrays
there
is
some
of
at
the
variable
is
does
is
to
zero.
Techniques
one
or
more
the
care
in
deciding
There
are
used
modules
the
beginning
hand,
where
used
its
the
all
the
not
doing
calculation
that
the
modules
by
several
example
notice
any
of
is a separate
own
which
when
called.
when
useful
program
very
beginning
which
tests
chosen
always
to
Take
jump
should
some
around
the
letters
danger
two
there
modules
anything
and
given
difference
the
it
1s
Programs
they
data
which
an
value
following
of
the
major
will
of
the
is
nothing
excessively
time
fall
into
areas
above),
program,
function
can
be
first
used
are
needed
already
clears
of
the
important
be
one
other
the
initialisation
which
will
remind
duplication
order
considerations
be
executed
program.
more
are
apparently
then
it
logical
of
the
at
in
speed.
ie
the
of
called
or
and
can
also
but
stored.
the
program.
variable
which,
than
example:
of
in
which
slightly
difficult
complicated,
is
probably
groups,
program
the
end.
declaring
the
program
not.
This
then
to
be
made
to
avoid
In
order
memory
At
to
when
zero.
routine
you
of
its
names.
modules
here:
jumbled
with
It
is
wipe
to
the
see
the
What
are
laid
faster
if
to
understand
together
with
enormous
better
to
lay
smaller
(like
the
FORMAT
extremely
of
the
various
and
should
will
allow
you
out
any
‘auto-initialise’,
clearing
to
and
start
program
if
the
do
this,
dimensions
of
the
whether
the
the
it
has
auto-initialise
variable
function,
out
in
they
are
than
in
no
out
the
modules
unlikely
arrays
have
a
to
set
data
if
it
ie
memory
place
the
the
module,
is
zero.
data
in
is
not
LHW
14@i
LHP
101@
1920
i@30
Here,
If
you
12
REM
REM
REMEXERKERKKRKEEEHEKREREHREKERKEERERERKEEEN
IF
INITIALISE
IT<>@
HEHEHE
THEN
KRKHKKEKHHEEHEKKEEHKKEEE
i500
CLR
DIM
IT
will
were
A$(10),
be
used
to
input
some
to
record
items,stop
AX(500)
the
number
the
,B~(100)
of
program
items
and
,C#(100)
stored
by a program.
start
it
again
with
Page 25

Chapter 1 Modular
Programming
GOTO
the
want
program
including
9)
in
various
modules
allow
10)
variables
1000,
lines
which
to
clear
with
IT,
Any
program
outline,
functions.
could
more
Modular
used
happened
Modular
program
be
answer
GOSUBs,
the
found
about
‘array.
problem
you
means
be
All the
is
still
in
will
up
ERR.
programming
to
called,
is
the
For
example,
third
in
the
to
and
and
insert
You
and
RETURN
of
an
set
to
zero
modules
zero.
the
chain,
be a module
the
ERROR
This
invaluable
form
one
module
error
flag
see
instead
clear
the
existing
RUN,
to
zero.
worth
what
the
program
Apart
probably
than
one
function
programming
to
indicate
in
another.
declare
use
how
of
different
are
one
suppose
ie
the
first
the
third
data
which
an
item
now
want
secondly
from
error
flag,
but
is
now
will
contain
If
it
is
not
without
which
MESSAGE
is
only
one
whenever
to
Chapter
of
the
data
the
memory
data,
since
this
clears
the
name
does and
from
that
be
improved
to
be
is
made
to
one
The
classic
lends
itself
types
you
to
prevent
or
more
flags.
that
you
routine
has
could
and
to
do
to
the
has
called
not
it
is
found
two
ensure
current
say a variable
given a value
one
or
they
RETURN
trying
to
do
will
detect
module
example
information
another.
(For a fuller
5).
being
lost,
line
and
set
up
all
that
needs
the
memory
needs a menu
allows
main
menu,
by
means
accessed.
easier
by
module
that
example
to
the
use
of
errors,
an
error
are
four
subroutines
called
the
second,
the
fourth.
have
been
that
there
things:
that
firstly
nothing
subroutine.
called
corresponding
more
lines
execution
anything.
that
of
the
on
ERR
to
print out
use
the
state
At
of a flag,
explanation
1010
would
the
arrays
afresh.
to
be
done
and
sets
which
specifies,
you
to
choose
many
of
of a small
the
use
of
‘flags’.
something
is
that
of
of a separate
but
how
is
crashing
the
along a chain
the
second
At
that
point
detected
is
to
notify
before,
no
more
disastrous
This
1s
usually
ERR.
This
to
the
which
detect
to
the
previous
the
beginning
has
been
error
message
you
of
play
has
of
jump
When
is
to
all
variables,
between
the
individual
menu
These
has
or
error
routine
that
routine
program.
has
an
say
room
the
user
happens
would
type
whether
of
set
and
will
find
to
be
the
use
around
you
start
the
at
least
the
if
they
are
has not
flagging.
in
the
to
The
of
called
error
is
you
are
in
the
of
the
when
done
by
normally
of
error.
ERR
module
the
chain
will
call
number
them
passed
of
an
11)
Spread
develop
more
annoying
new
module
new
modules
the
the
start
program
than
in
with
on
the
line
numbers
further,
having
line
numbers
end
which
of
and
to
spoil
incremented
would
your
you
your
more
modules.
no
doubt
neat
naturally
When
will,
there
structure
by
by 1 each
be
part
you
is
squeezing
time
or
of.a
want
to
nothing
adding
group
13
a
Page 26

Advanced
in
too
12)
simplified
the
much
There
middle
Programming
of
to
begin
are
by
replacing
Module 1 calls
of
RETURNing
be
to
call
Module 3 with a GOSUB,
RETURN
GOTO
the
module
RETURN
be
with
module
‘second
to
calling
will
to
Module
the
error-checking
which
level’
error-detecting
then
RETURN
however,
involved
MEMORY
not
been
since
can
either
error
cancelled
expected.
Techniques
the
program. A spread
with
for
many
circumstances
RETURN
Module
Module
Module
send
is
module,
line
to
miscounting
to
Module
execution
2.
called
which
the
menu.
lead
when
by
RETURNs,
2.
On a certain
1,
1.
‘This
3,
where
An
example
routine
directly
then
would
to
it
runs
programs.
when
the
statements
we
need
can
also
the
back
of
described
from
every
second
GOTO
The
technique
the
number
the
program
out
of
space
or
of
2000
for
each
module
execution
condition
to
call
then
RETURN
be
RETURN
to
Module 1 without
the
use
the
main
level
the
of
stopping
to
of a program
with
GOTOs.
being
detected,
Module
3.
One
to
Module
accomplished
statement
of
such a technique
above.
error
has
GOSUBs
menu
module
message
to
be
If
of
used
and
with
store
GOSUBs
at
having
we
the
could
with
an
executing a subroutine
is
not
can
be
For
instance
instead
way
would
2,
then
by a simple
the
end
of
first
to
would
regard
module
any
program
have
and
a
an
caution,
RETURNs
OUT
OF
which
have
you
had
not
13)
Once
you
it
is
easy
to
change.
a
certain
whip
technique.
out
14)
on
For
out
one
function.
the
Failure
of
modules
advantageous
This
will
enable
by
using a ‘merge’
Commodore
from
tape
or
then
running
key.
This
will, of
program.
the
15)
Remember
module
before
Finally,
remember
professional
subroutines
14
of
oN
yd
have
written a program
Be
on
When
original
the
module
to
update
greatest
embodying
to
store
them
you
to
program
64
(Sunshine
disc,
listing
the
cursor
course,
that
it
is
inserted.
that
programs
only
two
the
lookout
you
find
an
and
your
advantages
separately
add
them
like
Books:
it
to
the
down
the
lines
insert
you
may
almost
will
often
or
three
lines.
in
modular
for
better
techniques
improvement
replace
it
with
programs means
of
this
style
important
as
easily
that
1983)
screen,
on
the
lines
need
everything
techniques
well
as
to
subsequent
contained
or
simply
loading
the
screen
on
the
to
change
can
contain a great
It
is
possible
form,
remember
of
in a book
one
embodying
that
you
of
programming.
included
in
programs,
in
The
by
loading
the
new
using
the
screen
the
line
be
modularised.
many
to
go
too
performing
or
magazine,
the
are
missing
it
is
often
the
program.
either
Working
the
routine
program
RETURN
into
the
numbers
Good
separate
far
with
that
new
and
new
on
the
Page 27

Chapter 1 Modular
Programming
process,
but
Conclusion
There
is
little
It
contains
Only
that,
make
and
understandable
by
putting
of
all
the
far
the
biggest
not
easy.
doubt
less
the
material
difference
that
this
by
way
or
principles
contained
programs.
is
the
easiest
practical
of
this
chapter
in
this
in
your
attempts
chapter
examples
into
book,
to
in
the
and
no
practice
it
is
this
write
book
to
miss
working
chapter
successful,
will
BASIC.
you
that
useful
out.
learn
will
15
Page 28
Page 29

CHAPTER
Debugging
A
national
explaining
the
series
the
one
—
profanity.
When
have
even
nevertheless
enough
understand.
perhaps
will
not
I
know
trying
time
they
their
64
they
could
had
known
computing
the
many
had
ended a reader
language
you
have
run
it
come a time
on a program
It
is
from a book
have
developed
that
some
to
debug a program
contact
is
malfunctioning
have
and
used a few
2
different
familiar
entered
once
or
even
worse
or
an
readers
me
they
solved
their
magazine
computer
wrote
to
all
computer
your
program,
twice
without
when
it
of
your
own,
if
you
are
magazine.
instinctive
of
my
own
they
have
are
often
(or
that I am).
own
problems
simple
techniques.
recently
languages
in
to
point
owners
testing
apparent
breaks
With
near
down
whose
entering
the
feeling
books
have
made
to
The
in a few
ran a series
available
out
that
they
whatever
it
as
you
problems,
in
chaos.
working
someone
best
for
what
spent
an
error
desperation,
truth
will
in
is
going
weeks
in
entering.
is
that
minutes
else’s
convinced
of
today.
had
their
machine
go,
when
there
.This
methods
program,
the
world
on
or
months
in
most
if
only
articles
When
missed
you
will
ts
bad
you
you
where.
By
the
that
cases
they
Information — the
The
first
thing
to
remember
program
is
contained
those
and
You
you
head
information
then,
Having
use
exactly
is
priceless
run
the
may
well
have
lost
again
to
trace
made
of
the
information
that
that
all
the
information
safely
in
your
facts.
When
program
the
in
the
contained
each
information
again
be
right — the
chance
future,
error
that
resolution,
available?
64
in
to
perhaps
in
the
as
you
is:
key
to
debugging
when
you
you
and
the
last
you
find
an
the
hope
that
program
remove a bug
memory.
find
how
at
it.
To
will
some
are
decide
encounter
require
thing
you
error,
therefore,
it
will
apparently
which
time
The
first
you
to
go
that,
to
track
wish
not
will
when
rule
about
you
an
error
down
to
do
1s
never
crop
up
next
run
perfectly
inevitably
you
have
of
debugging
making
need
to
assess
in
your
the
error
to
erase
ignore
valuable
time.
rear
the
what
it
but
its
is,
best
17
Page 30

Advanced
1)
It
may
such
that
In
that
the
location
the
form:
°’
TERROR
2)
Some
stops
seems
stop
the
result.
often
This
be
Programming
well
be
it
pinpoints
case
the
in
errors
perfectly
program
type
no
indication
Techniques
that
64
has
the
program
MESSAGE
may
stop
but
of
error
the
type
the
problem
identified
at
which
IN
the
program
correct.
simply
of
result
is
the
where
Along
of
error
as
being
the
type
it
LINE
in
most
things
that
has
limited
of
mistake
occurs.
xx
even
though
with
these
the
program
difficult
are
going
stopped
The
go
to
that
you
error
the
errors
the
program
particular
have
made
report
will
line
on
which
producing a nonsense
to
trace,
since
there
wrong.
line.
and
take
which
will
not
will
is
it
Single
In
solved
that
program
key
indicated
need
refuse
Take,
of
be
perusing
the
work.
line
most
cases,
because
needs
has
to
discovering
in
to
look
to
recognise.
for
all
errors.
an
error
the
program
There
recognise
corrected.
Error
messages
error
are:
TOO
COMPLEX,
UNDEFINED
procedure
1)
List
out
the
line
in
context.
error
when
the
to
be
to
be
the
error
no
further
instance,
Whenever
in
the
line
again
is
something
as
BASIC
SYNTAX
with
such
the
program
messages
you
get
64
has
already
examined.
made
to
the
nature
message.
than
the
SYNTAX
you
way
you
in
question,
or
trying
and
the
which
normally
ERROR,
REDIMMED
FUNCTION,
‘line
specific’
area
an
error
pinned
It
may
some
of
the
For
the
line
receive
have
entered
deciding
to
alter
in
the
program
UNDEFINED
errors
which
message,
be
that
other
error
many
down
line(s)
the
is
always
of
the
half
for
actual
in
error
mentioned, a fact
ERROR
this
that
other
line
specified
pinpoint
FILE
ARRAY,
is
precedes
error
the
it
lines
will
never
NOT
as
follows.
the
message,
you
line
looks
which
the
FOUND,
TYPE
line,
your
problems
you
the
program
correction
the
program,
contained
messages
that
people
the
commonest
know
that
specified.
OK
to
make
run
exact
It
and
then
the
the
64
until
location
FORMULA
MISMATCH,
STATEMENT.
this
will
but
in
the
you
there
is
no use
running
program
does
that
line
of
help
are
line
to
the
the
line
will
often
must
not
the
The
to
put
is
2)
List
lines
separating
this
is
18
out
that
the
line
itself
it
from
it
is
surprisingly
again,
the
lines
easy
this
you
to
time
have
enter
on
its
already
two
own,
lines
with
one
listed.
on
the
The
64
or
in
two
blank
reason
for
such a way
Page 31

that
they
to
detect
Examine
16
FOR
~4@
NEXT
are
received
unless a line
the
following:
T=1
TO
I
as a single
is
listed
separately.
1@
=:
line.
LET
Such
errors
X=1*100-5@/
Chapter 2 Debugging
are
almost
impossible
(12)
Imagine
?SYNTAX
the
at
thus
entered. To
14
NEXT
Not
3)
task
character.
line
‘cursor
and
errors
intended
the
characters. Particular
instructions,
the
the
frustration
ERROR
error
can
go
the
end
of
line
taking
the
the
FOR
I=1i
I
surprisingly,
With
the
line
is
to
examine
One
is
to
place
the
right’
key,
the
instruction
which
result
it)
result
misspelling
the
letter
‘O’.
For
IN
on
for
10,
instead
cursor
64,
the
TO
the
64
listed
out
the
way
to
cursor
to
move
of
which
from
from
of
keywords
points
figure 1 replaced
instance:
when
it
LINE
10
hours
or
days.
of
pressing
to
the
beginning
full
version
10 : LET
finds
that a little
and
provided
line
instruction
ensure
at
the
that
beginning
slowly
it
is a part.
the
64
not
the
dropping
to
watch
is
run
and
all
flashes
In
up
on
fact
all
RETURN, a space
of
the
of
line
10
reads.
X=1#1@0-S0/
hard
to
that
there
by
instruction
you
don’t
of
along
the
line,
Most
syntax
understanding
of
characters
or
the
inadvertent
out
for
by
the
letter
that
ever
the
screen.
that
has
next
line,
interpret.
are
no
skip
too
the
line
and
examining
errors
the
line
(especially
are
missing
‘I’
and
happens
The
happened
is
that
search
is
that
was entered,
then
line
20
(I1#2)
gross
and
2@
errors,
character
quickly along
then,
using
each
character
(and
the
other
in
the
way
brackets),
transposition
colons
zero
between
replaced
for
was
the
by
the
the
you
of
by
GOTO
I@M@
UNDEFINED
4)
The
detailed
that
case
the
value
of
the
value
of
the
changes
the
involved
error
in
variables
in
messages’
insteadof
LINE
scan
next
step
variables
variables
the
line
to
area.
the
problem,
later
of
help
If
in
in
the
GOTO
ERROR.
the
line
depends
memory
will
be
track
value
move
the
chapter.
1@@@
will
often
upon
whether
or
not.
In
irrelevant
down
the
error,
of
one
or
more
on
to
the
would produce
fail
to
turn
up
you
need
the
case
of a syntax
and
you
can
even
though
variables
section
headed
the
mistake.
to
preserve
error
afford
to
make
this will
does
seem
‘Non-obvious
In
the
the
clear
to
be
19
Page 32

Advanced
5)
in a new
at
beginning
have
Programming
Provided
line
the
last
statement
of
to
run
that
the
disappeared,
effectively
error
statement
in
the
then
line
removed
delete
in
you
error.
6)
If
you
still
of
variables
of
the
is
wrong.
whether
the
same
and
variables
The
you
have
letters
the
just
after
the
statement.
program
then
the
the
the
line.
will
have
cannot
try
again.
does
purpose
entered
as
the
Techniques
variables
the
line
in
the
offending
Run
again
error
is
that
statement
REM
and
By
the
identified
identify
Remember
not
matter
behind
invalid
start
of a BASIC
are
not
where
the
line
the
line
up
to
that
in
the
last
from
re-insert
time
you
the
the
error,
that
in
the
changing
names,
needed,
place a STOP
error
was
and
insert a REM
again
point).
statement,
the
line.
it
at
the
beginning
have
reached
statement
then
begin
for
some
least.
It
is
variable
perhaps
keyword.
indicated.
(in
some
cases
If
the
syntax
since
the
If
there
is
of
the
first
which
contains a syntax
to
change
errors
the
the
form
of
names
names
is
to
which
statement
Now
start
at
the
very
you
will
error
has
REM
has
still a syntax
the
previous
statement
the
names
actual
value
the
line
that
try
and
see
begin
with
Non-obvious
As
mentioned
location
to
enter a line
14
then
reason
SUBSCRIPT,
ILLEGAL
FILE,
OVERFLOW,
will
program
In
variable
100
the
error
A=10/0
you
will
NOT
most
The
procedure
the
majority
A=X#Y/
of
the
is
to
which
will
receive a DIVISION
be
easy
DIVISION
QUANTITY,
OUTPUT
often
line
indicated,
contained
error
above,
error
UNDEFINED
of
in
be
found.
reads:
to
find.
occur
in
such
cases
within
some
the
FILE,
on
but
the
(T1*T2)
messages
error
messages
program,
The
distinction
On
the
whole,
BY
ZERO,
NEXT
OUT
FUNCTION
occasions
before
cases
first
the
is
less
step
line.
Thus
it
they
BY
ZERO
FILE
WITHOUT
OF
DATA,
when
in
the
execution
clear
than
will
be
if
the
do
not
simply
is
not
an
error
however,
NOT
and
STRING
the
real
in
debugging a single
to
print
line
read:
pinpoint
tell
you
absolute
message,
BAD
OPEN,
FOR,
OUT
error
of
the
out
the
where
one.
DATA,
FILE
NOT
OF
MEMORY,
TOO
is
not
program.
value
the
the
If
and
OPEN,
INPUT
LONG,
in
of
exact
key
you
the
BAD
the
line.
every
20
Page 33

you
would
os
y
Shen
eT
L
“TS
and
make a note
line
in
your
produced
identify
Normally
line,
you
time
program
unless
error
for
mentally
variable
often
alter
variable
in
might
here
have
attempt
able
to
find
lines
variable
be
variable
variables
observed:
the
you
are
may
have
distributed
again.
you
the
error
some
future
Having
may
not
the
program
as
the
program
be
altered,
is
that
to
start
Having
to
to
print
continue
the
area
seem
names.
faultless
name
it
In
all
of
enter
of
the
head
or
the
error
reason
this
will
not
unable
to
resort
among
This
can
reproduce
may
occasion.
identified
trace
back
have
picked
possible
the
in a complex
so
program
after
each
inserting
the
program
entered
repeat
the
out
the
program
the
the
value
where
correct,
The
but
the
for
another
is
only
the
this
the
task
values
on
paper
report
you
can
that
go
be a problem
to
see
how
to
re-entering
two
or
should
only
the
not
be
repeated
the
variable
the
execution
up
that
regular
is
running.
those
sections
new
line
the
lines
from
temporary
error.
Each
of
the
if
you
the
problem
one
factor
lines
referring
program
rendered
purpose
first
two
can
be
that
this
to
see
why
stopped
no
further
but
the
variables
three
separate
be
done
exact
chain
and
which
of
the
offending
program.
checks
This
of
reading
will
clear
scratch.
stop
time
offending
have
not
appears
to
watch
to
at
some
letters
which
made
much
produced.
it
if,
the
instructions
is
that
the
program.
in
tracking
due
work
Now
those
to
shorter
as a last
of
the
is
the
events
program
at
fault
program
resort,
value.
In
this
can
be
made
is
achieved
the
program
simply
the
lines
the
STOP — the
memory
the
program
program
variable
yet
found
the
to
be
generated,
out
for
an
important
nonsense
by
stage — remember
are
significant.
more
simple
Chapter 2 Debugging
work
through
particular
Until
down
the
the
complexity
together,
in
lines,
the
line
then
eventually
however,
which
led
up
bug
will
lie
the
only
course
to
see
where
Unfortunately
case
the
solution
of
the
value
by
inserting
where
new
the
drawback
and
thus
is
rerun
STOPs,
and
fault.
then
you
enter
If,
when
the
is
the
duplication
variable
the
use
may
of
the
that
if
two
rules
the
values
you
can
error.
of
the
but
this
run
the
since
to
the
in
wait
is
to
the
this
is
is
to-
of
the
lines
variable
you
will
in
an
will
be
CONT
you
program
of
in
fact
same
in
all
are
21
Page 34

Advanced
1)
program
Where
Programming
complex
modules
information
it
regularly
the
last
set of
keyboard.
2)
Most
program
a
large
quantity.
only three
If
there
only
or
values
Searching
point
done
and
to
achieve.
thankful
your
makes
or
is
an
four
items
like
can
be a taxing
thoroughly,
only
if
you
if
you
program
the
tracking
you
on
tape
so
that,
data
faults
Rather
four
items
error
have
AAAA,
for
an
following
understand
It
is
when
have
in
strictly
down
Techniques
sets
of
should
or
disc.
if
the
program
from
tape
will
than
and
then
it
been
BBBB,
error
embedded
task.
bugs
followed
functional
of
data
are
enter
When
instead
show
up
bash
then
go
will
be
easy
entered,
CCCC,
It
can
only
through
exactly
like
this
the
errors
considerably
what
advice
modules,
going
to
be
is
the
data
you
enter
does
stop,
of
entering
just
as
well
away
entering
through
all
to
simulate
especially
1111,
2222
in
the
program
be
carried
the
program’s
each
program
crop
up
that
given
for
handled,
file
data
you
from
routine
to
begin
will
be
scratch
one
with a little
huge
quantities,
of
the
program
the
sequence
if
you
enter
and
3333.
at
some
out
successfully
execution
section
you
will
be
in
Chapter 1 and
such a program
easier.
of
the
first
to
store
the
testing,
able
data
to
reload
from
as
save
the
with
enter
functions.
again
stylised
items
unspecified
if
it
in
detail,
is
intended
particularly
written
structure
if
is
Interpreting
Program
they
impossible
message
error
BAD
of
the
item.
PRINT#1,A$,R$,B$,R$,A,R$,B,)
separator.
CHR$(13)
module
BAD
because
the
obvious,
accept
22
bugs
are
entirely
might
messages
DATA : The
the
save
data
saved
Be
The
will
SUBSCRIPT : Look
one
array
when
check
references
are
the
to
give
signify.
and
routine
has
careful
module
then
data
end
up
of
them
it
that
error
as
messages
varied
work
an
exhaustive
of
Given
some
suggestions
usual
cause
in
its
load
not
been
in
using a variable
may
is
being
out
of
sequence
to
is
larger
was
DIMensioned.
you
did
to
elements
as
programmers,
programmers.
list
of
below
you
as
to
is a failure
counterpart.
properly
look
run
the
than
separated
that
fine
but
together
with
what
values
in
the
respective
If
dimension
zero
to
the
nine
for
the
For
that
what
every
will
find a list
likely
causes:
to
mirror
Another
by
to
separate
you
have
if
R$
has not
on
the
tape
was
saved.
brackets
dimension
the
fault
array,
since
of a single
simple
reason
particular
of
the
exactly
the
cause
CHR$(13)
the
actually
been
or
disc
after
the
is
not
the
program
dimension
reason
it
would
error
that
be
common
structure
may
be
that
after
each
items
defined
defined
and
array
you
the
load
name,
gave
(eg
the
as
to
immediately
will
array
Page 35

even
you
if
try
it
to
has
refer
not
to
been
DIMensioned,
element
10.
but
will
then
stop
-Chapter
in
confusion
2.
Debugging
when
DEVICE
NOT
in a statement
forgotten
access.
errors
circumstances
in
others
loss
DIVISION
a
line
improperly
EXTRA
items
with
program
processed.
string
FILE
have
FILE
number
which
to
plug
Unfortunately
occur
and
this
the
64
of
the
program
BY
so
the
probable
handled
IGNORED : An
eg
INPUT
more
than
tells
The
inputs,
NOT
the
since
FOUND : You
wrong
NOT
OPEN : You
which
has
already
PRESENT : Either
which
ZERO : It
that
you
message
in
the
the
Jnput/Output
can
must
be
and
by
the
A,B
is
number
that
these
deals
with a file
disc
or
this
error
be
cured
switched
data.
is
unlikely
cause
program
input
looking
of
an
item
will
also
will
be
have
cassette
can
by
of
statement
for
items,
be
interpreted
either
cassette/disc.
have
tried
the
64
either
does
been
CLOSEd.
you
have
specified
(eg
recorder
also
crop
system
becomes
switching
off
and
on
that
you
this
error
is
or
an
incorrect variable
expects a certain
the
input
of
perhaps
has
been
entered
generated
as
used
to
perform
not
recall
an
the
wrong
OPEN
off
again,
have
the
program
up
if
the
with
actually
1,7,1)
other
confused.
device
the
that a variable
name
two
numbers.
replying
10,12,14
which
if
you
place
separators
the
OPEN
wrong
an
operation
between
filename
statement
number
or
you
have
is
trying
file
handling
In
some
in
question,
consequent
entered
has
/0
been
used.
number
If
you
reply
then
will
not
commas
into
items.
or
you
on a file
for
to
in
of
the
be
or
FILE
OPEN : The
is
failure
used
a
file
you
FORMULA
expression
Unfortunately
the
guide
ILLEGAL
be
to
include a CLOSE
the
same
with
‘1’
will
not
subsequently
on
operating
can
be
QUANTITY
negative,
TOO
given
file
as
its
the
the
system
or
you
opposite
number.
number
be
COMPLEX
line
in
question
error
also
becomes
as to
what
:
One
may
be
of
the
previous
statement
Thus
but
fail
able
to
:
The
crops
confused
the
message
of
the
trying
if
you
to
CLOSE1
save
data
simple
into
two
up
in a number
variables
to
put a number
error.
The
in
some
previous
load
data
when
using
file
answer
expressions
of
and
in
these
means.
used
to
most
frequent
routine
into a program
the
data
1s
loaded,
number
may
on
circumstances
access
outside
be
to
separate
cases
an
1.
split
no
reliable
array
the
cause
which
using
the
lines.
where
may
range
23
Page 36

Advanced
Programming
Techniques
—32768
a
doubt,
(without
NEXT
the
single
try
WITHOUT
loop
to
byte
line
the
statement
therefore
NOT
you
NOT
OUT
program’s
12
for a solution
OUT
a)
memory.
wise
on
been
INPUT
wanted
OUTPUT
OF
DATA : You
data
OF
MEMORY : There
You
have
For
to
use
the
size
of
+32767
into
function
entering
the
numbers)
FOR : The
statement
or
you
have
executed.
FILE : You
to
open a file
FILE : Opposite
statements.
to
this.
dimensioned
programs
FRE
to
check
the
arrays.
an
work
various
and
refers
jumped
have
to
have
which
on
integer
let
input
tried
See
array,
on a number
statements
the
64
tell
program
to.
Either
into
incorrectly
data.
of
the
above.
to
READ
the
section
are
four
possible
arrays
will
the
available
too
work
or
outside
you
is
not
you
the
loop
specified
more
on
big
for
with
memory
you
may
the
in
the
which
one
aware
have
and
data
data
statements
causes:
the
large
before
be
trying
range
0-255.
line
in
direct
it
doesn’t
of
the
beginning
left
out
the
FOR
an
output
than
there
in
amount
quantities
of
of
finally
to
make
If
in
mode
like.
of
the
FOR
has
not
file
when
is
in
the
Chapter
available
data
it
is
deciding
b)
You
have
up
the
‘stack’,
addresses.
c)
You
have
which
has
combine
of
d)
64
with
loops
nested
Unspecified.
becomes
OVERFLOW
that,
for
instance, a large
REDIMM’D
DIM
statement
wish
to
redimension
24
too
many
the
area
too
many
FOR
to
remember
b)
if
you
inside
one
Sorry,
confused.
:
Usually a problem
ARRAY : You
as
that
an
GOSUBs
of
the
in
memory
loops
stage
operating,
have a long
another.
but
this
is
number
of
array
is
have
another
you
must
operation
which
at
has
to
again
which
each
loop
chain
of
GOSUBs
another
error
with a variable
being
divided
tried
to
use
the
array
already
first
of
all
the
same
remember
cluttering
has
reached.
and a large
which
can
being
by a tiny
same
array
DIMensioned.
clear
the
time,
cluttering
their
return
up
the
This
number
crop
up
misdefined
fraction.
name
If
memory.
stack,
may
if
the
so
in
a
you
Page 37

Chapter 2 Debugging
REDO
number
will
be
RETURN
the
tagged
at
STRING
from a file
the
string
properly
FROM
happily
wrong.
use
onto
the
end
255
input.
and
WITHOUT
of
GOSUB.
of
TOO
you
character
separated
2SYNTAX
trying
to
execute.
to
track
down
TYPE
MISMATCH
a
number
(or
frequent
vice
be
versa).
cause
START : An
was
given a string.
receive a number
GOSUB : You
The
most
the
end
of
the
the
main
part
of
LONG : In
have
tried
to
The
overall
error
by
maximum
also
CHR$(13)
ERROR : The
See
the
first
obscure
specified
is
errors.
:
Sometimes
whereas
Thus
A=A$+B$
careless
omission
input
statement
Note
that
without
any
have
common
program
the
the
and a STOP
program.
process
of
create a string
or
occurs
64
when
when
simply
part
of
the
what
saved.
does
the
context
is
would
of $ symbols
was
expecting
an
INPUT
indication
expecting a string
that
something
entered a subroutine
cause
is
when
subroutines
statement
string
addition,
whose
the
80
character
loading
data
not
understand
chapter
of
the
actually
generate
in
length
for
program
encountered
string
input
is
maximum
which
suggestions
this
error.
handling
to
receive
without
is
not
placed
or
input
greater
has not
the
than
been
line
on
dictates
is a string
The
most
lines.
a
may
are
for
it
is
how
that
UNDEF’D
function
FUNCTION
but
the
program
defined.
UNDEF’ D STATEMENT
not
exist.
If
the
message
the
number
inadvertently
then
you
described
appears
after
substituted
may
have
in
the
to
be
there
the
first
but
Conclusion
Successful
little
always
to
find.
another
debugging
thought
be
some
When
mind
and
errors
that
on
the
hard
:
You
has
:
The
appears
GOTO
‘I’
tagged
part
one
of this
isn’t a line
is
something
work.
that
will
time
comes
subject,
have
no
recollection
line
you
to
be
or
GOSUB
for
‘1’
or
line
onto
chapter — the
in
its
that
With
the
stump
the
for
very
often
tried
want
nonsense
to
‘O’
for
the
own
right.
comes
best
you,
bugs
most
successful
another
to
employ a user
of
that
function
to
GOTO
ensure
‘0’.
end
at
If
of
first
that
this
the
or
1s
second
with
experience
will
in
the
world
that
take
debugging
programmer
defined
having
GOSUB
sight,
examine
you
have
not
the
previous
part
of
the
there
days
or
will
been
does
not
reason
line
as
line
and
no
will
weeks
aid
is
spot
25
Page 38

Advanced
Programming
Techniques
something
Even
so,
exactly
likely
certain
what
area
line
beginning
immediately
the
time
is
going
where
generates a certain error
of
the
process.
that
to
call
in
wrong — the
the
problem
you
someone
were
values
is
cropping
too
else
is
close
is
not
of
the
up.
not
to
the
program
until
you
variables
Simply
enough,
knowing
to
can
describe
involved,
that
it
is
only
see.
the
a
the
26
Page 39

CHAPTER
Strings
3
Strings
Using
instantly,
with
programmer.
handling
expressing
RIGHT$
but
alphabet,
are
an
strings,
even
strings
is
inherently
the
The
64
equips
and
for
those
1)
LEFT$(A$,10)
2)
RIGHT$(A$,10)
3)
MID$(A$,10)
number
4)
MID$(A$,10,5)
10
and
continues
Applying
the
1)
ABCDEFGHIJ
2)
ORSTUVWXYZ.
3)
JKLMNOPORSTUVWXYZ
4)
JKLMN
easy
and
information
in
the
can
add
This
fact
string
handling
the
MID$.
who
are
10
and
continues
these
to
an
results
are:
flexible
case
quite
seems
difficult
user
with
Most
unclear a brief
means
means
means
means
for
five
actual
way
can
be
of
quite
considerably
to
be
hidden
but
because
commands
three
people
the
first
the
the
part
to
the
the
characters.
A$,
which
of
storing
deleted,
complex
string
understand
recap:
10
/ast
end
part
operations.
to
what
from
it
is
appear
handling
characters
10
characters
of
A$
which
of
the string.
of
A$
in
this
information
added
which
can
many,
often
fiddly
complex
functions,
their
function
of
A$
of
begins
begins
case
will
or
not
altered
Playing
be
achieved
because
and
at
first
A$
with
be
the
on
the
almost
around
string
the
sight.
LEFT$,
fairly
character
at
character
complete
64.
by
a
lines
well
On
their
own
examples
have
sprout
appear
problem
expression
translating
show.
to
be
brackets
very
the
which
the
the
The
applied
within
complex
way
to
is
line
commands
problem
in
combinations.
brackets
and
obscure.
cope
with
most
embedded
so
as
to
make
are
straightforward
for
most
Once
to a degree
When
it
is
always
it
successively
people
this
which
you
to
in
brackets
seems
happens
run
begin
simpler.
enough,
to
makes
into
with
and
arise
lines
their
this
the
part
then
For
as
the
when
they
tend
function
kind
of
the
to
begin
example,
to
of
27
Page 40

Advanced
Programming
Techniques
supposing
MIDE
What
alphabet.
(LER
is
to
you
be
We
T#
begin
RIGHT$(A$,10)
at
the
result.
RIGHT$(A$,10)
MID#(LEFT#
Following
QRSTU,
MIDE
or
STU.
the
inside
In
be
combined,
to
provide a wide
capabilities.
described
ensure
this
that
the
leaving
“GRSTU
In
string
and
chapter
Several
here
you
had
an
expression
(RIGHT#(A#,1@),5)
made
of
it?
Well
with
the
string
because
(/
same
us
we
G@RSTUVWXYZ
rules
we
with:
.2)
expressions
work
out
and
you
we
shall
examine
both
with
each
variety
subsequent
in
widely
understand
differing
the
such
as:
let’s
assume
expression
don’t
have
to
is
‘QRSTUVWXYZ’.
45)
find
that
the
as
in
any
other
will
find
that
ways
in
other and
of
interesting and
chapters
examples
with
will
applications
given
,3)
that
A$
that
is
translate
4.3)
LEFT$
kind
of
the
problem
which
the
other
useful
make
use
so
before
is
once
again
most
embedded,
anything
That
part
else
leaves
really
expression,
solves
string
functions
BASIC
commands,
programming
of
the
techniques
it
would
moving
be
on.
the
ie
to
get
us
with:
means
start
at
itself.
can
wise
to
Concatenation
One
of
the
simplest
together:
100
At=—Btt+CFt+DFt
would
provide a new
the
equation
used
to
placed
provide
or
‘nose
meaningful
information. A simple
1BOO
1061
LOO?
1616
1020
1436
1040
28
REMEXHHHEEKHHHHEHHEKKKHEKHHHEEERHRHRRER
REM
STRING
REM
INPUT
INPUT
INPUT
‘SURNAME:
“FIRST
‘SEX
SX#='MR.°
string
things
string
to
example
ADDITION
KEKE
(M/F):
=:
addition
that
you
can
do
with
strings
consisting
tail’
strings
of
EKKHKEKEKKHKREHEEERRERE
NAME:
IF
of
so
to
speak.
this
might
‘3;
5N4
°;CN#
°;04
OF='F’
the
made
three
This
up
be:
THEN
strings
simple
of
is
to
add
on
the
ability
smaller
pieces
SX4=-'MS.
them
right
is
often
of
of
Page 41

Chapter 3 Strings
i950
i456.
Not
Individual
such
string
‘packed’
described
in
String
Just
individual
NAMEF=SX$+°
PRINT
every
items
as a ‘*’
stored
entries
later — more
the
chapters
subtraction
as
strings
string.
A$=B$—C$
string
from
exclude
according
the
to
string:
1)
To
remove
redefined
i144
as
AF=MIDS
NAMES
application
can
be
packed
between
has
on
can
would
another
characters
the
LL
the
each
an
overhead
can
be
Data
Structures.
be
added
This
cannot
be
meaningless
simply
you
position
characters
portion
of
(AF
‘°+CNS+°
of
the
technique
into a single
item,
unpacked
complex
together,
be
means
wish
to
of
the
from
A$
which
,LL+1)
to
save
memory
of
three
bytes
using a string
and
flexible
so
parts
done
quite
to
the
64.
to
redefine
subtract.
characters
the
left
comes
°+SNF
need
string,
in
methods
can
as
To
the
The
precise
to
be
hand
after
the
be
so
trivial,
separated
since
memory.
search
will
be
subtracted
simply
as
subtract
original
method
removed
end
of
first
LL
however.
by
markers
every
individual
Such
routine
like
be
described
from
addition
or
remove
string
will
in
the
A$,
A$
must
characters:
simple
that
an
since
one
so
as
differ
main
be
to
2)
To
remove
as
all
the
characters
to
be
removed.
long
the
string
length
minus
the
i@@
AS=LEFT#
3)
To
remove
only
where
removed.
LL
they
Once
concatenation
portion
140
The
is
after
them:
AF=LEFTS(A,5F—-1)
logic
of
this
at
character
LL
characters
up
The
way
is
at
the
number
(At,LEN
letters
start
this
of
the
portion
line
SP
then
to
and
to
moment
of
from
(SP)
is
known
is
that
we
from
the
including
accomplish
and
then
characters
the
in
addition
before
to
(Af)
middle
the
the
+
if
the
beginning
wish
to
keep
end
of
A$,
A$
the
one
before
this
is
to
use
LEN
to
say
that
it
be
deleted:
—-LL)
of a string
to
the
string
characters
it
length
must
to
MID#(AS,SF+LL)
of
the
all
the
characters
must
the
first
to
discover
should
is
necessary
of
the
portion
be
redefined
be
deleted
group
to
be
redefined
character
now
be that
to
and
be
deleted
up
to
how
know
to
be
as
the
and
29
a
Page 42

Advanced
Programming
Techniques
including
so
one.
at
LL+SP
be
CDE
retained
and
giving
Inserting
Comparing
subtraction
characters
to
string
be
a
new
a
new
character
1446
Moving
Having
in a position
character
it
will
finish
The
second
in
the
subtracting
is
character
portions
the
characters
FG,
adding
items
what
you
from
insert
items
we
examined a method
retained
in
group
of
string,
PP
of
At=LEFTS(FP-1)
items
examined
to
at
CDE
into a string.
the
characters.
B$,
the
within a string.
two
operations:
from
the
string,
illustrated
characters,
object
character
the
string
position
new
position
Arriving
straightforward.
original,
position
we
will
ie
character
below
LL
of
the
position
ABGHICDEFJKL
three,
starting
position
seven.
at
is
going
in
the
want
the
position
long,
exercise
to a position
the
existing
SP-1.
The
actual
position
group
string
of
together
may
inside
of
and
from
three,
the
string
after
the
into
has
been
notice
an
SP
(the
characters
continues
the
string
and
the
would
group
to
give
strings
said
that
existing
In
removing
of
result.
amended
into
Roughly
In
the
A$,
with
A$:
+
within a string
how
to
add
or
combine
In
the
then
based
correct
The
reinserted
both
essence,
group
of
added
on
beginning
is
to
FP.
An
example
of
the
position
first
move
to
be
deleted,
string.
10.
We
techniques
to
move
characters
again
an
original
at
move
by
such
that
group,
is
In
group
now
have
group
of
first
character) + LL
you
wish
to
the
end.
ABCDEFG.
length
to
be
be
is
up
to
deleted
ABFG.
about
so far,
string,
identifying
the
following
the
Bt
remove
an
while
we
an
same
first
+
items
in
item
to
in
another
string
have
item
the
example
MIDt(At,PP)
order
be
string
character
the
of
moving
in
to
to
and
the
to
position
group
to a new
such a task
GHI,
it
will
read
the
final
reinsert
ignore
the
the
simply
case
of
start
where
two
alternatives:
letters
is
LL
(the
to
keep
therefore
An
example
The
start
three
characters.
SP-1,
which
would
start
addition
we
can
remove a group
not
yet
from
within
two
remaining
method
character
1s
the
used
object
of
from a string
to
move
around
moved
A$,
in a string
must
place.
The
which
SP
in
position
might
be
which
starts
ABCDEFGHIJKL.
string,
will
string
is
fact
that
the
determine
the
example
the
‘J’
is
at
characters
length)
minus
starts
of
this
would
position
Thus
would
give
at
SP+LL,
and
string
examined
an
existing
strings
in
inserting
is
to
insert
B$
becoming
we
are
now
items
around
involves
be
subtracted
method
has a group
the
string.
starting
to
rearrange
at
character
The
be
at
character
not
completely
group,
the
string
the
in
new
start
above,
moment,
long
of
the
AB
of
how
to
is
of
The
at
its
30
Page 43

a)
If
the
new
current
b)
characters
arrived
and
therefore
position,
we
uf
60
74
BY
SHAH
24@1
SHAS
2=@1@
2426
2420
“W406
start
If
the
new
then
at.
In
the
example
the
point
to
which
Putting
arrive
this
at
something
At=°ABGHICDEFJEL
FR=10
SP=3
LL=S
REMHKHHRKRKHEKEKRHEE
REM
REMHEHKHKHKREHKEHRKKHEERKHERKRERRHEEREEESE
IF
TIT$=NMIDS
At=LEFT#(AF,SP-1)
AS=LEFTS(AE,FRP-1)
Fd
=~450
PRINT
starting
position
starting
at
subtract
all
position
then
the
length
above
which
the
is 7 as
we
together
position
of
the
we
found
like
MOVE
CHARACTER
FR?>(SP+LL-1)
(At,
At
of
the
figure
is
the
group
group
want
length
by
as
it
would
the
following:
*
SP,LL)
the
group
of
arrived
after
ends
to
re-insert
of
the
the
must
at
group
at
current
be
position
commonsense
apply
to
KHER
REKRKEHEREREEEE
GROUP
THEN
FR=FP-LL
+
MID#(At,SP+LL)
+
TTS
characters
needs
no
end
subtracted
five
it
is
position
(3)
to
arrive
above.
the
example
+
MIDS
Chapter 3 Strings
is
before
adjusting.
of
the
group
from
the
figure
at
the
moment
ten.
We
at
the
given
above,
(AF,F
their
of
have
final
VARIABLES:
A$
String
to
be
FP
Point
at
which
inserted
LL
SP
TT$
main
length
Length
Point
Temporary
The
lines
string
(LL)
without
of
at
which
beginning
provided
are
Searching
In
all
that
has
has
been
assumed
operated
character
first
having
character
character
storage
at
that
known.
within
been
said
that
upon
group
been
deleted
group
to
be
group
to
for
character
2000
can
the
start
strings
up
to
now
the
programmer
would
moved
be
moved
group
be
used
to
position
about
the
already
start
if
it
currently
to
be
moved
move
any
(SP),
finish
manipulation
has
were
to
starts
group
position
all
the
information
be
re-
within
(FP)
of
strings
the
and
it
31
Page 44

Advanced
Programming
Techniques
necessary
that
be the
made
program
determined
Earlier
parts
begin
SMITH’.
reverse,
be
straightforward
we
a
standard
ease,
is
the
The
is
contained
items.
the
method
characters
a
string,
would
to
are
to
programmer
according
will
in
of
full
with
and
Easy
ie
extract
might
find
the
first
name
answer
It
is
same
spaces
of
which
A$,
be
as
specify
be
by
this
names.
length.
to
within
the
searching
follows:
start
and
acted
upon.
Normally
but
the
program
to
its
built-in
determine
the
contents
chapter
then
enough
the
enough,
that
we
Even
name
be
disassembled?
is
that
spaces
can
has
for a particular
Each
made
to
parts
had
would
all
the
it
in
which
be
used
the
to
be
how
of
we
examined
of
the
into
do
from
since
one
if
we
still
information
the
form
we
full
operated
finish
points
that
which
guidelines.
to
the
string
parts
one
that
the
they
or
two
could
be
Very
work
on a particular
itself.
an
example
was
longer
way
round
whole?
are
REV:s
extract
unpredictable
needed
of
the
spaces
mentally
by
the
program,
string
for
upon. A simple
combination
of
all
the
is
far
from
determines
often
of
stored
string
in a separate
of
the
but
what
Getting
both
the
same
or
other
the
title
in
to
break
which
use
when
provided
the
position
of
characters,
sections
true
and
where
the
way
string
string
addition
form
about
MS.
or
length,
titles
from
the
its
length.
down
separate
the
name
that
of
the
method
of
the
string
it
will
changes
in
which
will
using
string
‘MS.
JANE
doing
it
MR.
should
but
then
which
aren’t
name
with
How
then
the
name
the
three
is
read
we
give
group
of
searching
TARGETS$,
not
are
the
be
to
in
and
it
a
of
140
116
SP=1
ix@
Here
TRGTS$
and
store
FOR
the
T=1
IF
MID#(AF,1,LEN¢CTRGT#))=TRGTS
=:
GOTO
NEAT
I
routine
(the
character
it
in
the
design a routine
of
information.
given
in
the
format
=f
NAMES='MR.
6@
TRGOT#="
7@
DIM
NSF
SOOO
2441
SOH2S
2014
32
REMKKRHHKRKRKKREERKKEHR
REM
STRING
REMHHEXHHHRHHEHHXERRERKKHERHERERERREREER
TT=LEN
TO
158
will
identify
variable
which
will
In
the
‘MR.
*
(354)
(NAMES)
LEN(CAS)
the
group
being
SP.
Using
unpack
example
JOHN
JOHN
SEARCH
-LENC(CTRGOT#)+1
start
position
searched
this
kind
another
given
below
BROWN’:
BROWN’
AND
-LEN
CTRGT#)
of
for)
of
technique
string
the
EEE
EXTRACT
+1
THEN
the
first
occurrence
within
the
we
containing
three
several
parts
EEHKEEER
main
string
can
quickly
units
of a name
EEE
of
Page 45

Si=i
a a Fa
2464
Md a bea)
THEN
S60
IT=0
FOR
J=i
TO
TT
IF
MID#
(NAMES,
3,LEN(TRGT#)
2070
N2#(iT)=MID#(NAME#,51,J-Si)
LEN(TRGT#) : IT=IT+i
3070
3080
3090
3100
311@
NEXT
J
N2#(IT)=MIDS(NAME#,S1)
FOR
PRINT
NEXT
I=@
TO
N2#(T)
I
IT-i
VARIABLES:
IT
Number
N2$
Array
NA(ME)$
S1
Start
TR(GT)$
TT
Last
without
of
items
used
to
Main
of
the
section
Character
character
running
discovered
hold
items
string
to
of
employed
in
NA$
off
the
end
discovered
be
searched
NA$
to
that
of
NA$
in
NA$
be
as
separator
in
searched
it
is
worth
+:
NA$
between
comparing
Chapter 3 Strings
)<>TRGT#
+:
Si=d+
IT=IT+i
items
with
TR$
The
technique
one
in
the
main
the
part
of
the
N2$.
The
search
string.
target
the
Information
addition
again.
given
verbs
instance.
to
The
routine
string
and
main
string
Such
search
can
above
In
‘intelligent’
to
them,
or
nouns, a technique
In
other
detect
entries
Regular
Because
instructions
worry
place
about
to
store
string
string
which
here
1s
string
main
string
is
then
assumes
so,
after
which
follows
techniques
be
packed
and
then a search
programs
the
routine
cases
in
the
file
structures
handling
can
having
items
to
of
to
start
searching
and,
every
from
recommenced
that
the
loop
the
can
into
which
can
be
which
the
technique
which
can
either
insert
move
the
regular
length
for
the
target
time
the
target
string
S1
up
to
the
target
at
the
character
the
main
string
does
is
finished,
last
occurrence
be
used
strings
routine
analyse
used
1s
widely
contained a certain
be
accomplished
or
delete
existing
where
takes
of
in a variety
as
shown
used
to
extract
the
to
test
for
used
in
might
be
used
portions
contents,
insertions
the
in
wording
the
word.
string
at
is
found,
string
into
after
not
end
the
rightmost
target
string.
of
applications.
the
section
the
various
of
instructions
presence
adventure
in
by
without
strings
and
games,
filing
straightforward
are
deletions
character
to
put
the
array
the
target
with
the
part
of
on
string
parts
of
certain
for
programs
having
an
to
ideal
have
33
Page 46

Advanced
to
characters
characters
up
accomplish
character.
four-character
Programming
be
made
and
If
everything
to
the
full
regularly. A single
can
soon.
length
this
In
the
items
Techniques
be
used
is
to
have
necessary
is
to
use a loop
following
whose
string
to
hold
63
four-character
an
identifiable
to
hold
to
routine, a string
position
can
with a maximum
data
place,
the
string
all
the
items.
build
up
the
is
set
up
be
specified
by
length
items,
must
The
easiest
string
capable
the
user:
of
255
50
of
five
first
be
way
character
of
storing
set
to
by
AAG
4401
AAMAS
40@1i@
©
442040
T+
4634
>
4940
9 1 #441)
44954
4464
Data
REMERHKHRHHKKREREHEKREKRKEKEKRERKREREREREE
REM
REMHXKKRHRKHEKEHEKAEKEREEEREERHKRREHREEE
At="'
NEAT
INFUT
INPUT
ae
AF=LEFT#(CAF,4#
PRINT
GOTO
can
be
following
part
by
entering
44925
4076
D
42780
4497@
IF
INPUT
(1-63):
PRINT
GOTO 4620
STRING
46026
retrieved
lines
to
‘****’
T$='#ex##'°
°5NWN
WITH SAME SIZE
:
FOR
I=1
“ENTER
‘ENTER
CCLRI;A?
FOUR
FOSITION
°0T-1))
from a numbered
the
routine,
when
“NUMBER
MIDt(At,NN#4—3,4)
enter
prompted
THEN 4070
OF
TO
252
CHARACTER
location
some
for
ITEM
+
data
the
:
At=AF+’
FOR
T#
with
and
string
input:
TO
BE
ITEMS
ITEM:
ITEM
+
MIDFCAF
equal
then
EXAMINE
(1-6
ease.
try
the
°;
Add
second
the
Items
can
as
four
spaces.
could
be
crashed
in
length.
as
described
This,
Multiple
One
problem
of
the
maximum
was
accepted
34
be
deleted
These
easily
however,
in
the
element
with
length
that
from
routines
next
chapter.
using
the
maximum
the
array
are
by
entering
can
be
overcome
string
strings
arrays
to
of a single
number
by
simply
not
very
items
store
regular
string.
redefining
robust,
which
with
some
In
the
of
items
that
were
simple
sized
items
example
which
is
not
their
to
say
four
error
of
data
given
could
positions
that
they
characters
checks,
1s
that
above
it
be
stored
Page 47

was
63.
While
many
others
accomplished
position
the
of
thus
a4
64
XT
74
[AAA
uMiii
SOHAL
SHAi4
T#
[020
5420
26H):
SJW40
3650
MIDS
2066
3476
=
SVBH
5090
2144
of
an
correct
the
place
previous
allowing
DIM
ACIS)
FOR
f=1 TO
FOR
T=1
REM
REM
REMKHERHEREHRHEKREKRKKHHKRERHRERRHHEHREREE
INFUT
IF
INPUT
°sT
LL=INTC(¢T-1)/63)
A#(LLI=LEFT#(AS(LL)
(CAF(LL) , T*#44+1)
GOTO
INFUT
"3s
NN
LL=INT((NN-1)
FRINT
GOTO
this
may
be
useful
where a greater
quite
easily
by
item
not
only
in
in
the
array
routine
1260
RRHRRERKERERKREHE
MULTIPLE
T#='s###*%’
which
will
four-character
252
TO
19
:
“ENTER
“ENTER
3160
°“ITEM
MID#
350i
TO
(AS
for a variety
capacity
would
declaring a string
terms
of
as a whole.
accomplish
items
to
=:
At(MI=AF(HI+°
A#(I)
ELEMENT
FOUR
THEN
POSITION
763) = NN=NN-6S*LL
(LL)
BE
CHARACTER
508702
=
T=T-63*#
EXAMINED
,NN#4—3,
of
be
array
its
place
in
Given
this
with a 20
be
stored
=AF(H)
RHEE
RKHRERHRHREEREE
ARRAY
FOR
,4"¥°0T-1))
Chapter 3 Strings
applications,
desirable.
there
This
and calculating
the
string
but
below
is
an
adaptation
element
and
accessed:
©
=:
=:
NEXT
ITEM:
ITEM
LL
4)
(¢i-i
+
T#
¢1-12606)
can
also
array,
NE
‘s
+
are
be
the
of
VARIABLES:
LL
The
line
dividing
T/NN
the
Originally
transformed
Data
In
worked
positions
an
is
the
item
done
in
variable
two
previous
with
of
placed
to
other
number
desired
number
into
position
were
items
in
at
position
positions.
in
which
position
by
of
of
item
length
sections
of a fixed
the
it
strings
23
Not
the
new
item
the
length
item
to
in
line
LL
strings
has
been
length.
will
all
The
are
fixed.
remain
applications,
must
of
the
lines
be
inserted
assumed
advantage
There
at
position
however,
be
in
that
are
placed,
the
array
or
examined
the
strings
of this
always
23
63
no
require
obtained
being
is
that
items
matter
what
the
by
but
the
and
full
35
Page 48

Advanced
length
of
list
of
items,
run
through
routine
a
list
of
Programming
the
string
whether
one
which
will
up
to
1240 items
Techniques
in
memory.
in a particular
by
one,
added
allow
four-character
to
be
Very
often
to
or
searched
order
deleted
items
for
or
the
need
or
not,
from.
to
be
deleted:
is
to
keep a compact
which
simply
Given
added
to
below
the
front
can
be
is
of
a
SHOHH
6061
OYA
610@
6128
TOP:
6138
6149
6150
620A
6201
5202
6210
ERTED:
6220
OR
6220
6240
6250
6260
RE
MEER
HRERERKRREREEREKREERREHRKREHREKREKRE
REM
VARIABLE
REMEBER
DIM
INPUT
HEERHREBRERKRHEHRERHRREMRKHHHREREHREHEHE
A#(19)
"1=INSERT/2=FIND/3=DELETE/4=S
":FF
ON FF
GOTO
GOSUB
4170
END
REMEBER
REM
REF
INPUT
IF
I=1
INSERT
RHEE
":
INS
IT=124@
TO
2000
HRHHEKRERHEHKREBRHRERERHREHRERHRHEHEEEH
HRKRHRRHRKRHKHKEKRERHRHRHERERE
"FOUR
AF(M)=INS+4$(0)
IF
LEN(A#$(@))<252
FOR
I=@
TO
TTS=RIGHT#(AS(1),4)
#(1),LEN(A#(I))—-4)
6270
)<252
6288
6298
63@1
6302
6310
ARCHED
6320
6330
6340
6350 NEXT
@0 : NEXT
6370
A¥(I4+1)=TT#4+AE(I41)
THEN
NEXT
6290
I
RETURN
SMA
REMBRHEEHREHRHRRRHEHRRHRHRHRERRHRERMRHRHREKREHRHRERKE
REM
SEARCH
RE
PMEEEERERRHRBERREHRHHEHHRKRHEHRBRHRHRHHREHEHRBREHE
INPUT
FOR";
FOR
"FOUR
I=1
IN
TO
LL=INT((I-1)/62)
IF
MID#(A#(LL)
I
3460
PRINT
PRINT
"NOT
:
GOTO 4390
"PRESENT
LENGTH
STRING
462700,6500,6400,6150
CHARCTER
THEN
:
NEXT
FRINT
=
ITEM
:
GOTO
IT=IT+1
THEN
"NO
46290
6290
18
2:
AS(I)=LEFT#(A
+:
IF
LEN(AS(IF1
CHARACTER
ITEM
IT
:
PP=4*(I-LL*62)—-3
,PP,4)=IN#
FRESENT"
AT
:
ITEM
THEN
FOR
NO.":I
ARRAYS
RRR
TO
BE
ROOM"
TO BE
J=1
EH
HRHREH
INS
:
SE
6370
TO
20
:
INF
F
36
Page 49

UT
63806
6398
5400
6401
56402
641406
2":
6420
64236
L)
,PF+4)
6444
6450
@4
64654
RF
AX(I)=""
6470
€
(A$
6480
6490
6500
“CONTINUE
IF
LEFT#(03,1)="Y¥"
RETURN
REMHXXKRERKEEKHEKKRERHREHKEREREKHREREERE
REM
REMHXKREHEKEHKREEEHE
INPUT
INS
GOSUB
AF(LL)=LEFT#
I[T=IT-i
PRINTINE:"
=
NEXT
FOR
LN=248-LEN(A$(I)D
CI+1)
AX+(CI+1)=MIDt
NEXT
RETURN
DELETE
“FOUR
6220
I=1i1
THEN
,LN)
I
SEARCH:
:
DELETED"
T0
18
6490
"30%
CHARACTER
IF
I
(AF
(LL)
:
IF
=
(AFCI+1)
THEN
KEKE
HRHREREERHRERERHEEE
2+
IT
,PP-1)+MIDS
:
LEN(AP(I))=248
ASCII=APCI)D+LEFT
,LN+1)
ITEM
THEN
FOR
633560
TO
I=i
Chapter 3 Strings
DELET
6506
(At
(CL
TO
20
O
VARIABLES
FF
the
number
IT
the
number
TT$
temporary
the
length
be
added
without
LL
current
PP
position
LN
length
Take
some
little
daunting
is
to
apply
novel
feature
length
testing
string
array
deletions
of a string
first
length,
without
are
USED:
of
the
of
four-character
variable
of
one
line
exceeding
line
being
of
item
of
item
to
time
to
at
first,
some
of
is
the
reaches
to
see
whether
the
new
danger.
made.
function
used
in
the
dealt
in
line
LL
be
moved
study
there
the
techniques
way
items
item
The
chosen
items
to
transfer
array
reaches
the
maximum
with
in
the
of
the
array
down
the
this
routine
is
little
really
described
are
transferred
252.
This
adding a new
can
always
reverse
by
the
user
in
the
array
an
item
252,
length
array
array
because,
new
is
done
item
be
added
procedure
to
ie
another
of
when
although
in
it,
all
in
this
from
in
order
would
to
is
the
next
item
255
deleting
it
that
has
chapter.
string
to
that,
result
the
beginning
carried
line
could
may
seem
been
The
string
rather
in
an
out
when
not
a
done
one
if
the
than
illegal
of
the
when
37
Page 50

Advanced
Programming
Techniques
Garbage
When
strings
every
in
fact
any
other
rearrange
strings
to
make
that
redefining a string
memory
are
being
problem
‘garbage
is
really
does
not
the
OUT
If
you
64’s
FRE
an
accurate
PRINT
collection
using
complex
around
now
and
that
is
machine
its
are
only
room
area.
done
will
become
collection’,
needed
always
OF
MEMORY
run
into
function,
value
FRE
in
arrays
then
notice
exactly
which
memory
moved
for
something
The
result
the
is
used
take
this
which
for
the
(@)
string
routines
or
redefining
that
what
it
uses
to
make
about
to
be
is
that
memory
acute
and
or
the
tidying
for
place
in
error
problem
forces
amount
which
strings
the
64
does.
When
Commodore
the
fullest
in
the
memory
which
has
shorter
does
when
will
gradually
the
64
up
strings.
time
Unfortunately,
to
prevent
message.
in
your
garbage
of
free
involve a great
within
appears
the
to
pause. I say
redefining a string
BASIC 2 does
use
of
when
absolutely
increased
not
large
will
of
the
programs
free
amounts
fill
up.
embark
memory
the
machine
the
in
memory
on
solution
collection
memory
available.
deal
of
memory,
you
appears,
the
not
the
space
available,
necessary
length.
garbage
in
That
in
the
of
string
handling
After a while
what
is
known
so
that
only
collection
stopping
is
to
order
to
Thus:
moving
may
64,
or
fully
means
string
the
as
what
with
use
the
provide
(the
value
bytes
of
memory. A slight
numbers
as
entering
PRINT
i@
it
24.
=4
Run
of
the
the
from
but
65536
in
DIM
FRINT
PRINTFRE
LIST
the
screen,
space
the
running
in
minus
everything
line
program
after
program
displayed.
works
with
38
in
brackets
the
range
the
15
Ati2z18)
‘CCLRI’
with
PRINT
the
The
reason
16
bit
makes
—32768
number
exactly
but
no
(@)
and
you
the
listing
the
amount
program
for
integer
no
difference),
complication
to
32767.
of
free
as
it
space
after
should
below.
in
line
15.
of
free
again
this
is
to
arithmetic.
is
Anything
bytes.
appears
the
PRINT
see
the
Go
down
Because
memory
results
do
with
Strictly
will
that
Try
below
in
value
to
you
should
in
the
the
fact
this
print
the
number
FRE
can
only
over
32767
the
following
with a space
line
20:
32767
printed
the
listing
have
removed
now
be
value
—32768
that
the
FRE
should
mean
of
cope
is
expressed
program,
after
at
the
and
take
one
32768
bytes,
function
that
free
with
the
top
out
byte
being
any
Page 51

Chapter 3 Strings
number
the
the
bit
problem
explanation)
The
MM=FRE(@)
All
is
thus
include a line
1@@
at
program a little,
employed
from
highest
number
must
be
is
following
this
is a little
that
to
use
avoiding
T=FRE
some
point
zero
bit
of
is
negative,
used,
to
use a logical
to
convert
line
s
bit
it
in
any
such
()
where
since
if
experience
Conclusion
Once
you
have
made
you
will
never
again
which
LEFT$,
Every
part
cannot
for
slicker
understandable
the
beginning
upon
more
make
MID$
string
handling
of a string
be
done
more
efficient
programs
important
of
this
frequently
than
repay
heavy
and
and
to a string.
format,
parts
chapter,
in
the
to
63535
can
be
the
binary
is
interpreted
so
number
any
number
condition
negative
will
always
PRINT
return
MM—-6552468
of a digression.
any
way
during a program
danger
of a false
as:
it
will
be
executed
garbage
shows
the
need
use
RIGHTS$
collection
it
to
techniques
to
despair
of
string
functions
technique
with
intelligent
Not
only
data
storage,
which
leaving
of
what
what
follows,
effort
allow
the
the
has
the
techniques
involved
expressed.
is
reserved
greater
as a minus
(see
numbers
the
correct
The
real
OUT
OF
regularly.
takes
be
necessary.
described
when
handling
coupled
basically
use
it
of
variables
does
allows
user
does
this
the
to
program
been
entered.
described
so
don’t
skip
in
understanding
In-fact
what
for
indicating
than
32767,
number.
the
to
the
The
separate
correct
value:
(MM<@)
purpose
forces
of
garbage
MEMORY
This
will
time
and
in
this
chapter
confronted
techniques,
with a mass
no
more
there
open
up
programmer
input
strings
to
do
the
work
As
mentioned
here
the
material
it
fully.
happens.1s
whether
where
answer
chapter
positive
mentioning
collection,
error.
slow
down
it
should
only
your
with
programs
crammed
of
variables.
than
identify
is
very
little
wide
possibilities
to
write
in a more
of
identifying
will
be
here.
that
the
16
to
the
for
an
ones.
FRE
Simply
the
be
own,
with
a
that
far
at
the
drawn
It
will
39
Page 52
Page 53

CHAPTER
4
Inputting
One
of
the
greatest
and
the
powerful
micro
is
interactive,
user
to
work
with a program
people’s
both
made
of
not
the
even
debugged.
to
the
processes
built
program
of
the
important
to
computers
possible
back
applications
executed
the
hands.
often a painful
people
for
all
experience
programs
of
what
running
until
whole
The
the
the
process
began
result
anticipate
program’s
carried
in,
in
the
was
the
program,
program
decision
be
run
again
The
modern
today,
to
execute
to
the
they
tasks
to
be
Such
took
the
programs
careless.
and
was
program
following
to
get
was
everything
execution.
correct
submitted.
could
the
micro
user
programs
will
performed,
freedom,
care
After
Information
differences
mainframe
it
responds
of
computers
all
the
input,
then
would
day,
had
to
an
idea
that
the
out
during
order
they
all
had
be
designed
had
been
following
has
for
instance
on
machines
as
it
was
now
be
able
however,
process,
with
their
to
work
all,
the
be
programmer,
that
If
non-interactive
on.
between
computers
immediately
as
it
was
necessary
the
program
not
be
and
errors
repeated
of
what
was
going
If
there
the
course
and
with
decisions
to
be
anticipated,
to
overlooked
day.
changed
games,
which
run.
take
it
to
feed
in
with
the
brings
programs
Instant
results
of
refer
More
control
the
micro-computers
of
the
to
is
running.
of
machines
data
first,
was
run.
obtained
over
the
or
were
of
all
had
in
the
and
program
at
least
to
happen
going
the
the
to
be
for
program
over
program
necessary
for
to
the
user
then
the
that
situation.
would
did
not
allow
importantly,
for
granted
information,
of
the
its
own
problems.
programming
and
with
interactive
the
program
past
is
that
the
user
and
Before
without
the
which
Very
often
several
had
any
hours,
could
again
before
did
when
the
successful
during
to
be
several
they
data,
taken
during
there
was
for a decision.
program
Some
applications
simply
the
not
program
users
that
as
the
make
decisions
program
always
Though
did
the
choosing
computing
will
be
with
of
the
allows
micro,
to
be
tests
the
mean
it
was
one,
the
course
different
all
had
before
the
no
way
would
have
of
program
ensure
of
the
has
made
us
today
modern
the
most
given
being
results
perhaps
that
the
user
fully
had
of
to
be
the
course
that
If
an
have
of
been
to
refer
serious
is
about
in
their
it
was
that
data
us
almost
41
Page 54

Advanced
Programming
Techniques
immediately,
and
the
A
good
is
spelled
and
every
the
user
refers
to
operate.
a
process, a good
not
unintentionally
corrupt
In
this
accept
information.
methods
so
program
program
out
in
possible
to
input
the
user
Given
its
stored
chapter
by
which
information.
Entering
The
Commodore
information:
while a program
have
their
strengths
almost
more
on
Almost
arrows
satisfied
is
upper
to
beginning
two
characters
need
in
where
makes
remains
they
exclusively'on
appropriate
The
main
the
screen,
as
important,
in
combination
that
terminated
INPUT
INPUT
does
limit
of
of
consecutive
it
to
terminate
programs
you
wish
no
response.
the
are
running.
advantage
what
by
80
80
characters
the
cannot
which
workhorse
if
anything
run
again.
today
is
such a way
that
important
information
important
the
ease with
program
feed
is
in
material
information.
we
look
at
In
the
the
program
64
provides
is
being
run,
though
INPUT,
to
make
use
of
INPUT
and
letters
what
or
1s
with
is
on
the
screen
pressing
have
characters
line
screen
RETURN.
disadvantages,
on
you
after
the
lines
deal
with
every
entry
require a large
to
continue
with
Despite
of
most
has
gone
not
so
much
it
will
not
decision
in
as
flexible a way
decisions
which
mistakes
also
one
which
some
of
next
chapter
can
be
INPUT
two
basic
the
INPUT
the
majority
even
of
GET.
is
that
numbers
being
entered
the
insert
and
is
exactly
however.
the
information
need
to
INPUT
can
properly,
with a RETURN
these
prompt,
be
accepted).
number
the
execution
drawbacks
programs
wrong
one
it
can
where
cause a hiccup
anticipated.
It
as
as to
the
way
can
be
which
ensures
causes
the
we
protected
ways
of
in
cases
it
is
can
the
ways
in
shall
examine
against
of
entering
and
GET
home-grown
where
clear
cut. A prompt
be
entered
can
be
edited
delete
keys.
what
is
which
Firstly
that
can
move
the
since
Secondly
such
as
the
can
of
responses
of
the
the
that
accept
be
quickly
every
item
in
the
is
one
which
possible
the
program
made
during
that
the
program
programs
some
mistakes
information
statements.
programs
it
would
and
using
When
desired,
cursor
only
it
does
be
entered
down
the
the
contents
there
comma.
Thirdly
be a real
from
the
program
INPUT
information
put
right
of
data
program,
allows
and
which
is
to
such
user
does
to
stop
or
can
of
the
in
that
Both
rely
be
far
appears
displayed.
the
cursor
the
user
is
INPUT
place
an
(even
to
the
of
are
several
the
limitation
user
or
if
the
user
statement
while
Simple
1)
Entry
42
entries
ofa
single
with
string:
INPUT
Page 55

12
INFUT
2)
Entry
i@
INPUT
3)
Entry
1@
INFUT
(GEFPARATED
“ENTER
of a single
‘ENTER
of
several
strings:
‘'SURNARIE,
number:
BY
A
STRING’:
A
NUMBER’:
FIRST
COMMAS)
NAME
°:
Chapter 4 Inputting
At
4
AND
SEX
SNE,
CNE,
Information
SAS
Screens
Note
here
the
three
of
entering
display
ENTER
BY
7?
DAVID
2?
MALE
4)
Entry
146
INPUT
This
would
strings
may
SURNAME,
(SEPARATED
how
separate
commas,
would
SURNAME,
COMMAS)
of
several
behave
be
LAWRENCE
the
commas
strings
appear
like
SY
numbers:
“NUMERIC
in
the
mixed
in
,DAVID,
in
the
the
user
this:
FIRST
LAWRENCE
same
the
same
FIRST
BY
the
information
INPUT
presses
ITEMS
way
input
NAME
COPFMAS)
MALE
statement
RETURN
NAME
1-3:":;A48,5,C
as
the
string
line.
AND
*
<RETURN>
entered
AND
input
SEX
are
used
is
expecting.
after
each
SEX
in
3).
to
identify
If,
instead
item,
(SEFARATED
Numbers
the
and
INPUT
The
flexible
statement,
appearance
of
several
screen-handling
can
be
used
of
the
screen.
items
of
to
reduce
When
using
the
64,
the
clutter
several
the
same
combined
that
inputs
with
so
have
screen
the
often
spoils
to
be
made
line
INPUT
the
in
43
Page 56

Advanced
Programming
Techniques
succession,
them
all
at
same
line,
1)
Overwriting
bo
PS
PPT
“iy
PMPOP|
In
this
case
moves
one
all
each
problem
previous
case,
below
that
eM
FRINT
where
Using
would
the
is
prompt
which
entry
each
O$
this
always
for
instance,
once,
it
is a trivial
each
overwriting
of
INPUTs:
UC
Decor
Pele
the
PRINT
print
position
where
you
necessary
and
all
will
may
INPUT
line
OF
is a string
method,
be
placed
O$
and
the
fer
statement
to
the
wish
the
is
to
put a ‘cursor
the
entries
arise
with
not
be
fully
would
=
INFUT
of
39
spaces,
would
on a clean
it
is
not
matter
previous
bo
at
desired
INPUT
will
entries
erased
consist
of
“CCU
preceded
clear
up
line.
essential
to
arrange
one.
gel
line
10
1s
screen
prompts
up’
character
be
made
of
different
by
the
something
ITEM
to
the
end
that
the
user
be
all
the
input
to
simply
location,
to
appear.
on
the
an
at
which
the
same
example
From
beginning
lengths
subsequent
ones.
like:
1’
salt
by a cursor-up
of
the
line
and
able
to
see
fall
on
the
which
should
then
be
on
of
line.
One
is
that
the
In
that
character.
the
input
2)
Entries
provided
format
14
<4
“M4
of
INPUT
PRINT
PRINT
you
the
INPUT
Few
methods
boxes
into
the
use
of
individual
to
them.
The
44
can
of
course
are
sure
screen:
‘ITEM
CCUJCLI@*#CRIs:IMPFUT
CCUAIL2@*#CRIs:
to
screen
of
entry
which
the
GET,
it
entries
are
method
boxes
look
entries
can
also
not
would
be
that
i:
going
spaced
they
will
‘°:A?
more
professional
are
made.
be
done
to
be
be
something
across
not
INPUT
Though
with
longer
the
screen
overrun
‘ITEM
‘ITEM
than a screen
this
INPUT
than
along
the
as
the
line
2:
32:
is
better
if
you
are
the
boxes
following
well
and
';8t
°;C#
with
tackled
sure
you
lines:
as
down,
spoil
the
inverse
by
that
the
allocate
Page 57

i@
FRINT
24
INPUT
Line
10
would
space
for
the
INPUT
the
be
cancel
laying
any
errors
prompt
[RVS]
at
in
reversed
the
RVS
It
is
worth
out
your
program a great
that
will
GET
Useful
are
command,
function
key
before
keyboard
that
in
entered,
desirable
the
though
irksome.
is
is
being
deciding
no
key
cases
where
where
user
is
and
or
not
‘(C9
SFACESI
“LCUd
ITEM
place a 10
intended
the
lettering.
and
taking
INPUTs
be
INPUT
In
GET.
to
read
depressed.
either
is
being
you
where
prompt
begins
with a cursor-up
end
of
the
Pressing
subsequent
the
trouble
on
deal
easier
made
in
is,
order
to
GET
the
keyboard,
GET
what
an
accepts
depressed.
wish
to
single
key
you
do
is
depressing a key.
CRVSI
i:
bLRV51°:A
space
inverse
in
non-inverse
prompt
ensures
RETURN
printing
to
experiment
the
screen. A clearly
to
use
and
entries.
there
are
many
overcome
harder
to
that
does
not
wait
entry
finally
the
first
character
GET
is
examine
commands
not
wish
the
(without
the
Chapter 4 Inputting
Cig
box
on
lettering
to
move
that
at
will
be
in
reduces
occasions
this,
64
BASIC
use
than
is
to
say
for
RETURN
is,
each
it
therefore
length
the
program
SPACES’
the
screen,
back
whatever
the
end
the
normal
with
formatted
the
where
in
front
to
the
is
of
the
the
many
screen
number
its
with
right
mode.
provides
INPUT,
detect
use
comes
since
whether
to
of
GET
across
be
particularly
of
an
entry
as
use
of
RETURN)
to
wait
for
Information
enough
of
it.
The
line
and
entered
entry
ways
will
will
of
makes
of
careless
limitations
another
its
sole
or
not
a
depressed
scans
the
or
registers
appropriate
it
is
being
are
an
entry
if
GET
The
pressed:
1@
On
whether
A$
the
indefinitely
take
will
various
and
classic
encountering
will
line
pass
Slick
use
GET
At
or
not
be
given a null
will
cause
until a key
on
the
value
on
to
applications
stages
creating a waiting
of
GET
is
to
provide a waiting
s
IF
this
any
key
the
of
the
following
during
Ax=""
line
the
is
being
value
line
to
is
pressed.
the
character
line.
programs
their
THEN
program
depressed.
and
the
be
re-executed.
The
that
which
execution
state
state
14
will
execute
If
nothing
IF
statement
The
program
moment a key
key
represents
provide
will
the
most
often
until a single
GET
and
determine
is
in
found,
the
the
second
will
is
pressed,
and
the
choices
with
user
use
make
key
string
part
of
thus
wait
A$
will
program
at
this
of
45
is
Page 58

Advanced
form
to
after
use
Programming
of
GET.
depress a single
every
entry.
of
GET:
Techniques
When a number
key
that
to
Given
below
of
choices
constantly
have
be
is a typical
to
be
having
program
made
to
press
menu
it
is
far
RETURN
which
easier
makes
i444
iW™i@
iM@f24
iff
14446
i434
i466
i476
1480
Hi
iMG
Here
call
up
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
GET
TY=VAL
ON
GOTO
all
that
that
INS
TT
is
part
Bl
ple
oul
“CODI
+:
(A)
GOSUR
1800
required
of
the
Moving a cursor
Games
comes
1DAH
i@41
1AAS
i@i44
i426
14246
1446
i4@S6
1466
i@7@
Lic
1484
programs
to
moving
too
objects
REMEHHKHKRKHKHKEHRKHKKKERERERHRHERRER
REM
MOVING
REMRRXRREXKREKKERHREREREHEKHEERRRKEREKEEE
GET
TF
PRINT
FOR
PRINT
FOR
IF
IF
OR
T#="COCRIS
GOTO
°*
I=1
TO
“CSPACEICCLI’:
[=1
TO
T#=""
T#+°CCUI’
144004
QUIT
FNTER
DELETE
ALTER
=
DISPLAY
WHICH
Ik
IN¢=*° THEN
10000,
is
that
the
program.
with
GET
make
extensive
around a screen:
CURSOR
CCLI’s;
3®@
=:
3@
=:
THEN
140%
OR
THEN
PROGRAM
NEW
DATA’
ITEMS’
ITEMS
DATA’
DO
YOU
2000,
user
touch
use
of
NEXT
NEXT
T#="CCDI"
PRINT
~
*
REQUIRE’’;
10460
2004 , 4000
0,
1,
2, 3,
GET,
OR
T4;
,50
or 4 in
order
especially
when
TH='CC
to
it
This
routine
screen
the
that
Statement
46
until a key
cursor
you
provides a simple
is
pressed.
appears
need
and,
to
do
if
it
to
is
is
to
flash
rather
examine
one
of
flashing
The
two
than
the
the
cursor
‘*’
cursor
loops
provide a short
flicker.
character
move
which
To
move
placed
into
characters,
will
pause
the
T$
to
flash
on
so
cursor,
by
the
PRINT
the
that
all
GET
it.
Page 59

The
print
cursor
position
routine.
will
move
and
you
Chapter 4 Inputting
can
then
re-execute
Information
the
flashing
GET
In
allow
and
games
the
stopping
this
is
asimple
i@
FOR
20
GET
20
NEXT
AQ
IF
Here
the
which
to
can
be
executed,
1000
iterations
line
40.
GET
We
a
GET
while
up
and
have
specific
can
it
to
and
timed
and
sometimes
user a certain
the
program
matter:
i=i
TO
T# : IF
I
T#i>'’
user
has
the
respond.
already
position
be
1s
still
including
If a response
as
of
the
inverse
seen
for
vital
because
being
10
responses
in
more
amount
of
indefinitely.
iaaa
T#<>"°
THEN
time
in
loop,
that
it,
made.
characters
it
line
40.
the
boxes
an
say
it
The
GOSUB
will
is
If
program
effective
an
inverse
can
following
in
serious
take
made
no
applications
time
to
make a response,
Using
GET
THEN
320
to
execute
then a particular
key
has
continues
way
of
box.
be
used
to
routine
length:
it
and a suitably
1=1066
the
loop
course
been
depressed
at
the
entering
In
detect
this
how
will
data
kind
long
accept
can
be
useful
rather
sized
1000
of
during
line
following
is
to
set
of
application
an
any
than
loop,
times
action
the
aside
entry
entry
to
in
is
PAGO
=0@01
SHOP
=~Oi@
2420
2026
2640
2@50
2460
~40
2470
ENCIN#)-1)
GOTO
“O86
-“090
REMEHHEXEKHREKEKRHRHRHERKREREREREREREEE
REM
REMEXHEHEHRRKERKKKERRHEKERRERRREEE
INS=*°
PRINT
PRINT
GET
IF
IF
IF
2046
PRINT
INt=INS+TS
ENTRY
‘C7
‘'CCUIITEM
T#¥
=:
T#=CHR#(13)
T#=CHR#(20)
T#=CHRE
=:
TT;
TO
INVERSE
SPACESICRVSI£CI“OW
i1:-LRV5S1°;
IF
T="
THEN
AND
(20)
PRINT
THEN
‘“COLICSPACEILCLI‘;
BOX
THEN
2116
LENCINS)=@
IN¢=LEFT#
2646
WITH
SFACESI’
GET
THEN
CINS,L
:
Page 60

Advanced
Programming
Techniques
=ifiA
“116
Here
print
the
already
erased,
cursor
either
a
the
position
box.
move
when
length
IF
STOP
box
If
the
something
both
from
arrows
RETURN
of 10
Using a routine
you
desire
and
spoiled
Screen
GET
is
difficult
the
The
the
same
applications
What
it
then
it.
character
or
can
also
imposed
with
screen
64
allows
cursor
techniques
The
following
is
does
as
it
is
entered.
the
routine
The
only
the
editing
by
and
over
are
limitation
length
LENCIN¢)<
is
printed
at
the
beginning
DEL
key
in
the
the
screen and
as
the
(CHR$§(13))
characters.
such
as
thus
ensure
structure
of
with
be
used
both
INPUT
INPUT.
being
you
existing
is
to
The
able
to
perform
can
be
seldom
routine
allow
If
A$
could
ofa
string.
and
lines
simple.
also
is
14
and
the
of
is
pressed
box,
routine
this
you
that
arrays
GET
to
overcome
to
edit
technique
to
record
screen
and
applied
is
fairly
the
user
began
as a string
be
used
the
absolute
THEN 2040
prompt
the
placed
box.
(CHR$(20)),
the
last
letter
from
the
stands,
can
the
only
is
pressed,
prevent
desired
corrupted.
the
existing
of
changing
those
changes
editing
adding
complex
to
to
strings
but
to
enter a string
which
to
print
one
in
front
of
Letters
can
then
provided
of
what
has
memory — you
DEL.
Entry
or
when
the
an
entry
being
layout
limit
strings,
on
or
subtracting
on
its
of
of
length
something
things
is
called
program
the
screen,
purpose
the
as
listings
(called
was
already
it
to
the
screen
imposed
by
the
it,
leaving
be
typed
that
there
been
input
cannot
use
is
terminated
entry
reaches
longer
screen
of
strings
they
screen
from
which
that
is
appear
editing.
by
moving
them.
is
though
is a simple
A$)
and
to
in
memory,
and
change
maximum
the
into
is
is
the
than
not
very
on
The
such
one.
edit
255
SHAG
S401
SHAS
S010
S420
S436
SYV48
“434
2466
714
2076
Pd
CH
48
REM
XHKHKRKRKHREREKKKKKRREKRKRERERREEE
REM
SCREEN
EDITING
REMKRXHKRERERKKEKHEKREKEERKRERRERERERE
DEF
FNACP)
=1624+LL*#40+P
AF="LCI*SPACEI*
P=4@
2:
Li=igo
PRINT
FRINT
CH=PEER
:
PORE
FOR
°“CHOMEILiIB*CDI°
At
(CFNACP))
FNACF?
TT=1
,160
TO
3 : NEXT
=
FOKE
34272+FNACP)
TT
:
FOKE
FNAC
Page 61

Chapter 4 Inputting
Information
=080
2990
GET
T# : IF
IF
TS#=CHR#(i3)
T#='’
OR
THEN
LEN(A$)=255
STOF
=1@@
Sii@
#)-1 : GOTO
S120
£(A$,P-1)4+MID#$(A$,P4+i):
S156
314@
S150
IF
T#=CHR#(95)
IF
T#=CHR#(95)
040
IF
P>@
AND
IF
T#=CHR#(2@)
IF
T#=’CCUI’
IF
T#<>‘CCL]’
AND
F4>@
AND
F=@
T#=CHR#(2@)
P=P-i
THEN
OR
AND
3040
T#=‘CCD1‘’
T#<2>°CCR]’
$=LEFT#(A#,P)+T#4+MIDE(AF,P41)
2160
2170
IF
T#='CCLI’
IF
T#=’CCRI‘
AND
F>@
AND
FPSLEN(A#)—-i
THEN
=F+i
2180
Unpacking
3000
it
such a function
screen
User-defined
This
does
GOTO
is
to
and
3040
the
routine,
is
an
important
PEEK a particular
in
order
remember
functions
what
function
to
be
it
in
case
are
described
we
find
1s
when
character
able
to
we
wish
this:
it
position
detect
to
more
comes
replace
fully
=@4@
THEN
THEN
THEN
to
on
later
in
Chapter
P=LEN(4G
@#=LEFT
THEN
:
P=F4+1
P=F-i
screen
the
screen.
what
is
it
in
the
THEN
S839
3046
THEN
THEN
editing.
We
already
same
position.
12.
&
F
What
need
on
the
3020
In
order
to
edit.
This
string
as a single
it
would
be
a
space
to
3030
The
the
cursor
3040-3050
number
3060
of
Into
3070
the
of
This
the
character
its
place
The
screen
time
to
start
on
line
assumes
space.
temporarily
the
end
of
the
variable P is
in
the
string,
starting
This
line
prints
‘cursor
line
for a fraction
downs’.
uses
the
at
position P in
is
POKEd
taken
defined
to
the
process
that
we
are
If
the
intention
renamed
string.
used
an
inverse
execute
of a second,
during
the
the
desired
function
line
the
A$
space.
of
editing a string,
starting
and
the
numbering
LL
small
then
from
was
to
this
routine
at
string
to
discover
and
store
loop
the
original
scratch
edit
an
existing
line
would
to
record
zero.
on a line
the
screen-code
it
in
keeps
the
character
we
need a string
and
begins
string
be
used
the
position
dictated
the
variable
inverse
space
is
replaced
our
then
to
add
by
the
value
CH.
on
of
49
Page 62

Advanced
on
3080
is
being
3090
This
the
routine
GOTO
created
the
screen.
Having
depressed.
To
reach
line
tests
string
is
another
string.
Programming
being
terminated.
character,
3100
If
the
keyboard,
—
provided
3110
If
the
at
the
beginning
the
line.
These
around
the
flashed
If
this
part
to
see
edited
part
Before
the
space
character
then
the
that
it
is
left
arrow
of
two
string.
Techniques
the
cursor,
not,
the
of
the
whether
is
already
In
actual
of
the
using
that
was
entered
print
position
not
already
has
been
the
line,
lines
this
cursor
routine,
the
key
use
program
the
added
is
the
there.
entered
then
are
added
line
is
flashed
the
user
depressed
255
characters
you
would
which
string,
at
the
beginning.
‘left
arrow’
(P)
is
reset
and
the
print
simply
checks
again.
must
was
not
would
you
would
at
to
the
the
position
to
to
see
whether a key
have
depressed a key.
RETURN
long.
In
use a STOP
make
use
strip
the
top
beginning
print
position
jumps
make
it
or
either
but
of
the
off
left
hand
of
is
to
the
easier
is
whether
case
the
would
newly
the
last
of
the
the
line
already
end
of
to
move
3120-3130
line,
flashing
3140-3150
then
characters
the
right
3160-3180
the
cursor
string.
Using
Provided
pressing
cursor.
If
the
character
from
to
make
These
left
All
that
this
information
cursor
arrows,
information
record
allows
program
kind
the
you
of
method
position
to
noting
examination
50
the
delete
The
the
character
the
use
lines
or
right
is
altered
routine
onto
any
add
into
memory.
move
which
is
far
and
that
the
key
program
entered
is
added
into
cursor
of
it.
test
position
The
to
arrow.
is
the
and a little
position
or
delete
You
of
the
cursor
up
and
down
of
the
easier
then
re-entering
print
position
will
remove
then
returns
is
the
string
see
whether
In
this
position
imagination
on
the
characters
can,
down
between
lines
is
on
the
user
the
to
not
one
string
at
onwards
is
then
the
case
there
at
which
screen,
and
if
you
wish,
the
screen
different
being
than
it
in
full
is
not
at
the
character
the
flashing
of
the
cursor
the
cursor
being
moved
reprinted.
character
the
you
edit
is
no
cursor
will
it
using
then
add
as
entered
need
replace
another
well
lines
edited
at
having
in
its
any
to
altered
beginning
to
the
cursor
move
position,
to
will
be
able
the
left
routine.
arrows,
with
one
space
was
reprint
be
flashed.
to
left
and
the
of
the
of
the
either
the
place
right
edited
variable
as
across.
of
text
one
recall a string
with
time.
form.
This
the
This
for
For
all
to
to
Page 63

Chapter 4 Inputting
Information
programs
routine
program
Simple
For
possible
will
deal
number
in
front
iff
114
i244
With
provided
the
where
of
this
and
screen-editing
all
the
flexibility
to
perform
not
be
able
with
one
to
be
of
it:
At=—*ABCDEGFE
PRINT
INPUT
this
method
by
64
will
accept
Conclusion
The
input
of
otherwise
cluttered
often
formatting
with
with
make
Which
but
with
your
prompts,
can
be
excellent
screen,
be
entered
will
different
each
prompt
the
responses
method
the
program
one
sure
that
information
type
can
one
which
is a joy
given
screen-editing
to
input
string
at a time.
edited
on
the
TAB(9)
“CCUJITEM
you
can
the
64’s
operating
whatever
information
program.
with
unclear
wrongly
make
all
colours
attached
ending
stand
or
format
techniques
need
ever
after
another
the
information
has
make
to
using
to
us
more
than
To
screen
’
At
use
all
system
is
after
is
one
Information
prompts
and
will
the
difference,
to
in a black
out
on
the
you
prefer
outlined
again
be
on
the
you
to
be
regularly
the
difference
use..
INPUT
by a routine
using
INPUT
80
characters
achieve
with
1:
the
the
area
successive
in
limited
screen.
this,
enough
°3A
automatic
and,
prompt
where
and
certainly
as
will
colour
screen
from
will
be a matter
this
chapter
to
It
obtain
with
updated
and
between a cumbersome
such
as
that
above,
statements,
in
this
simply
room
screen
when
you
as
the
it
is
very
which
in
no
be
tiring
the
prompts,
control
the
there
boring
remains
your
for
new
is
apparent
added
character
prompts
lists
to
prompts
though
way
and
print
the
the
input
editing
press
RETURN,
form
of
easy
to
requested
order
to
enter.
use
of
for
instance,
which
themselves.
of
personal
is
no
reason
of
single
be
seen
1s
altered
it
is
still
a
you
can
only
string
or
prompt
facilities
A$.
spoil
an
on
a
will
Proper
colour,
but
will
choice
why
colour
how
you
correct.
51
Page 64
Page 65

CHAPTER
5
Error
There
said
enough
attractive
user
this
be
made
Trapping
is
no
about
idiot.
and
makes
chapter
more
unexpected
techniques
common
likely
to
make
sense,
Avoiding
Why
do
people
programs?
down
think.
enough
be
that
or
that
each
work
for
most
making
limitations
meant
such a way
happening
With
which
The
to
the
Most
in
the
the
prompts
the
screen
prompt,
halfway
of
the
it
clear.
of
to
be
from
this
will
eliminate
such
thing
as
an
idiot-proof
any
program
Even
useful
an
input
we
shall
robust,
or
ridiculous
in
the
an
attempt
and
to
is
so,
there
program
which
examine
that
is
data
chapter,
to
be
one
step
that
are
which
cannot
some
to
is
for
understand
errors — common
insist
on
making
answers
fact
that
input
way
it
may
through a program,
time
Whatever
the
used
as
to
moment
in
mind
are
your
errors
that
information
you
give
is
too
be that
then
people
and
that
make
we
can
the
vast
many
favourite
arise
because
with
cluttered
you
suddenly
the
reason,
who
crash
will
clear
to
to
moment.
start
with
majority
it
has not
few
stops
be
of
say
less
input.
error
ahead
but
program
is
your
to
be
change
perhaps
asking
your
only
be
the
one
of
program.
yet
things
at
the
dealt
the
ways
likely
You
trapping
the
of
them.
sense
mistakes
the
largest
the
program
requested
INPUT
able
the
The
come
more
crucial
with
in
in
which a program
to
stop
will
find
is
largely a matter
kind
of
precautions
when
proportion
is
not
quite
from
statements
to
concentrate
conventions
expecting a numeric
for
an
alphabetic
there
is
no
point
programs,
possible
user
or
errors:
if
exactly
two
commonsense
they
what
best
that
can
against a creative
annoying
point
the
normal
than
because
way.
the
can
in
confusion
very
few
mistakes
using
as
is
simply
the
user.
are
complex
people
your
of
them
good
not
too
when
are
best
boil
as
you
clear
It
may
brief,
properly
on
which
you
response
input
without
in
lamenting
the
programs
are
is
meant
designed
the
are
to
principles
be
an
In
of
on
in
be
1)
Take
the
techniques
be
such
as
trouble
described
to
draw
the
to
in
the
eye
format
last
of
the
the
screen
chapter.
user
to
properly
The
layout
the
of
correct
using
the
screen
prompt
the
and
kind
of
should
away
53
Page 66

Advanced
from
2)
you
developing
of
what
is
spelled
get
then
3)
or
characters,
example
M-—-
1
2
2
4 - Display
Programming
anything
Try
to
get
decide
the
information
the
program
out.
their
hand
come
back
Specify
letters,
o-
oom
o7
the
is
of a menu
ait
Enter
Lelete
Search
Techniques
which
might
someone
the
program
backwards.
This
on
to
format
there a maximum
should
FProgream
New
else
program
no
is
about
applies
the
program.
it
you
may
of
the
there
which
[tem
Item
For
[tem
Data
appears
distract.
to
is
doubt
Other
and
even
entry
be
Avoid
look
at
finished.
you
users
no
idea
if
you
If
you
well
find
wherever
value,
commas
on
the
clutter
the
prompts
Having
know
the
will
have
what
do
not
leave
the
yourself
it
is
is
there a limit
between
screen:
on
the
you
spent
purpose
only
each
input
intend
program
as
puzzled
in
doubt — is
items....?
screen.
are
using
days
of
the
is
to
let
for a time
as
anyone
on
the
before
or
weeks
every
haziest
for
unless
anyone
it
in
figures
length
Take
entry
idea
it
else
and
else.
in
the
Which
That
seems
entering
or
the
program
number
entry
will
4)
Do
not
really
need
screen
groups.
the
be
into
Paradoxically
user
exercised
program
to
mentally
more
experienced
5)
Be
sure
input
of
an
item
of
with
someone
54
do
you
fairly
clear
the
letters
stops.
do
you
require?’.
be
made
make
combinations
to
input
logical
has
become
in
reading
correctly
freewheel
you
use
‘0’
normally
data,
don’t
who
require’?
yet
you
‘Display
Data’
The
In
in a certain
10
items
in a row
groups,
you
more
perhaps
will
familiar
the
the
first
few
and
respond
with
the
program.
the
same
conventions
quits
the
be
surprised
loses
something
can
be
sure
and
prompt
other
words
way,
it
should
of
inputs
then
get
more
with
prompts,
times
does
to
current
to
find that
important
that
wondering
really
should
if
the
first
too
lengthy
break
clearing
errors
with
the
program
the
fact
not
mean
the
wrong
throughout
function
some
why
program
tell
them
the
that
prompt
but
you
when
people
nothing
have
the
user.
or
complex.
up
visually
screen
complex
since
someone
that
they
when
the
program.
in
one
are
not
all
they
will
sit
there
happens
been
‘Which
assumes
between
inputs
less
won’t
If
on
when
care
uses
start
they
If
the
you
the
the
will
the
are
an
place deletes
very
popular
wanted
to
Page 67

do
was
return
6)
Be
extremely
you
normally
to
know
another
prompt
on
accustomed
press
RETURN
from
the
screen
the
user
has
make a beep
7)
Itis a good
been
made
mistakes
user
is
telephone
to
user
straight
situation
can,
has
just
correct.
number
the
screen
has
confirmed
into
if
the
to
the
careful
ask
the
to
making
after
become
to
remind
idea
through
however,
entered
It
may
implies
the
main
user
menu.
with
for
name,
fact
if
age
screen
without
three
again
when
the
third
accustomed
them
to
assume
tiredness,
be
in a new
just
be
have
been
that
nothing
that
the
array
specifies
inputs
whose
address
1s
and
greater
age
than
warning.
inputs
that
that,
and
the
data
input.
to,
flash
something
despite
does
If
you
boredom
reduced
format
that
the
by
printing
and
asking
user
transposed,
is
actually
information
of
data
is
makes
that a mistake
Chapter 5 Error
order
sometimes
in a filing
65,
don’t
The
user
it
is
odds
on
not
immediately
are
changing
the
screen a different
different
your
or
will
for
done
as
it
very
has
is
best
efforts,
sheer
carelessness.
out
the
for
confirmation
then
notice
instance.
with
intended.
difficult
been
made.
changes.
program,
just
will
that
put
he
but
the
have
or
disappear
the
order
colour
happening.
mistakes
information
that
that
age
Echoing
the
Placing
input
to
remedy
an
until
an
Trapping
need
extra
been
she
will
that
have
Such
the
this
and
input
the
input
the
If
or
Error
Trapping
techniques
The
use
of
common
the
level
of
errors
will
still
be
made,
in
which
the
program
and
balances
Setting
One
of
program
an
item
a
program
then
the
zero.
number
possibility
a
program
checks
into
limits
the
commonest
Is
designed
is
input
to
program
Clearly
greater
of a typing
can
that
any
sense
made
however,
can
the
program.
to
which
falls
input
two
will
the
prompt
than
zero,
error
only
function
information
—
some
methods
out
of
and
be
sources
work
with
outside
numbers
stop
with
should
but
or a more
simple
like
all
proportion
we
made
proof
of
data
those
and
an
error
have
even
within
limits
entered
those
shall
now
against
program
which
limits.
then
if
instructed
when
than
ordinarily
it
does
programming
described
to
the
examine
crashes
falls
For
divide
the
second
this
is
is
wise
not
effort
them
by
within
example,
the
first
number
the
done
obtuse
to
put
fall
outside.
above
some
occurs
certain
will
reduce
involved.
of
the
building
checks
when
limits
if
you
by
the
second,
input
user
to
input
there
is
still
user.
Where
in
some
simple
The
Errors
ways
the
and
write
is
a
a
the
limits
55
Page 68

Advanced
which
usually
a
string.
1)
Value
In
developing
should
the
case
into
needed
have
program
of
an
an
error-checking
tobe a number
Programming
cause
of
anumber
and
determined
would
invalid
Techniques
problems
debugging
is
tolerate.
input.
If
line.
from
are
value
your
the
range
In
the
such
limits
Suppose,
one
to
ten
of a number,
program,
of
values
example
are
found
for
instance,
inclusive:
and
one
of
the
for
numerical
given
above,
they
can
that a particular
the
first
things
inputs
zero
be
simply
length
of
you
that
is a clear
built
input
i@O@
INPUT
1-10':NN
1210
i220
IF
NN>=i
PRINT
ANGE!’
1930
FOR
I=1
1‘:0%:PRINT
i240
All
and,
Error
character
long
remember
INPUT
format
giving a message
more
number
input
to
2)
Just
programs
certain
from
GOTO
that
routine
if
it
message
string
as
by
lines
was
have
an
Length
as
the
length
the
is
not,
and
string
which
that
if
two
shifting
than
is
wrong,
rejected.
input
of
astring
value
can
be
and
technique
‘ENTER & NUMBER
AND
‘THAT
TO
Of:PRINT
NN<=1@
NUMBER
20@@:NEXT
C2*CUl’;
i9a0
does
1s
to
check
that
displays
of
the
lines
to
simply
rejected
of a number
thrown
an
original
spaces,
covers
the
it
do
employed
twice
line-end
of
characters
print
the
user
going
is
worth
There
are
without
by
not
get
error
message
input
are
and
both
lines
has
been
position
and
then
back
to
the
effort
few
things
understanding
can
be
the
fact
it.
Guarding
for
numbers:
IS
the
input
then
the
user can
will
crossed
had
been
too
clearing
the
original
because
out
that
IN
THEN
OUTSIDE
I:PRINT
1s
within
for
the
erased
not
work
and
received,
far
down.
the
INPUT
it
more
frustrating
why.
of
the
they
are
against
THE
RANGE
1050
THE
R
‘C2*cCu
the
specified
duration
by
try
again.
Note
original
tells
desired
expecting a string
this
of
printing
Printing
since
the
will
treat
thus
that
statement
the
user
to a user
range,
is'little
the
O$, a 39
64
the
ruining
although
input
why
so
different
limits
loop.
one
will
next
the
takes
if
the
the
than
some
of
a
1000
“3
AS
56
INPUT
‘ENTER
A
STRING
(LENGTH
1-10)
Page 69

Chapter 5 Error
Trapping
i@i@
i
i@2@
GTH!*
i@26
SeCU1';OF:PRINT
i@44
Here
the
above.
strings
99Q
This
input
a
value
it
Garbled
Often,
prompt
of
inputs
of a number.
list
does
4a
the
lines
takes
will
as
‘SMITH’
range
of
not
strings
IF
LEN(A#)
PRINT
FOR
GOTO
check
correspond
One
extra
is
an
extra
Ode
-
care
leave
of
‘SMITH’,
and
entries
either
through a simple
correctly,
as
incomprehensible
this
usually
In
it
correspond
2=1
‘THAT
f=1
TO
2@0@
OF:PRINT
1640
is
that
the
length
exactly
to
safeguard
command
of
the
A$
as
the
the
happens
the
before
fact
that
it
was
then
pressing
length
user
will
when a letter
case
of
understands,
to
any
of
AND
STRING
of
the
lines
you
might
the
pressing
before
RETURN
check
would
typing
make
to
the
strings
perhaps
them.
LEN(A®)==10
‘
15
:
NEAT
“L2ecul’;
the
string
of
the
like
INPUT
RETURN
the
INPUT.
have
error
an
input
program.
is
inadvertently
it
happens
as
commands,
THE
I : PRINT
falls
in
number
to
include
statement:
Thus
by
mistake
been
evaded.
or
through
which
In
when
THEN
WRONG
the
range
checking
when
without
if
A$
would
failure
is
not
the
case
entered
the
program
and
the
LEN
‘LE
1-10
technique
inputting
making
already
have
to
read
so
much
of
numeric
instead
string
and
an
has
left
the
out
has
a
input
1)
Invalid
This
type
prompt
address.
a
value
of
only
way
input
as
every
character
1400
NNF=**
i@i@
1620
number
of
error
for
‘age’
The
result,
zero
to
guard
strings
INPUT
IF
NN#=‘*
formats
occurs
the
user
of
course,
to
the
64
against
and
then
is a valid
‘ENTER
when,
for
instance,
carelessly
(unless
such
examined
digit. A typical
inputs a string,
is
nonsense,
it
begins
mistakes
character
routine
NUMBER:
THEN
NN=4@
instead
with
the
input
with
one
or
effectively
by
character
would
‘;
NN?
:
GOTO
of
responding
such
as
usually
more
figures).
is
to
have
be
as
follows:
1980
part
having
numbers
to
see
to
of
The
that
a
an
57
Page 70

Advanced
Programming
Techniques
i@3@
1640
1,1)<='9'
i@5@
:
i@46@
T
107@
Such a technique
an
not
program
from
simply
as
an
2)
Where a program
a
entry.
one
month
allow
is
was a sensible
FOR
I=1
IF
MID#(NN¢,1,1)2='@°
THEN
FOR
PRINT
J=1
FRINT
‘THAT
TO
‘£2#CU]':0%
‘C2eCUI]‘: : GOTO
input
be
notified
what
Note
pressing
zero.
extra
Unknown
number
Take
of
the
number
the
to
be
made.
NEXT
and
crashing,
that
If
message,
of
user
I
does
will
be
to
the
they
has
been
input.
in
the
routine
RETURN,
you
wished
perhaps
strings
is
designed
strings,
for
example a program
months
but
to
input
In
that
one:
of
this
TO
LEN(NN#)
1070
IS
NOT & VALID
7000 : NEXT
i@ia
not
add
noticeably
effective
user.
to
confusion
the
the
case
Invalid
simply
as
it
guard
saying
year.
is
prone
actual
there
in
detecting
number
mean
that
given
is
simply
against
NOTHING
to
accept a command
can
arise
which
The
user
to
error.
name
would
J
:
PRINT
to
errors
formats
unintended
there
is
that
such
such
an
if a command
allows
could
You
of
the
need
to
AND
MID#(NNE,
NUMBER’
O£ : PRIN
the
time
taken
which
would
do
values
no
check
an
input
eventuality
INPUT.
consisting
data
to
be
allowed
might
therefore
month
for
be a check
to
otherwise
not
result
are
extracted
against
is
interpreted
you
would
of
is
mistyped
be
input
to
input
decide
which
the
that
the
process
1n
the
the
user
add
one
of
on
for
any
the
to
input
input
146006
1410
1426
1426
104@
1056
1
1460
T
Here
elements
commenced.
recorded
message.
58
MMt=*~
INPUT
FOR
IF
NEXT
PRINT
TO
2000
PRINT
‘C2*¥CUI]’‘;
the
assumption
month
‘NAME
I=6
MMS=MONTHE(I)
I
‘MONTH
=
NEXT
‘C2xCUI';0%
+:
0-11
of
the
The
routine
names
TO
GOTO
is
iil
that
array
and,
OF
MONTHS: ° 3
NAME
1010
you
have
MONTH$
checks
if
no
match
THEN
INVALID’
=
PRINT
stored
what
1070
the
when
has
is
found,
MMe
names
been
:
FOR
OF
:
PRIN
of
the
the
program
input
prints out
I=
months
against
the
error
in
first
the
Page 71

Chapter 5 Error
Trapping
Common
In
the
section
of
the
most
effective
to
force
the
user
itis
correct.
the
task
at
the
program. An
1992
i@i@
i@20@
can
same
FRINT
FOR
PRINT
If
time
‘TBLACKI
i@=@
i@4@
i@5@
i968
1070
WEXT
GOSUEB
FRINT
FOR
PRINT
@)sOQ#(1)
iG@BG
ig9@
WEXT
INFUT
‘sTT#
ii9@
HEN
1110
i17@
{120
ii4@
GOSUB
1900
RETURN
PRINT
FOR
RETURN
sense
of
you
be
example
error-trapping:
common
to
wish
handed
ensure
sense
methods
look
to
of
of
again
at
do
this
over
to a subroutine which
that
the
such a subroutine
measures
given
reducing
what
regularly
presentation
has
been
during
the level
is
‘the
above
entered
the
is
uniform
given
second
of
course
will
below:
LEFT#(CC#,LL+1i);
I=@
TO
Na-i
‘CGREEN]‘sPF#(I)3":°
‘:GQQ#(1)
I
112¢a
LEFT#(CC#,LL+1i);
I=@
TO
NQ-i
‘CYELI';PP#(1):°:C0RVS1‘':TAB(2
I
“CCDIARE
11270 : IF
THESE
CORRECT
LEFT#(TT#,1)<2°Y'
|
LEFT#(CC#,LL+1);
I=1
TO
NO+? : PRINT
O#
:NEXT
we
noted
errors
and
confirm
of a program
save
throughout
:
INPUT
(¥/N):
look’
that
on
input
that
space
T
one
is
and
the
Variables
LL—
screen
NQ—Number
PP$—
What
the
before
the
in
CORRECT,
again.
Array
the
variable
the
questions
inverse.
required:
line
position
of
questions
containing
routine
subroutine
If
accomplishes
NQ.
The
have
been
the
user
the
questions
of
first
the
prompts
questions
is
called.
does
asked,
not
and
Responses
answer Y to
prompt
is
to
ask a series
themselves
they
are
redisplayed,
the
answers
are
are
the
are
of
questions
stored
stored
question
cleared
in
in
QQ$.
with
based
the
array
When
the
ARE
and
presented
on
PP$
all
answers
THESE
59
Page 72

Advanced
Programming
Techniques
Formatting
CC$
which
consists
"THOME
and
consisting
The
again
changing
second
information
the
To
in
your
J@4@
J1i@
324
224
244
woY
Once
would
number
done
verification
the
responses
wherever
Clearly
program
a
program
can
the
A
the
correct
of
actual
to
the
user
their
time.
on
relevant
lines.
call
the
main
program:
Li=i@
PRPt(O)=°NAME*
PPt(1)="ADDRESS’
PP
(2)=°RPHONE
GOSUB
FOR
the
main
specify
of
questions
that
the
of
responses
are
you
there
or
one
which
increase
need
the
to
include
of
the
screen
of:
Ce4eCod
area
of
39
spaces.
format
of
is a matter
appearance
At
the
end
the
screen,
routine
IT=1
:
N@=2
1000
TO
you
prompt
the
position
to
subroutine
the
accuracy
are
made
contained
wish
to
permanently
would
be
where
there
asks
quite a few
accuracy
the
checking
is
accomplished
°
the
screen
the
prompts
of
taste,
helps
of
the
the
subroutine
would
’
NQ
:
routine
be
of
the
asked
would
of
the
above
format
correctly.
in
the
no
point
were
of
the
responses
routine every
by
is
cleared
and
the
way
the
only
the
user
to
concentrate
routine,
have
AAFCII=OOE(1I)
first
and
responses,
array
store
in
only
questions,
if
you
at
1200
lines
something
had
been
prompt
then
spell
the
prompts
repeating
On
return
QQ$
them.
using a routine
one.or
however,
while
the
use
of a string
by
use
of
the
that
they
point
of
importance
on
do not
could
wish
be
called
like
=:
entered,
on
the
out
from
and
two
prompts
screen
the
and
the
can
like
these
prompts.
ask
the
prompts
subroutine
be
transferred
this
ever
such a subroutine
at
the
same
time
time a prompts
usual
|
are
presented
them
to
leave
the
following
NEXT
brief
(in
lines),
Having
the
user
one
in a small
used.
reducing
used.
called
O$,
is
that
for
the
the
to
clear
lines
the
for
until
the
For
to
DIY
So
far
we
slotted
traps,
mainly
always
made.
That
60
error
have
into
various
involving
to
determine
will
messages:
been
considering
parts
of
incorrect
what
constitutes
not
always
be
the
elegant
the
possibilities
the
program
inputs.
an
possible.
solution
of
routines
to
provide a variety
All
of
this
depends
incorrect
Sometimes
input
an
as
input
which
on
being
soon
will
of
be
can
error
able
as
it
made
be
Is
Page 73

that
is
not
too
misspelling
program.
become
least
be
possible
and
place
and
The
apparent
partially
to
checks
Problems
an
input
and
a
distinct
task
permanently
Now
suppose
clear
that
there
something
fault
that
that
would
anonsense.
Clearly we
an
appropriate
problem
simply
in
that
that
work
we
five
This
there
of
terminating
the
fifth
would
an
error
is
done
would
would
would
could
how
subroutine
be
place a special
not
with a whole
error
has not
The
elegant
any
errors
variable
handle
to
insert
how
arisen
As
three
that
which
all
the
new
to
prevent
will
disappear.
an
example
commonerrors
long,
or
yet
it
will
difficulty
until
processed
anticipate
and
error
still
remain,
then
passes
to
perform
or
used
further
that
is
something
would
make
What
is
to
could
insert
error
to
escape
the
disastrous.
has
been
on
the
particular
be
executed
work
but
be
many
places
range
of
special
arisen.
solution
are
found
will
be
error
messages
error
checks
different
of
the
tend
too
low
in
value,
still
be
an
here
is
that
the
information
by
the
program.
where
such
messages
however.
control
and
to
modify
in
the
to
ending
the
fourth
wrong
actually
the
be
message
fourth
being
found
final
done?
an
from
executed
What
and
crash
result
error
to
the
subroutine
we
data.
check
in
if
the
in a program
where
checks,
to
the
problem
during
tested
and
parts
use
of
to
crop
regularly,
that
are
to
of
the
this
up:
that
input
that
the
actual
which
With
errors
might
at
the
correct
Suppose
five
overall
with
check
be
chain
that a certain
successive
with
the
result
of
the
the
data
the
program
of
processing
in
displayed.
of
since
and
we
must
do
is
use
that
record
So on
returning
the
program
particular
of
any
complexity
errors
could
each one
is
to
the
course
and
needed.
define
new
program
technique,
Chapter 5 Error
cannot
be
easily
will
cause
difficulty
has
been
enough
foresight
crop
up
points.
problems
created
input
in
the
program
subroutines,
processed
five
the
five
that
have
to
make a record
to
error
arise
ensuring
hand
data
being
of
the
program
subroutines
that
has
been
but
nevertheless
the
information
fourth
subroutine,
But
we
also
subroutines.
will
normally
already
to
ensure
from
ensure
had
and
over
decided
that
subroutine
that
been
it
is
possible
we
could end
that
one
the
recording
of a program
to
use
one
subroutine
Using
this
method
errors,
executing
while
problems
if a problem
consider a program
Trapping
checked
has
for
will
been
it
would
for
the
not
at
program
accepts
each
with
stored
so
far.
it
becomes
input,
not
some
yield
with
have
the
It
is
no
use
result
that
of
the
fact
no
more
four
subroutine
discovered.
that
up
particular
of
to a single
to
it
is
easy
of
has
where
1)
After a certain
too
large
for
2) A label
is
memory.
amount
the
program
entered
!
for
of
calculation, a figure
to
cope
with
sensibly.
data
that
is
already
is
generated
contained
in
the
which
is
program’s
61
Page 74

Advanced
3)
The
data
this
can
You
would
an
array
three,
of
a)
RESULTING
b)
LABEL
c)
FORMAT
In
addition
to
zero.
In
the
messages
more
than
Programming
must
be
only
be
checked
begin
called
ERR$(3)
the
array
to:.
NUMBER
DUPLICATION
ERROR
to
this
we
program
associated
alter
the
Techniques
entered
by
defining,
and
ON
would
itself,
with
them
value
of
in a fairly
after
the
you
TOO
data
when
would
LARGE
complex
has
the
then
INPUT
declare a variable
the
checks
ERR
are
replaced
when
for
specific
an
error
format
been
partially
program
set
three
called
errors
by
checks
is
found.
and
was
first
elements,
ERR
and
which
For
mistakes
processed.
initialised,
one
set
it
equal
and
the
error
do
nothing
instance:
in
to
1220
would
1520
Into
line
subroutine
IF
LARGE.
be
IF
each
which
replaced
relevant
would
be:
1700
This
IF
would
subroutine
subroutines
whenever
indicated,
1770
In
the
dictated
would
the
nothing
GOSUB
end,
the
insert a line
NN+6SS25
°
by:
NNS6S5a35
subroutine
would
ensure
not
ERR
«>
ensure
that
would
might
have
program
more
2500
program
order
in
something
THEN
THEN
that
operate.
@
THEN
if
the
not
be
their
returned
was
done
:
execution
executed.
FRINT
ERR=1
of
the
program
if
any
Thus
the
RETURN
value
of
calls
to
from a subroutine
to
the
IF
ERR
would
which subroutines
like
this:
‘NUMBER
we
error
had
entry
line
ERR
were
Subroutines
other
routines
data:
«20
THEN
return
to
the
were
called.
TOO
would
now
place a new
been
detected,
of a subroutine
anything
but
which
call
altered
with
an
error
RETURN
main
module
In
that
module
might
zero,
other
so
being
which
the
the
that
we
1126
62
[F
ERR
THEN
GOSUB
2008
Page 75

which
would
call a simple
subroutine
consisting
Chapter 5 Error
of:
Trapping
SHAG
afAi
SAAS
aAWia
aie
S434
The
against any
do
to
is
error
heart’s
REMERERHREE
REM
REMRREEKHKERER
FRINT
ERRK=@
RETURN
beauty
is
to
add a new
the
appropriate
zero
will
you
content
of
new
ensure
have
Conclusion
Using
the
techniques
programs
to.
on
upon.
long
half
satisfaction
to
be
for
Even
program
key
flames.
which
How
far
you
how
complex
Even a simple
time
to
enter,
an
hour’s
which
in
control
fear
that
it
so,
be
is.
The
you
hadn’t
work.
will
ERE
ERROR
such a system
errors
error
identified.
with very
will
want
it
ERR
as
message
value
that
the
laid
survive
to
1s
and
MESSAGES
(CERR)
you
and
program
You
little
out
go
in
partly
program
causing
Perhaps
comes
from
of
events
stop
warned!
person
thought
rather
in
confusion.
Never
you
of
RERERRER
REE
HEREHRKKRERERERE
is
that
develop
to
ERR$,
the
built-in
is
can
go
effort.
in
this
most
of
the
protecting
on
how
may
severe
inconvenience
the
most
having
than
boast
are
boasting
and
your
RRR
EREMREREREERREE
if
you
the
decide
program
you
then
insert a check
lines
which
now
protected
on
identifying
chapter
abuse
your
important
work
on
you
that
program
information
against
will
users
is
the
when
important
factor,
designed a program
one
that
has
to
of
how
robust
to
will
inevitably
reputation
will
REESE
want
all
you
which
test
whether
the
new
errors
be
able
to
will
subject
will
depend
data
that
which
it
crashes
however,
which
be
handled
your
press a single
be
shot
to
protect
have
sets
ERR
ERR
possible
to
your
produce
them
partly
it
works
takes
after
is
the
appears
gently
favourite
down
to
a
in
63
Page 76
Page 77

CHAPTER
6
Storing
One
day
so
large
and
programs
programs
soon
as
machines
computer
micro
only a part
to
day.
To
cope
program
provide
Cassette
Admittedly,
from
the
drive
work
and
we
shall
that
they
will
the
machine
will
has
owners
of
with
and
an
extension
Recorder,
compared
RAM
at a snail’s
programming
of
the
extra
capacity
limitations
of
micros
switched
of
cannot
off.
Strangely,
amounts
of
programs
or
techniques
chapter,
exhaustive,
on
described
reliably
on
of
money
their
machines,
make
even a humble
necessary
especially
indeed
the
effective
in
these
and
in
tape
or
disk
Retrieving
all
be
using a generation
will
hold,
that
we
wish
be a permanent
is
switched
represent
been
have
the
total
the
the
data
chips
for
most
the
64’s
hold
though
for
much
cassette.
use
larger
and
making
as
over
the
to
learn
sum
fact
that a machine
associated
to
the
or
the
1541
to
the
of
the
pace.
useful
of
the
memory
information
most
add-ons
often
by
use
of
In
to
make
as
it
relates
it
would
of
floppy
pages
you
quantities,
better
at
one and
to
use.
part
on.
the
Not
only
of
the
The
possibilities
big a step
past
few
years.
to
live
with
of
information.that
with
it
memory
speed
64,
Effective
of
Disk
Drive,
with
the
cassette
programming,
applications,
C2N
and
1541
and
the
fact
during
micro
owners
which
will
only
small
the
massive
this
better
be
quite
will
disks.
storage
chapter
use
to
the
possible
Even
be
able
swapping
use
of
the
of
computers
same
time,
that,
the
memory,
forward
as
Until
machines
may
like
the
64
at
any
one
the
64.
That
really
is — extra
which
data
recorder
will
to
overcome
that
the
the
time
seem
prepared
increase
the
amounts,
capacity
we
shall
examine
of
the
C2N
use
of
the
to
write a complete
so,
using
to
store
information
memory
available.
with
memories
all
the
information
information
always
that
capable
however,
learn
opened
the
home
day,
be
used
can
hold
time,
Commodore
is
what
can
be
and
even
to
available
up
of
recovered
make
both
present
generation
the
machine
to
memory
few
home
of a floppy
some
and
1541.
disk
drive,
the
techniques
information
with
that
and
as
by
such
micro-
however,
holding
from
day
only
one
the
C2N
memory.
the
disk
especially
use
the
size
is
pay
large
capacity
grown
disk
of
the
The
is
not
book
more
stored
65
Page 78

Advanced
Programming
Techniques
Saving
The
programs
people
being
saved,
and
are
1)
As
microcomputer
in
the
your
work
last
not
resaving
that
to
half-an-hour.
but
you
time
2)
To
always
saving
programs
first
and
safely
take
in
developed,
keeping
disks
by
leaving
One
or
two
you
develop
electricity
programming
you
will
saved
your
normally
the
program.
relatively
you
can
depend
will,
sooner
to
enter.
make
saving a program
include
without
most
obvious
for
future
this,
failing
failing
only
one
them
commonsense
new
programs
the
64
can
supply,
you
manage
have
lost
program.
expect
fewer
having
It
really
or
later,
four
to
In
changes
on
the
lines
to
spell
use
of
use.
It
is
to
save
to
check
copy
of
important
around
or
will
If a program
enter
the
depends
fact
lose
at
rules
lose
programs
someone
to
depend
lines
event
are
being
that
an
important
easier
the
beginning
out
the
exposed
when
SAVE
upset
on
external
always
regular
that a program
it
kicks
the
on
is
for
that I am
made, I might
how
if
you
and
program
storage
surprising
updates
programs
to
the
comes
to
them
regularly.
if
there
the
plug
64’s
equilibrium.
how
long
being
entered
more
than
debugging a program,
much
you
do
not
save
program
to
encourage
of
my
name
is
to
keep
how
little
when a program
has
been
and
abusing
elements.
saving
is a momentary
it
15
are
that
programs
each
Given
programs.
Like
or
even
because
How
has
been
rapidly I would
minutes
increase
programs
that
prepared
has
taken a long
myself
which
time:
your
care
most
1s
properly
tapes
below
any
other
surge
in
much
since
you
without
so
period
to
lose
regularly
to
do
it,
I
allow
i
GOTO
2
SAVE
EN
ANY
3
VERIFY
4
REM
Including
to
save
the
be
saved
simply
that
all
your
not
wish
VERIFY
in
this
section
VERIFY
or
the
program
Those
above:
66
4
‘PROGRAM
KEY
TO
‘PROGRAM
such a routine
program
programs
to
use
is
optional
you
using a disk
by
entering
RUN
before
can
of
will
begin
under
and
making a choice.
course
drive
NAME’
VERIFY’;
NAME’ : STOP
in a program
the
wrong
‘GOTO
can
be
started
and
wipe
many
people
lose
line 3 but
to
execute
can
include a similar
:
INPUT
04
has
the
virtue
name
due
2’
and,
as
with a uniform
out
any
stored
never
use
If
you
you
every
time
‘REWIND
that
to a typing
an
added
‘GOTO
variables.
it,
but
do
decide
will
still
youSAVE
routine
you
bonus,
see
the
to
dispense
need
Itt.
to
TH
are
unlikely
error,
it
means
I’
if
you
The
use
next
the
STOP
that
it
can
do
of
point
with
given
Page 79

SOTO
SAVE
Pde
SRAM
7)
RE
ted
A
point
system
its
own
ensures
name).
difficult
out
to
then
program
to
leave
In
the
‘“@@:FROGRAM
MAME
fi
bug,
map
of
caution
on
of
.&
relatively
the
that a program
The
program
to
load
another
be a problem,
resave
name
the
case
the
in
name
of
new
alone
disk
=
here
disk
when
Is
just
is
either
version,
line 2 and
and
drive
VERIFY a program — if
undoubtedly
3)
Loading
most
reliable
people
and end
problem.
to
check
approach
course
When
amount
Sometimes a program
SAVE
of
the
do
they
The
quality
cassette,
the
end
have
to
in
order
it
comes
VERIPY
get.
and
begin
up
never
If
you
what
you
lies
between
entering
of
time.
routine,
tape
you
can
be
best
course
of
your
recording
of
the
both
lose
to
lose
to
saving
the
tape.
saving
on
by
on
any
machine
verifying
verifying
are
naturally
you
have
probably
the
two
long
programs
Losing
more
are
the
can
often there
using.
heartbreaking.
is
one
tape
then
each
new
tape,
then
either
the
program
more
than
something
NAME'.0
STOP
for
disk
owners
full
disks
the
1541
using
the
‘@O’
saved
even
though
saved
will
be
program
owners
you
the
their
saved
never
on
to
first
or
to
change
validate
it
the
there
don’t
then
64’s
C2N
on
the
programs
anything
prone
to
every
VERIFY
the
scratch
attach a number
each
disk
is
you
cassette
market
because
caution
time,
attitudes.
VERIFY
program
be
Such
of
can
take
lost
because
will
be
some
problems
do not
compromise.
develop a program
version
the
turn
over
on
the
last
development
like
after
or
machine
the
final
Chapter 6 Storing
2:
VERIFY
is
that
due
drive
may
prefix
there
Is
unharmed
disk.
The
the
existing
time
the
after
saving.
never
any
deserve
recorder
today.
every
time
they
then
you
if
you
your
programs.
can
take
up
more
of
some
difficulty
occur
If
you
on
something
the
last
version
rewind.
In
and
have a faulty
of
version,
and
Retrieving
“PRO
to a disk
sometimes
to
the
an
existing
but
solution,
program
to
program
excuse
everything
For
that
something
have
will
are
operating
file-name
file
you
may
if
this
the
end
is
saved,
for
failing
you
are
among
reason
is
never
probably
casual
The
optimum
corrupt
of
find
turns
file
of
most
saved
had
want
in
up a considerable
and
it
does
happen.
limitation
often
are
of
the
with
the
but
when
confident
quality
of
like a C60
until
you
reach
this
way
you
would
recording
the
program.
however,
When
always
(this
that
it
and
the
or
to
will
the
a
your
64’s
they
the
4)
While
there
is
longer
no
doubt
tapes
that
the
are
eminently
best
way
to
store
suitable
programs
for
developing
permanently
problems
on
tape
67
Page 80

Advanced
is
.program.
programs
long
you
5)
clean.
compared
become
6)
an
There
some
a
magnet.
your
rerecorded
the
most
suffer
Programming
to
use
specialist
This
will
tapes
for
will
unintentionally
Keep
the
Kits
to
coated
Keep
more
entirely
different
is
always
way,
If
backup
For
disk
owners
best
will
reliable
loading
Conversely
saved
to
two
drive
don’t
copies
of
important
frustrating
if
Techniques
computer
does
cost a little
be
instantly
the
right
recording
for
cleaning
the
frustration
with a deposit
than
one
place
the
danger
perhaps
you
onto
do
copies
shorter
through
not
can
the
in
the
world
that
Commodore
or
saving
the
taking
disks
with
neglect
the
material. A serious
your
only
cassettes
more
available,
starting
record
and
copy
over
playback
the
heads
of
of
of
from
the
that
position.
losing a program
oxide
your
your
excessive
wish
to
duplicate
be
stored
cassettes
need
the
to
keep
1541
if
have
difficulties
of
copies
very
relative
copies
or
is
little
extra
safety
of
the
and
but
without
It
an
existing
heads
are
inexpensive
from
programs,
tapes
or
working
heat
every
on a few
they
are
backup
disk
drive
ever
to
have a disk
so
much
effort.
and
disk
required
limit
each
it
also
means
having
also
reduces
program.
on
your
because
your
tapes.
with
the
disks
you
normally
copy
will
or
the
efforts
program
longer
ever
copies
cannot
made.
cassettes
needed.
is
accentuated.
be
It
is
accidentally
easier
since
Even
if
reliability
drive
program
of
fault
are
cassette
that
to
search
the
danger
cassette
and
easy
the
second
work
be
damaged
of a child
on a single
and
described
not
uncommon
damaged.
programs
you
do
own a disk
tape
for
can
be
extremely
on
disk.
to
one
all
your
through
that
recorder
to
use
heads
copy
in
with.
in
with
tape,
then
With
as
the
to
can
be
backup
Saving
Most
work
into
every
reloading
In
and loading
programs
upon.
the
program
time
or
it
deciding
encountered
saving
perhaps
there
variables
program,
values
necessary
the
was
were
as
contents
in
in
it
the
to
68
which
In
cases
itself
conquer
into
the
program
to
save
is
that
of
associated
it.
First
your
program.
should
program
get
the
program
data
are
of
some
where
of
be
that
you
have
the
problems
at a later
data
to
identifying
an
array
with
the
of
all,
then,
This
remembered.
runs.
back
actual
use
data
is
not
two
choices,
of
saving
date.
tape
or
disk
what
it
is
if
you
forget
array
and
make a complete
will
not
Many
You
only
need
on
the
road
need a quantity
fixed
so
that
either
re-enter
data
on
tape
the
first
you
want
to
to
save
the
recorded
how
list
be
all
the
variables
to
when
save
you
will
those
of
data
it
can
be
written
the
or
disk
problem
save.
It
is
variable
many
of
the
essential
variables
be
assigned
which
next
wish
to
data
and
to
be
no use
which
items
in
the
are
to
use
Page 81

it.
One
point
arrays
defined a 500
store
to
used
saving
loading
even
which
of
data.
ensure
and
data,
and
worse
that
save
saving a program
by
to
remember
actually
line
string
If
you
have
you
do
only
those
whether
wasting
in
this
respect
contribute
array
only
have a variable
lines.
to
tape
time
on
something.
in
which
used
170
The
or
disk,
and
there
non-useful
Chapter 6 Storing
is
to
you
are
lines
recording
reason
is
not
is
no
items.
for
need
save
It
may
gradually
of
the
of
this
as
fast,
to
only
be
array
how
is
that
byte
make
and
those
that
you
building
so
far
it
many
lines
loading
for
byte,
this
situation
Retrieving
parts
of
have
up
a
is
best
are
and
as
Saving
Having
in a module
to
open a file
A710
In
the
which
figures
will
short,
1’,
and
talks
can
at
the
or
two
When
secondary
specifies
presented. A secondary
file
added
to
read
are,
do
not
to
tape
identified
which
with a line
OREN
context
information
in
the
be
referred
that
it
is
that
the
to
the
external
opened
but
with a test
while
same
time
files
are
opening a file
address,
that the
with
the
to
the
end
items
from a file
generate
the
variables
will
1,1,1,
of a micro
will
example
to
whenever
meant
to
type
of
device
this
one
though
needed
simultaneously.
namely
file
is
added
of
the
line
detecting
an
error
be
and
parts
reliably
such
line
be a line
communication
there
for
address
feature
data.
without
by
save
as:
°F
TLENAME
like
the
placed
is
an
but a line
indicate
something
rather
working,
are
storage
one and
output
of
that a special
This
knowing
the
trying
to
them
64 a ‘file’
that
of
than
and
very
there
file
two
second
end
input
of
arrays
you
must
to
tape.
The
*
is
not a static
of
communication.
the
file
which
is
to
be
saved
as
communication
to
be
opened
the
other
you
can
few
cases
are
two
two. A secondary
which
signifies
‘end
form
of
exactly
of
the
file
beyond
way
have
where
normal
will
that
of
the
how
and
the
to
up
around.
up
accept
the
file’
data
many
ensuring
end
set
first
step
location
The
is
being
file 1 or
‘device
is
where
Other
to
10
files
more
than
choices
address
data
file
is
an
marker
file
allows
items
of
the
data:
them
here
into
three
opened
‘#1’
number
the
files
open
one
for
of
one
as
it
output
will
you
there
that
you
out
is
for
64
a
is
be
i7i0
i72@
i7=®
i740
1750
NN=0 : OPEN
1,1,@,
INPUT#iI,T
IF
ST=64
THEN
A(NN)=T
NN=NN+1 : GOTO
CLOSE
17208
FILENAME’
i : RETURN
69
Page 82

Advanced
This
marker
variable
of
strange
tape.
should
storing
Programming
routine
is
ST
caution,
effects
In
most
be
and
variables
beginning
that
specific
The
moral
to.
The
general
Techniques
will
go
on
accepting
encountered.
(STATUS)
however,
cases
capable
therefore
on
material
the
of
using
recording
how
representing
of
each
block
number
is:
don’t
format
of
use a secondary
for
items
This
marker
and
the
program
two
as a secondary
stored
EOF
marker
after
is
how
many
have
the
quantities
of
data
and
items,
without
address
opening a file
from
will
change
execution
the
not
necessary,
many
to
of
the
program
the
is
then:
the
tape
address
file
in
items
be
stored.
data
use
of
two
until
the
value
will
move
can
question
any
decent
of
data
If
can
be
designed
of
an
unless
the
end
of
the
on. A word
produce
on
it
is
currently
this
is
stored
to
load
EOF
you
really
of
file
system
some
the
same
program
known,
at
the
back
marker.
need
OPEN
file
MARIE
and
opened
program
a
response
i71i@
i7S6@
This
names.
file
(known
°
any
attempt
in
such a way
It
is
not
necessary
line
to
INPUT
OPEN
allows
The technique
itself,
an
INPUT
the
same
specify different
different
Printing
Having
it.
by
in
much
even
number
opened
This
is
PRINT#
print
of
files
for
to a file
the
done
using
and
the
same
to
the
differences
number,
as
to
place
will
result
to
spell
it
can
statement:
‘NAME
1,1,1,FF#
program
can
input
files
different
file
it
is
the
PRINT#
the
appropriate
way
that
screen
to
by
be
device
‘secondary
information
in
an
error
out
the
name
also
be
accepted
OF
FILE:
to
create
also
be
employed
and
thus
allow
purposes.
now
necessary
statement.
file
number
PRINT
would
opening a file
noted:
number,
address’),
into a file
message.
of
the
file
from
the
“sFFa
data
files
with
with
the
program
to
start
placing
Anything
will
place
it
on
to
device
type
which
to
be
user
distinctly
the
input
to
shuffle
information
which
be
placed
the
screen
3)
but
RIL
has
not
opened
in
the
different
of
between
is
preceded
into
(you
there
of
been
in
form
data
the
are
the
of
to
into
file
can
a
1)
The
64,
dividing
70
line
unlike
between
many
other
variables
micros,
which
are
will
not
PRINTed
automatically
by
the
same
mark
line
the
using
Page 83

Chapter 6 Storing
and
Retrieving
astatement
MRINTHI,
Such a line
string
to
separate
to
print
a
separator
In
a
loop
i7ii#
i7SW
i726
Single
being
each
the
case
to
save
FOR
PRINT
NEAT
items
would
items
character
(CHR$(13)).
CHR$(13)
with
1740
Note
put
commas
R$
to
FRINTHL,
(AE
here
when
save
the
them.
like:
Ach,
Be,
result,
detected,
which
item
of
data
between
of
arrays,
each
of
the
i=24
A#L
21
need
to
be
This
is
usually
the
program
typing
TTS
lack
of
or
semi-colons
Oe
when
the
consisting
are
to
be
of
saved
with a separate
the
items.
the
separation
elements
To
ITEMS
AF
CTD
printed
to
done
is
first
‘CHR$(13)’
RE
COt
punctuation
between
data
was
recalled
A$,B$,
and
there
C$
are
PRINT#
of
items
is
in
turn,
eg:
the
file
followed
by
defining a string,
initialised
every
RE
between
the
time:
TT
the
items
and
items.
but
from
tape,
run
together.
two
alternatives,
statement
or
accomplished
by a ‘return’
say
R$
as
separating
Aa NN
the
You
64
is
RE
can
indifferent
in a single
In
order
either
to
insert
by
using
character
equal
to
every
item
if
you
wish
to
2)
The
64
is
range
of
normal
contain
controls
part
those
1714
i723
i72H
1744
Note
reloading,
control
which
of
the
numbers
FPRINTS#i1
FOR
PRINT#1,
NEXT
that
you
the
string,
characters.
not
capable
printing
characters
are a normal
character
one
at a time:
LEN
I=i
TO
I
have
to
program
of
saving
characters.
of
other
part
by
CAF)
LEN(A®3
ASCINIDS
store
the
will
know
and
reloading
If
you
than
characters
of
strings,
character,
length
when
into
(At,1,193
of
the
to
stop
characters
wish
to
like
you
must
numbers
string
expecting
|
outside
save
strings
cursor
and
translate
and
in
order
translated
colour
at
least
then
that
the
which
a
store
when
string
71
Page 84

Advanced
4)
You
cannot
case
of
string
happen
saved
thus
if
and
disrupting
overcome
array
with a leading
Programming
save
arrays,
the
first
the
second
the
this
the
Techniques
empty
which
strings.
may
element
element
order
of
simplest
character
This
often
of
any
array
will
effectively
the
array
solution
before
it
can
contain
is
when
is
to
‘pad
is
saved:
cause
empty
empty
become
it
is
out’
some
problems
elements.
is
that
nothing
the
first
reloaded.
every
element
What
on
In
in
will
will
the
tape
order
in
the
be
to
the
i7i@
1726
172M
Clearly
FOR
T#='#'°+AF(T)
MEXT
you
reloading
element
null
strings.
5)
The
order
whether
example,
variable
called
‘ITEMS’.
loop
such
1710
When
ITEMS
that
is
reloading,
if
any
saved
FOR
before
onto
itself.
1=4
will
but
padding
to
see
whether
in
it
1s
possible
suppose
to
record
When
as:
T=@
it
can
variables
tape,
YO
have
which
to
that
how
TO
the
program
take
from
then
to
you
ITEMS
:
PRINTHI,
remember
every
element
it
1s a null
you
successfully
you
many
save
TTEMS
the
the
program
those
string
save
the
reload
have a string
of
the
the
contents
will
therefore
data
off
variables
to
strip
is
just
and
data
can
it.
array
elements
the
tape
are
used
should
TS
off
these
as
quick
then
padding
be
vital
Harking
of
500
are
currently
of
the
array
have
to
again.
to
control
be
stored
characters
as
testing
out
only
in
determining
back
to
an
elements
being
you
will
have a value
The
simple
the
way
the
before
the
when
every
the
earlier
and
a
used
use
a
for
rule
is
data
date
6)
When
do
this will
number
format
CLOSE<file
Before
left
tape,
saved.
72
for
closing a data
in
the
otherwise
This
all
the
data
mean
that
will
result
in
closing a file
number
‘memory
buffer’
the
is
meant
has
been
any
subsequent
the
program
is:
file,
however,
which
last
item(s)
to
be
accomplished
stored
>
the
attempt
stopping
it
is
stores
information
of
information
by
file
with
wise
CLOSE
must
be
to
open a file
an
to
ensure
may
alone
‘closed’.
error
message.
that
as
it
is
printed
not
but
Failure
of
the
same
The
nothing
to
the
be
properly
experience
to
is
Page 85

Chapter 6 Storing
and
Retrieving
shows
that
PRINT#<file
for
closing a data
PRINT
HS
Loading
The
procedure
image
of
that
1)
The
type
of
DREN
where
to
2)
are
3)
when
the
1,14,@,
the
zero
receive
The
information
main
INPUT#
Provided
they
were
separation
it
is
more
number>,
file
becomes:
File
from
for
for
saving.
file
mumber>
tape
loading
which
“FILENAME
indicates
from
statements
and
GET#.
that
proper
stored
between
reliably
with
The
is
opened
done
no
:
from
tape
main
differences
is
’
that
this
an
external
involved
They
in
will
separation
there
is
no
items
of
data:
by
actual
data
CLOSE<¢ile
is
in
different
is a file
which
device.
accepting
be
explained
has
been
need
to
adding
an
specified.
many
ways
are:
eg:
will
be
information
more
fully
made
between
do
anything
extra
command
Thus
the
format
mumber
simply a mirror
used
back
>.
by
the
from
tape
later.
the
data
items
about
detecting
64
Le4a
would
given
4)
If
off
again:
isi@
1820
18630
*5)
Strings
their
16816
i820
19830
1840
INRFUTHL,
be
sufficient
above
of
the
leading
characters
FOR
I[=4
INFUTH1,T#
NEAT
which
characters
At="'°
FOR
I=i
INFUT#1,T
NEXT
to
use
I
have
must
:
I
Tt,
Coe,
recover
of
have
TO
been
be
INFUT#i,LS
TO
from
R$
to
separate
been
[TEMS
=
ASCII
stored
reconstituted
LS
=
AF=AF+CHRS
07,
tape
added
=MIDEC(TH,
in
the
as
NN,
Oe
the
data
items.
to
strings,
form
strings:
CT)
stored
they
of
the
in
must
=}
numeric
the
example
be
stripped
values
of
73
Page 86

Advanced
6)
which,
characters.
of
character
Programming
Provision
like
the
This
the
tape
by
Techniques
must
sometimes
normal
is
done
one
character
character.
INPUT,
by
the
at a time,
be
can
use
made
only
of
GET#,
for
the
accept
which
to
recreate
limitations
string
picks
inputs
up
the
original
of
the
INPUT#
of
up
to
contents
string
88
281i
iB2G
Ag="'
GETH#i,T# : IF
A$+T# : GOTO
In
this
case
GET#
A$
until
the
end
of
7)
In
general
is
right
write a loading
stored
PRINT#
by
the
program
The
save
program
is
stopped
pressing
considerable
will
therefore
problems
The
load
‘auto-load’
ways
to
of
auto-initialise
program,
variables
to
the
initialising
by
the
program.
the
user,
data
is
to
tape.
If
initialisation
arrays
to
since
they
of
such a module:
1@@@
i@i@
LIMNGTT=100
the
best
next
to
the
routine
is
to
edit
the
statements
in
many
routine
menu,
‘STOP’)
the
to
if
the
receive
IF
DIM
with
(which
bodies
be
able
with
the
64
routine
function
‘auto-initialise’
the
which
be
start
there
added
user
routine
will
be
A#(H)
AF(106)
means
from
module
The
is
chooses
the
loaded
=:
T#<>CHR#(iz)
1820
will
continue
string
marker
place
one
which
which
line
to
INPUT#.
different
should
again
that
can
no
from
be a normal
perhaps a reminder
should
is a good
of
data
to
save
or
the
be
called
at
the
very
user
has
that
scratch,
not
auto-load
data
the
to
will
be
data,
but
from
THEN
RE=-CHRE
to
is
detected.
for
the
saves
exactly
numbers
Even
ways.
be a menu
idea
are
being
the
data
program.
in a very
beginning
technique
the
the
auto-initialise
or
of
being
function
held
by
keyboard
load
data
carried
,BF(25)
out,
variables
tape
13568
(12)
pick
up
program
it.
This
mirrors
of
the
so
the
program
to
to
save
entered
regularly
different
of
the
described
two
options
starting
executed
adds
the
program,
or
existing
from
namely
will
not
anyway.
,ALZ
THEN
characters
module
1s
the
saving
the
option
with
if
to
tape
be
Given
CIM)
which
because
order
routine
two
routines
function,
user
before
rather
data
before
into
the
against
way
program,
in
Chapter
of
either
function
GOTO,
there
is
these
options
to
specify
data
then
the
parts
set
to
below
,B“(SS)
and add
reloads
the
safest
in
which
and
can
called
the
than
it
program
the
possibility
by
the
similar
1.
In
RUNning
will
which
already
by
whether
first
loaded
some
parts
which
their
initial
is
an
Ag=
them
data
way
data
change
be
called
from
program
simply
is
lost.
the
user
use
of
in
some
the
case
reset
will
lead
data
held
allowing
new
from
of
set
up
value
example
=
to
to
was
the
If
of.
an
the
the
the
the
74
Page 87

Chapter 6 Storing
and
Retrieving
i@2@
Er
1430
Ros
i144@
Here
and
of
Once
from
include
initialisation
important
intitialisation
save
Save
Given below
of
variables
employed
AGAMA
~H{@iO
FAAS
2SO0275
“4430
N
“4040@
2480536
INFUT
CY
/N)s ° 3
IF
GOTO
TTENS=@
the
auto-initialise
‘DO
fit
LEFITS(OF,15=-"Y¥°
ise
declares a variable
the
program,
these
tape.
all
in
are
declared
Remember
the
variables
this
module
than
usual
value
of
and
load
modules.
and
Load
is
an
example
my
own.
There
is
involved,
with
REMKEKRKKEKRERKRERHRERKKKRAHHKRESRERREEE
REM
REMRKAKRKREKRHKKRKRKEKRKKRARHHRERREREERHE
RE=CHRE
INPUT
CRYVSIRETURN’
IF
OPEN
the
complex
DATA
NN¢=—'°
1,1,1,°FILENAME’
YOU
:
NN=@
line
is
1000.
whose
value
case
the
the
user
that
if
data
which
which
is
not
to
spell
out
zero,
in
order
routines: a working
of a save/load
no
need
to
example
bodies
(iz)
“POSITION
3:
of
FILES
0+
THEN
$,R#,004,R£,CU,RE,iTEMS
2A690
=HiG@
R$,T#(1.1)
[ii
2“Hi26
RE,AF(CI,1)
7~His@
“@14@
=,002,CU,ITEMS
[4156
27H16HW
TH(I,1),7T¢1)
IF
CU=@
FOR
IF
IT=6
FOR
FRINT#i
OFEN
IF
CU=@
FOR
THEN
[=0
TO
,R#F,TCI)
THEN
I=@
TO
,.R#,CCI}
=:
1,1,@,
THEN
I=6
TO
=
CuU-i
IT-i
CLOSE1
FILENAME’
CU-i
WEXT
WISH
:
CT=i2
The
second
will
not
maximum
can
specify
is
loaded
are
passed
executed.
all
the
to
remind
try
to
1s
intended
data:
TAFE
20140
20110
:
=
NEXT
20120
:
+
NEXT
=:
20170
:
TO
LUAD
THEN
be
changed
number
whether
from
For
variables,
FROM
GOSUB
:
BASE=2
line
dimension
during
of
data
tape
then
over
in
this
reason
even
yourself
items
the
when
example
routine
understand
PRINTHI,T#(1,@3,
FPRINT#i,AF(I,@),
RETURN
INFUT#I,T#(1,0),
taken
to
illustrate
CORRECTLY
:
FPRINT#i,NN
=:
INPUT#1,NN
from a program
the
functions
only
TAF
LUADE
four
the
permitted.
1s
to
be
that
data
part
it
is
even
those
with
writing
the
method
THE
arrays
course
loaded
must
of
the
more
an
the
of
the
75
Page 88

Advanced
Programming
Techniques
2Wi74@
“4186
AStI,13,Ct1)
“WiSiW@
Here
module
according
initialisation
always
line
specify
saved
contents
the
routine
and
recalled
Variations
Owners
because
is
not
because
or
find
data,
will
overwrite
same
IF
FUR
CLOSE1
the
user
is
automatically
to
whether
in
contain
could
something
be
replaced
whether
or
loaded,
of
two
format
was
then
in
of
the
in
fact
editing
exactly
for
of
disks
of
the
speed
only a question
the
disk
the
specified
separating
have
to
be
the
file
filename.
Li=6
T=4
given
THEN
TO
=:
=:
the
detects
the
that
it
is
vital
with a simple
loading
with
or
the
variables
two
halves
copied
the
lines,
the
order
disk
will
find
at
which
of
drive
will
input
items
and
made
for
if
previous
26196
fT-1
NEXT
RETURN
=:
opportunity
whether
string
NN§$
contains
to
choose a variable
when
the
program
two-line
saving
is
intended.
amount
CU
of
from
thus
in
the
and
the
the
which
use
of
IT.
Finally
module
save
helping
they
of
data
information
the
speed
at
automatically
file.
The
techniques
so
forth
are
the
specifying
batches
the
of
INFUT#1I,AS(I,@),
to
position
data
is
to
the
be
anything — this
for
holds
data.
menu
allowing
Two
sets
data
to
be
handled
the
file
is
is
exactly
routine
to
ensure
were
files
far
can
which
the
position
same
kind
data
have
by
changing
that
stored.
more
be
loaded
disk
an
output
for
actually
but
some
of
file
been
the
tape
and
then
saved
or
is
like
this
test
which
This
‘auto-load’
the
of
arrays
are
based
closed.
same.
line
items
Note
The
numbers
would
convenient
and
saved.
operates,
file
on
it
storing
extra
provisions
to
be
used
stored
under
the
loaded
auto-
will
user
then
on
the
that
load
simply
This
is
also
the
disk
the
and
the
to
be
to
1)
As
well
as
specifying
OPEN
specification.
type
accepts
can
of
where
a
to
76
statement,
of
application
items
offer
the
OPEN
OREN
1,8,2,
the 8 refers
sequential
which
information
In
of
them
statementis:
file
the
the
disk
drive
the
case
of
is
known
information
back
in
the
“FILENAME,S,W’
to
the
device
and
the W indicates
will
be
type
of
file
with
data
requires
files
the
the
kind
as a ‘sequential’
in
the
order
in
which
same
order.
To
number
output.
of
the
that
the
Note
that a secondary
the
numbers
filename
of
file
file,
they
create
such a file
disk
file
is a ‘write
attached
to
include
we
are
using
or
one
which
are
given
drive,
the S specifies
address
an
for
simply
and
the
format
file’
or
of
to
the
extra
this
later
one
two
Page 89

is
normally
do
not
When
OPEN
used
apply.
reading
statement
with
back
is:
disk
files
and
information
the
drawbacks
from
Chapter 6 Storing
noted
such a file
the
in
relation
format
and
Retrieving
to
tape
of
the
OFEN
where
information
omitted,
2)
1,8,8,
the R indicates
will
the
disk
The
other
complication
actually a result
files
are
contained
load
module
what,
if
exactly
In
the
not
accidentally
the
same
where
and
then
program.
so
that
format
OREN
Of
course
filename
not:
any,
where
case
name.
the
same
resaved,
To
it
will
for
this
1,0,2,
the
and
given
new
information
of
This
allow
overwrite
1s:
facility
with a user
“FILENANE,S,R°
that
this
be
taken
back
drive
assumes
that
of
the
intelligence
on
its
present
above,
information
the
wipe
the
is
will
be
disk a check
out
an
existing
is a valuable
data
file
will
be
many
times
for
this a special
any
existing
“@@sFTLENAMNE,S,W’
can
be
choice
is a ‘read
into
the the
that a read
arises
of
the
disk.
When
C2N
recorder
being
written
stored
is
provided
file
protection
recalled
in
the
course
prefix
file
combined
of
whether a file
file’
64.
file
is
intended.
from
the
drive
in
using
is
not
over.
by
positioning
to
ensure
by
trying
but
there
from
disk,
of
can
be
of
the
same
with
the
or
one
If
the
use
of a disk
knowing
tape,
capable
The
the
that the
to
save
are
added
the
continued
added
name
ability
will
be
from
W/R
exactly
as
in
the
of
detecting
user
determines
tape.
user
another
often
occasions
to
or
amended
use
to
the
filename
and
type.
to
define
overwritten
which
suffix
drive
what
save/
does
with
of
The
the
is
is
a
or
i7i@
$+°SSW"
1720
FILE
1730
1740
INPUT
Q$="N" : INPUT
(Y/N):
IF
OPEN
Conclusion
There
is
no
are a simple
right
is
often a fiddly
knowledge
that
"NAME
"s@¢
Q$="Y"
2,8,2,FFS
doubt
that,
matter,
programs
THEN
though
getting
job.
That
which
FOR
FILE:";FF#
“OGVERWRITE
FFS=
the
outlines
the
data
file
should
are
not
going
:
EXISTING
"@O:"+FFS
of
storing
module
be
allowed
to
store
and
of a complex
to
credible
FFS=FF
retrieving
program
detract
from
amounts
data
the
of
77
Page 90

Advanced
Programming
Techniques
information
computer
cassette
Disks
useful
certainly
limited
or
to
keyboard.
probability
age
can
and
cassettes
information.
preferable
either
the
information
If a set
worth
need
into
load
to
external
scorning
large
quantities
are
reliable
Using
to
working
one
set
which
of
information
the
effort
storage.
the
speed
of
and
them,
with
of
information
can
involved
Nor
should
with
which a disk
information
even
relatively
no
matter
programs
which
be
entered
is
worth
in
storing
we
all
into
fast
what
their
of
the
is
built
at
one
working
it
safely
be
fooled
drive
or
the
64’s
memory.
ways
of
limitations,
kind
which
into
the
session
with
it
for
future
by
the
even
storing
is
are
program
at
the
is
in
all
use.
a
78
Page 91

CHAPTER
7
Logical
Few
techniques
lines,
or
of
the
programming.
the
logical
micro
owners
their
potential.
The
humble
Every
BASIC
of
programming.
as
it
seems
ways
of
sometimes
The
to
whether a condition
such
as:
Conditions
indeed
internal
essence
logic
In
condition
use
programmer
or,
to
achieving
seem
of
can
provide a greater
make a program
of
the
64
in
this
them
chapter
IF,
regularly
and
we
the
IF
uses
Even
so,
the
use
put
it
results
to
realise.
IF
is
another
that
set
an
by
way,
with
action
the
saving
look
more
conjunction
enter
the
logical
in
IF — it
operators
their
programs
is
one
of
IF
is
not
there
are
IF
statements
can
be
programmer
in
the
elegant
with
more
sometimes
AND
without
of
the
always
often
more
than
performed
is
fulfilled.
length
than
most
of
program
the
proper
normal
obscure
and
as
straightforward
BASIC
world
OR.
ever
realising
essential
straightforward
micro
or
not
according
Thus
owners
in a line
use
of
Many
tools
i@@
IF
only
if A is
be
carried
statement.
character
ignored,
i146
4 : GOTO
Where
expressed
eg:
IF
too
condition
As+i@
greater
out.
In
program
Asif THEN
on a single
to
jump
THEN
than
This
this
way,
line, a series
2664
many
commands
around a section
is
true
line,
F=K+1
10
will
for
within
F=kh+1
the
the
addition
any
part
the
limits
of
commands
2:
follow
simplest
of
the
in
the
second
of a line
X=A£-14
of
the
which
length
can
be
:
from a single
alternative
is
to
program:
part
of
the
falls
after
of a single
carried
Y=yvY*"i
condition
use
the
opposite
line
an IF
out
to
80
or
be
79
Page 92

Advanced
160
1146
"2
Programming
IF
A*=10
FPRINT
K=K+1
Techniques
"THE
2
X=X-10
THEN
VALUE
GOTO
=:
120
OF
A
Y=¥*100
IS
NOW
=:
GOTO
OVER
10
200
Protecting
One
use
of
the
it
is
to
protect
cause
SUBSCRIPT
2
iS
2
This
subject
20
The
is
Errors
A
around
scan
line
the
DIM
5525
Tr
problem
IF
only
the
line
common
through
entered
program
ACS)
AtSS)>
to
an
$S¢=24
limit
length.
arising
error
part
of a line.
1s:
against
power
against
error
will
can
be
IF:
to
the
from
found
an
array,
illegal
of
IF
to
isolate
possibly
to
stop.
be
generated
1
THEN
avoided
THEN
number
by
IF
of
IF
in
programs
Thus
the
intention
subtracting
values
the
part
illegal
values
In
the
in
line
a
making
following
20:
the
A(SS)218
IFs
which
can
Is
to
forget
of
10
from
of
the
of
variables
original
THEN
be
‘cascaded’
this
the
programmer
all
values
line
which
which
example a BAD
IF
in
line
Sa
in
this
power
of
IF
to
might
over
100,
follows
would
20
itself
way
default
be
to
but
the
This
would
encountered
encountered
If...
One
which
micros,
user
THEN...ELSE
deficiency
has
become
the
is
permitted
80
only
in
were
over
the
NEXT I will
of
the
an
IF...
THEN...ELSE
to
specify
fact
make
100.
be
IF
statement
accepted
two
the
The
first
ignored
on
part
of
statement.
actions
after
adjustment
time a value
and
the
loop
the
64
is
the
the
BASIC
In
this
the
IF,
if
every
less
than
terminated.
absence
on
optional
one
many
to
be
of a feature
other
format
carried
element
100
is
home
the
out
Page 93

if
the
condition
as:
i@@
IF
would
add
not — NB
is
that
it
either/or
this
the
i447
can
ifMM
If
the
on
144
EMS"
110
T
actions
on
the
IF
and
IF
be
simulated
TT=F
actions
the
same
IF
:
IF
ENTERED"
specified
Asti
one
this
is
very
THEN
to K if A were
will
not
often
in a program
64.
One
one
after.
A166
THEN
by:
s
F=@
to
be
carried
line,
two
A+1@ THEN
K=K+i
A<i@
THEN
=:
run
the
of
the
Thus:
lines
=:
K=@
is
true,
F=K+i
on
your
case
and
simplest
K=k+i
:
IF
out
would
can
be
FRINT
GOTO
PRINT
:
the
more
that
other
Ati
used
200
GOTO
other
ELSE
than
64.
the
ways
ELSE
take
with
"MORE
“TEN
The
256
Chapter 7 Logical
if
it
is
false.
K=K-1
10
and
subtract
usefulness
programmer
ways
must
is
to
specify
Kk=&
THEN
too
opposite
E=TT+1
much
THAN
ITEMS
Thus a line
one
of
this
command
needs
be
found
to
one
action
room
to
be
conditions:
TEN
NOT
Conditions
such
if
it
were
to
specify
achieve
before
included
IT
YE
IF
with
You
may
are
used.
made
If
an
action
the
condition
IF
A
or
it
could
TF
Ac1i
The
second
be
confused
to
remember
>,
notice
In
setting
between
is
could
==
be,
THEN....
form
by
<and
in
the
out
simplicity
meant
to
read:
14
THEN....
in
most
circumstances:
is
shorter
the
11
is
that
if
=
examples
conditions
and
the
be
carried
but
when
when
the
important
you
are
working
given
that
in a line
ease with
out
if,
for
you
read
with
combinations
there
is
of
always a choice
which a program
instance, A is
the
program
value
is
10.
10
The
non-integer
>=
and
may
be
or
less,
you
may
other
point
numbers,
<=
to
be
read.
then
well
ie
81
Page 94

Advanced
Programming
Techniques
numbers
as
<=10,
IF
with
The
power
BASIC
the
programmer
same
line.
i@W@
TF
128
GOTO
124
@F
both
of
120
will
one:
144
IF
A
different
144
TF
iif
iF
i241
GOTO
124
E=k4+1
that
may
since
<11
the
operators
of
the
of
the
operators
In
the
@si4 THEN
ish
Be=i1ale
the
conditions
not
be
acted
421%
problem
&2if
Bi=106
1468
not
be
whole
would
allow
AND
IF
statement
AND,
to
combine a number
lines
iff
THEN
specified
upon.
Using
AND
B<=18@
is
presented
THEN
1208
THEN
numbers,
through
and
is
vastly
OR
and
R=h
+i
must
AND
by
the
i276
<11
any
OR
increased
NOT.
of
separate
be
met,
the
THEN
lines:
does
value
The
or
lines
K=K+1
not
between
by
first
two
IF
statements
the
second
can
be
mean
the
10
and
the
addition
of
these
part
combined
same
11.
allow
into
of
to
the
line
into
where
either
acted
upon.
Here
i@@
IF
Activ
Combining
ANDs
of
the
14
118
itu
13
14
82
and
ORs
conditions
64
will
actually
ii
ah
ivi
=a
Cl fi
a
RINT
=|
F
A=
ee | an
of
the
conditions
we
OR
AND
can
be
provided
assess
“fCLAIS
1”
AND
must
make
Be=1480@
and
combined
that
them.
being
OR
some
Enter
B=i¥4@
met
use
of
OR:
THEN
on
the
attention
these
OR
would
same
lines:
C=i4
F=K+i
line
is
paid
suffice
to
specify
to
the
THEN
for
line
complex
order
FPRINT
130
in
to
be
sets
which
Page 95

Chapter 7 Logical
Conditions
Running
the
out
140
14M
first
the
action
to
read:
IF
the
program
two
conditions
specified
A=i2
OK
and
you
will
find
again
to
read:
144)
IF
°y
and
possibilities:
1)
The
referring
C=50).
2)
The
ANDed
C=50.
A=1@
d
everything
true
condition
to
B,
true
condition
together,
so
AND
that
AND
works
that
so
will
result
connected
even
though C is
B=i56
line
140
B=i15%
again,
referring
the
referring
that
line
the
but
is
line
in
OK
being
by
the
AND
not
equal
GR
C=if
will
now
not
OR
C=5H
what
does
to C has
being
read
replaced
IF
to C replaces
is
read
IF
printed,
were
to
THEN
print
OK.
THEN
it
mean?
A=10
both
of
(A=10
so
it
is
sufficient
10.
Now
change
PRINT
Change
PRINT
There
the
false
AND
(B=150
the
two
AND
B=150)
clear
that
to
carry
line
line
140
are
two
condition
OR
conditions
OR
The
only
way
line
140
becomes:
140
IF
OK’
Now
we
can
ANDed
conditions
one
stands
This
lead
produce
if
you
Consider
1446
)
conditions
condition.
on
its
strict
to
confusion,
the
are
unsure
this
IF
THEN
to
discover
A=28
see
that
with
ANDs
On
own.
order
expected
of
line:
‘A=i6
PRINT
AND
the
as
between
the
in
which
with
result.
the
way
OR
‘OR’
which
B=15@
condition
if
they
other
hand
AND
lines
which
The
in
which a series
8-144)
is
right
OR
after
were
them
any
and
answer
is
to
make
C=5@
the
one.
The
must
all
condition
OR
are
appear
to
the
of
AND
another
THEN
OR
has
conclusion
be
fulfilled
preceded
evaluated
to
be
sensible
problem
conditions
(C=50@
change
PRINT
replaced
is
that
as
if
they
by
can
sometimes
failing
is
to
use
hang
together.
OF
D=264
so
that
the
two
any
were
an
OR
to
brackets
83
Page 96

Advanced
Here
the
in
the
last
two
then
try
Programming
brackets
line,
and
force
before
thinking
adding a new
Techniques
isolate
the
line
about
line
the
to
second
to
evaluate
the
the
little
and
AND.
routine
third
the
first
[f
this
just
conditions
two
conditions
is
all
still
used:
from
as
clear
the
and
as
AND
the
mud,
Change
program
is
)
and
pair
second
true
line
will
filled.
Now
THEN
you
will
of
conditions
pair
conditions
140
PRINT
find that
of
Unpacking
If
you
have
real
do,
then
take
and
‘FALSE’
following
1)
=)
2}
4)
3)
53
rules:
TRUE
TRUE
FALSE
TRUE
TRUE
FALSE
to
the
last
print
OK
when
alter
line
140
‘OR’
the
in
the
conditions
and
so
the
complex
trouble
the
conditions,
AND
AND
AND
GR
OR
OR
line
which
TRUE
FALSE
TRUE
FALSE
FALSE
with
FALSE
version
again
routine
brackets
is
fulfilled.
line
it
is
to
can
given
run,
read:
still
is
fulfilled;
The
be
acted
conditions
complex
is
given
then
=
=
=
sets
and
simplify
TRUE
=
FALSE
=
FALSE
TRUE
TRUE
=
FALSE
above
since
works.
AND
upon.
of
conditions,
convert
those
and,
not
surprisingly,
every
condition
Since A is
since D is
is
now
surrounded
and
it
into a series
conditions
according
equal
equal
many
of
in
the
to
10,
to
20,
by
people
“TRUE’
to
the
line
the
the
two
the
As
an
example,
C=50
and
TF
A=1@
translate
TRUE
and
84
AND
using
D=20.
AND
as:
the
assume
In
FALSE
rules
this
B=20@@
set
out
as
in
case
OR
above
the
program
the
conditions
OR
C=50
TRUE
this
can
be
above
in
the
line:
THEN
first
simplified
that
A=10, B =100,
....04.
to:
Page 97

Chapter 7 Logical
Conditions
FALSE
and
finally
becomes:
TRUE
TRUE
OR
AND
FALSE
Setting
Conditions
an
action
will
1)
If
an
action
an
action
is
OR
TRUE
to:
FALSE)
FALSE
limits
are
often
be
set.
is
to
not
to
be
AND
used
to
The
format
be
carried
carried
set
out
(FALSE
limited
here
out
if
ranges
1s:
if a variable
the
variable
OR
FALSE:
for a variable
is
in
the
is
out
of
the
within
range
range:
which
11-20
or
i@@
iF
2)
If
an
action
or
to
be
carried
i4@4
IF
Sometimes
when
testing
characters
case
we
need
1400
IF
"A"
AND
IF
with
NOT
Few
people
indeed
there
A=sil
is
not
out
if
Asii
the
being
(IN¢S="O"
OR
need
the
input
either
to
use
two
IN@<.="Z2Z")
regard
are
few
AND
A<=20
to
be
carried
the
variable
A2t20
is
to
specify
of a character
the
numbers 0 to 9 or
pairs
of
conditions:
AND
THEN
NOT
as a regular
things
that
THEN...
out
if a variable
is
out
of
THEN...
two
possible
to a program,
INS<="9")
GOTO
part
it
can
accomplish
the
range:
ranges.
the
letters A to
200
of
their
that
is
in
the
range
This
can
often
with
the
permissible
Z.
OR
CIN#3=
programming,
cannot
be
11-20
occur
In
this
and
done
in
85
Page 98

Advanced
other
ways.
and
it
can
the
simulation
opposite
clearly
1464
IF
FMS"
110
IF
OT
YET
Programming
The
be
used
of
conditions.
by:
A>1i@
:
K=K+1
NOT
ENTERED"
Techniques
function
to
make
IF...
THEN...ELSE,
This
THEN
:
GOTO
Az=-10
of
NOT
certain
could
FRINT
THEN
:
F=0
is
to
reverse
lines
more
where
probably
"MORE
200
PRINT
:
GOTO
the
readable.
two
consecutive
have
been
THAN
“TEN
250
effect
of a condition
Take
expressed
TEN
ITEMS
the
lines
IT
N
case
used
more
of
Using
In
spurious
The
needed
such
In
RePRE
If
us
happening
some
65536
strange
minus
of
The
In
on
conclusion
after
0
with X equal
of
logical
the
chapter
situation
to
as:
fact
what
we
assume
some
way
and
way
one,
affairs
value
assessing a condition
the
basis
the
if
it
is
false.
them
as
on
negative
was
have
65536
we had
Ge
2
that
the
interesting
in
the
by
(K<0).
sometimes
sometimes
otherwise
arise?
of a condition
that
something
about a condition
IF
and
gives
Take,
to 7 and Y equal
statements
conditions
string
handling a simple
value
given
by
that
if
the
value
added
was:
Rek-SoS363
two
things
second
In
nothing,
the
it
for
rather
to
oor
statements
about
form
is
addition,
the
represent
‘-65536’
in a program
is
either
the
64
one
of
two
example, a program
to
5.
like
‘John
the
FRE
produced
it.
This
(hi)
mean
the
that
the
since
(K<0)
the
value
will
make
the
true
examines
values,
Now
is
line
function
by
could
have
exactly
second
‘IF
K<0’
we
shall
in
the
second
zero
and
no
sense.
64,
like
or
false.
the
—1
1f
the
with
consider
taller
than
was
given
into
the
correct
FRE
was negative,
been
done
the
same
form.
Clearly
is
being
sometimes
form
sometimes
How
does
any
other
micro,
In
order
expression
expression
two
variables X and
the
following
Bill’:
to
convert
by a line
thing,
what
replaced
wish
to
must
in
the
this
works
to
record
which
comes
1s
true,
and
a
value.
it
it
tells
is
in
add
some
value
state
its
and
Y,
think
86
Page 99

ty
as
“
3
a
ery
CT
i
C3.
Ln
Fairly
obviously,
In
the
of
zero,
b)
above
has
out
if
the
anything
For
instance
14%
IF
would
result
one
but
anything
nei
|
cel
context
and
c) a value
been
included
condition
which
can
the
line:
TT
THEN
in a jump
statements
of
an
IF
statement,
of
minus
the
has
been
be
assigned a value
SOTO
to
line
other
than
zero.
a)
and
d)
are
false,
a)
and
one.
Where a condition
action
specified
assigned a value
can
i232
120
if
the
value
Strings
too
Chapter 7 Logical
while
d)
would
by
the
IF
of
be
used
after
of
TT
can
be
treated
b)
and
c)
are
be
assigned a value
like
those given
statement
minus
the
were
is
one.
IF
statement.
not
only
in
this
Conditions
true.
carried
In
fact
minus
way:
would
technique
a
checking
checking
Using
In
statement,
conditions
used
an
be
zero
or
within a program
techniques.
conditions
addition
anywhere
IF
statement.
acted
can
be
null
value.
to
being
another
are
evaluated
in a program
upon
used
One
interesting
The
Whenever a condition
it
will
always
the
program
the
FRE
when
the
they
can
statements.
iG
11i4@
174
function
condition
be
used
Take
-=14G
@©F
TTsist
IF
Kx<3@
be
assigned a value
in
just
the
above,
(K<0)
in
combination
the
following
THEN
if
A$
were
in a variety
application
and
this
as
values
able
to
use a single
area
as
zero
or
to
give
FRE
converting
is
encountered
and
same
way
65536
is
is
true.
with
lines:
THEN
F=k+36
F=K-25
anything
of
ways
which
1s
described
is
opened
minus
one
during
this
as
any
added
The
beauty
each
but
where
is
variable
one.
of
the
line
the
value
other
to
the
other
an
empty
it
is
important
commonly
in
the
up
by
In
fact,
two
values,
above
relies
execution
can
be
used
variable.
result
of
such
to
replace a mass
string.
to
used
chapter
to
the
conditions
on
activate
way
in
not
simply
on
this
of a program
in
controlling
In
the
of
FRE(0)
conditions
This
detect
in
error
error-
an
which
can
fact.
case
only
is
that
of
IF
be
in
of
IF
87
Page 100

Advanced
i346
144
Programming
IF
YP="DERTT®
IF
FRr=@
Techniques
THEN
THEN
-=k
H=k+108
iz
These,
Plus
One
the
account
one.
100
100),
Multiplying
Note
acondition, a straightforward
multiply
the
wanted
multiply
be
be
and
many
1006
K=190@-SO(TT+120)
(¥Y$="DEBIT"))
or
minus?
confusing
wrong
way
of
the
If
you
want
times
its
value
or
K+100.
also
that
by
and
value
of
the
to
multiply
by
1000+999*(X<>0).
multiplying
multiplying
more
thing
here
round.
fact
that
to
add
when
and
when
multiplying
first
subtract
condition
by
1000
by
1000+0,
by
1000+
of
the
same
*%
(ZZ74+(ZZ-1)
is
that
[f
you
think
the
result
100
to K if
true
(ie
dividing
method
from
opposite
if X was
or
1000. I X
(999),
could
+
2SS*(XX<50;
the
plus
about
of a true
something
minus
(or
dividing)
is
it
one
to
the
equal
If X was
or
one.
be
replaced
(FF.
and
minus
it,
this
condition
1s
true,
one),
so
according
to
take
less
than
condition
to
zero,
equal
was
not
by
27@))
has
is
you
that
the
number
its
chosen.
then
to
zero
equal
lines
—
signs
to
be
not
one
have
the
to
own
you
then
to
zero
such
140*
appear
done
but
to
subtract
result
the
result
you
value
Thus
would
you
you
as:
to
to
take
minus
is
K-(—
wish
times
if
you
in
fact
would
would
be
of
to
Avoiding
A
point
to
remember
that
IF
isolates
fulfilled.
the
loop
such
144
WM)
There
appropriate
of
from
88
Earlier
NEXT
to
be
executed.
as:
FOR
2
NEXT
are
conditions.
being
isolation
Is
everything
on
we
which
terminates a loop
Such
f=0@
TO
some
cases,
to
replace
Where
accessed
if
by
IF
that
conditions
that
noted
problems
99
it
should
IF
statements
two
IF
statements
it
has
an
can
be
follows
the
:
it
when
danger
ACTII=AACIID+1@0#
if
the
intention
can,
however,
be
remembered,
with
of
expressions
are
illegal
value,
used
the
using
used
the
to
overcome
IF
condition
IF
in
the
is
for
the
be
overcome
(ATI
where
based
to
protect a variable
use
of
conditions
the
same
whole
by a line
ei
it
on
the
fact
is
not
line
of
the
is
not
value
will
as