Input - Commodore SX-65 Portable User Manual

Portable color computer
Table of Contents

Advertisement

INPUT
Up to now, everything in a program has been set up before the program
RUNs. Once you executed the program, you couldn't change or add anything.
The INPUT statement lets you send information to a program WHILE it is RUN-
ning. Not only does the program act on this information you supply, but the pro
gram won't continue until you supply it.
To get an idea of how INPUT works, type NEW, press RETURN, and enter this
short program.
10 INPUT A$
20 PRINT "YOU TYPED ";A$
30 PRINT
40 IF AS = "STOP" THEN END
50 GOTO 10
RUN
? GO
YOU TYPED GO
? CONTINUE
YOU TYPED CONTINUE
? STOP
YOU TYPED STOP
Here's what happens in this program:
Line 10 tells the computer to display a question mark to prompt you to INPUT
a value for AS, and to wait until you supply the value before continuing the pro
gram execution.
Line 20 PRINTS a message and the INPUT value, and line 30 PRINTs a blank
line.
Line 40 tells the computer to end the program immediately IF the value you
INPUT for AS is STOP.
Line 50 returns the program to line 10 so you can INPUT another value. IF line
40 is true because the last value you INPUT for A$ was STOP, then line 50 isn't
executed.
You can INPUT numeric or string variables, and you can have the INPUT
statement print a message along with a question mark to describe the kind of
INPUT the computer is waiting for. For example, here's what happens when you
add a prompt message to line 10 of the previous example:
10 INPUT "KEEP GOING";A$
Prompt message can't
RUN
be more than 38
KEEP GOING? GO
characters
YOU TYPED GO
KEEP GOING? STOP
YOU TYPED STOP
49
INPUT
Up
to
now,
everything
in a program has been
set
up
before
the program
RUNs.
Once
you executed
the program,
you couldn
't
change or add
anything.
The
INPUT
statement lets you
send
information to a program WHILE it
is
RUN·
ning. Not only
does the program act on this
information
you
supply,
but
the pro·
gram won't continue
until
you supply
it.
To get an idea
of
how
INPUT
works,
type
NEW,
press RETURN
,
and
enter this
short
program.
10 INPUT
A$
20
PRINT
"
YOU TYPED
";AS
30
PRINT
40
IF
A$
=
"STOP"
THEN
END
50 GOTO
10
RUN
?
GO
YOU
TYPED
GO
?
CONTINUE
YOU
TYPED
CONTIN
UE
?
STOP
YOU TYPED STOP
Here's what happens in this program:
Line
10
tells
the
comp
uter
to display a question mark to prompt you
to INPUT
a value for
AS,
and to wait until
you
supply the value
before
contin uing
the pro·
gram
execution.
Line 20
PRINTs
a message
and
the INPUT
value, and line 30
PRINTs
a
blank
line.
Line 40 tells the computer to end the program immediately
IF
the value
you
IN
PUT for A$
is
STOP.
Line
50 returns the program to
line 10
so you can
INPUT
another value.
IF
line
40
is
true
becau
se
the
last
value you INPUT for AS
was
STOP,
then line 50 isn't
executed.
You
can
INPUT numeric
or string
variables,
and you can
have
the INPUT
statement print
a
message along
with
a question mark to describe the kind
of
INPUT the
computer
is waiting for. For
example, here's
what happens when you
add a prompt
message to line
10
of
the previous example:
10 INPUT
"
KEEP
GOING";
A$
RUN
KEEP GOING? GO
YOU
TYPED
GO
Prompt message can 't
be more
than
38
characters
v
KEEP GOING? STOP
YOU
TYPED STOP
v
v
49

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sx-64

Table of Contents