EasyManua.ls Logo

Sharp MZ-700 - Page 45

Sharp MZ-700
213 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
2. 3. 5. 4 GET
I Format
Function
Try running the program shown above. Inclusion
of
character strings in the PRINT
and INPUT statements provides a clear indication
of
the program's operation.
Practical
computer
programs consist
of
combinations
of
sequences similar to the
one shown here. By combining commands, statements, and sequences in different
manners,
you
will soon find
that
there are many different methods
of
achieving
a desired result.
GET V
v .
....
..
Numeric variable
or
array element,
or
string variable
or
array element.
When this statement
is
encountered during program execution, the BASIC inter-
preter
checks whether any key
on
the keyboard
is
being pressed and,
if
so, assigns
the corresponding value
to
the variable specified in
v.
Whereas the INPUT statement
prompts for
entry
of
data and waits until
that
data
has been entered before resuming
execution, the GET statement continues execution regardless
of
whether any key
is being pressed.
Although data
is
substituted
into
variable v
by
the GET statement
if
any keys are
pressed when
the
statement is executed, the variable will be left
empty
(0
for a
numeric variable
or
null for a string variable)
if
no keys are pressed.
With numeric variables, this statement allows a single digit (from
0 to 9)
to
be
entered; with string
v~riables,
it
allows a single character
to
be entered.
This statement can be extremely useful when
you
want
to
enter
data
without
pressing
the
I
CR
I key,
as
is
often
the case with game programs.
(Example:)
1 0
PR
I N T "
NE
XT G O 9 CY 0 R N) "
2 0
GET
A$
3 0
IF
A$=
" Y "
THEN
5
0···
·· In the example above, execution
jumps from line
30
to
line 50
if
the
value
of
variable A$ is
11
Y".
40
GO
TO
2
0····
··
··········
··
·· ··
·
··
········
··
Line
40
unconditionally transfers exe-
5 0
PRINT
"
PROGRAM
ENO
"
cutiontoline20.
6 0
END
This program displays the
prompt
11
NEXT GO? (Y
OR
N)
11
and waits for input.
When the Y key
is
pressed, execution moves to line 50 and the program ends.
Until
that
time, however, execution loops repeatedly between lines 20 and 40.
Now delete lines
30
and
40
and try executing the program again.
As
you
can see,
execution
is
completed immediately regardless
of
whether any keys have been
pressed.
Note: When GET statements are executed in succession, a routine should be includ-
ed between them to ensure
that
each
is
completed before going on
to
the
next
. The reason for this is
that
key
chatter
(vibration
of
the contacts
of
the key switches) may result in two GET statements being executed simul-
taneously.
----------
--
----
--
--------
----
----
--
----
--
----
--
--------
----------------43

Other manuals for Sharp MZ-700

Related product manuals