Example 3- Using Variables In Programming - Sharp PC-1403 Operation Manual

Hide thumbs Also See for PC-1403:
Table of Contents

Advertisement

96
The
value assigned
to a
variable can
change during the
execution
of
a
program, taking
on
the value
typed
in
or
computed
during
the program.
One
way
to assign
a
variable is
to
use
the INPUT
verb.
I
n the
following
program,
the value
of
A$
will
change
in
response
to the
data typed in answer
to the
inquiry
"WORD?".
Enter this
program:
10 INPUT
"WORD?";
A$
20
B=
LEN
(A$)
30
PRINT
"WORD IS ";
B;
"
LTRS"
40
END
L..J
LJ
L
means space
Before
you RUN
the
program,
note
several new
features.
Line
30
of
this
program
exceeds the
24-character
maximum of
the
computer's
display.
When
a line
is
longer
than 24
characters
(up to the 79-character
maximum), the
computer moves the
characters to the left
as
the
24-character maximum
is
exceeded.
This does
not
destroy
the previous input.
This
move to the left is
referred
to
as horizontal scrolling.
The second
new
element
in
thi
s program
is
the use
of
the END
statement
to signal the
completion of
a
program.
END
tells
the computer
that
the program
is
completed.
It
is
always good programming practice
to
use
an END statement.
As
your
programs become
more
complex,
you
may
wish
to
review
them
before
beginning
execution.
To look at your
program, use
the
LIST
command.
LIST,
which
can
only be
used
in the PROgram mode, displays programs beginning with
the
lowest
line
number.
A$=
"TOTAL"
To
assign a string
variable,
you also use a letter,
followed
by
a dollar
sign.
Do not use
the same letter In designating a numeric and a string fixed variable.
You cannot
designate
A
and A$
in
the same
program.
Remember
that
each string fixed variable
must not
exceed
7 characters
in
length:
A=5
If
you are unfamiliar with the use
of
numeric and string variables in
BASIC,
reread
these
sections
in
Chapter 4.
Using
variables
in programming allows
much
more
sophisticated
use
of
the
compu-
ter's computing
abilities.
Remember,
you
assign
numeric fixed variables
using any letters
from
A
to
Z:
Example 3- Using Variables in Programming
Programming the Computer

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents