AMSTRAD cpc 6128 User Instruction page 39

Integrated computer/disc system
Hide thumbs Also See for cpc 6128:
Table of Contents

Advertisement

Reset the computer to clear the memory, ([CONTROL] [SHIFT] and [ESC] keys). If
you had wanted an input made up of any characters, (letters or letters and numbers),
the dollar sign
$
must be used at the end of the variable. This type of variable is called
a 'string variable'.
Type in the following program: (Note that in line 20 you must put a space after the
0
in
he
L L
0
and before the
m
in
my).
1 0 ; n put " w hat ; s you r n a me" ; n a m e $
[RETURN]
20 pr; n t "h e II
0
";
n a m e $; " my n a me ; s R
0
n a l d"
[RETURN]
run
[RETURN]
On the screen you will see:
What ;s your name?
Type in your name then [RETURN]
If the name that you entered was Fred, you will see on the screen:
Hello Fred my name ;s Ronald
Although we used n a m e
$
in the above example for the name string variable, we
could have just as easily used a letter, for example a $. Now we will combine the
above 2 examples into one program.
Reset the computer by pressing [CONTROL] [SHIFT] and [ESC]. Type in the
following:
5
c
l
s [RETURN]
1 0 ; n put " w hat ; s you r n a me" ; a $
[RETURN]
-- -20 - ;-n p u-t- !lwha t- -;-s - yo ur--ag e-"i b-
[R&TURN]-- - - - --- -- - ----- - - -
30 print "1 must say ";a$;" you dont
loo k " ; b; " yea r sol d"
[RETURN]
run
[RETURN]
In this program we have used 2 variables, a $ for the name and b for the age. On the
screen you will see:
what ;s your name?
Now type in your name (e.g. F red), then [RETURN].
You will then be asked:
what ;s your age?
Now type in your age (e.g. 18), then [RETURN].
Chapter 1 Page 26
Foundation Course

Advertisement

Table of Contents
loading

Table of Contents

Save PDF