AMSTRAD CPC464 User Manual page 91

Cpc464 colour personal computer 64k
Hide thumbs Also See for CPC464:
Table of Contents

Advertisement

! declares a variable to be real - which means the integer part, and the portion to the right, of the
decimal point. Variables default to being real upon switch on. Real variables can take any value in
the range 2.9E-39 to 1.73+38.
$ indicates a string variable, where the contents may be a mixture of numbers, letters etc. In other
words an arbitrary collection of characters that are delimited by being enclosed within double quotes
" " . For example:
N A M E $ = " B O B S M I T H "
Using this in our evolutionary example, add line 6, and adjust line 60:
5 CLS
6 I N P U T " W h a t i s y o u r n a m e " ; N A M E $
1 0 I N P U T " W H A T I S Y O U R S A L A R Y " ; S A L A R Y
2 0 I F S A L A R Y < < 1 0 0 0 0 T H E N G O T 0 3 0 ELSE 40
3 0 P R I N T " A S K F O R A P A Y R I S E " : E N D
4 0 P R I N T " A S K F O R A B I G G E R C A R "
5 0 I F S A L AR Y > 3 0 0 0 0 T H E N P R I N T
" a n d g e t a g o o d a c c o u n t a n t "
6 0 I F S A L A R Y > 2 5 0 0 0
" . . . . a n d l e n d m e a f i v e r " ; N A M E $
6 1 D A I L Y . R A T E = S A L A R Y / 3 6 5 :
P R I N T " t h a t ' s " ; D A I L Y . R A T E ; " a d a y "
7 0 F O R n = 1 t o 5 0 0 0 : N E X T n : G O T O 5
run
Note a space has been added after fiver or the name would be butted hard up against fiver . Try it if
you don' t believe us! The semicolon ; at the end of PRINT or INPUT statement supresses the
computer' s desire to start a new line at the end of each such statement - unless told otherwise.
We can also work in the subject of integers by adding line 61. Just type it in, and the computer will
organise the program:
5 CLS
6 I N P U T " W h a t i s y o u r n a m e " ; N A M E $
1 0 I N P U T " W H A T I S Y O U R S A L A R Y " ; S A L A R Y
2 0 I F S A L A R Y < < 1 0 0 0 0 T H E N G O T 0 3 0 ELSE 40
3 0 P R I N T " AS K F O R A P A Y R I S E " : E N D
4 0 P R I N T " A S K F O R A B I G G E R C A R "
5 0 I F S A L A R Y > 3 0 0 0 0 T H E N P R I N T
" a n d g e t a g o o d a c c o u n t a n t "
6 0 I F S A L A R Y > 2 5 0 0 0
" . . . . a n d l e n d m e a f i v e r " ; N A M E $
6 1 D A I L Y . R A T E = S A L A R Y / 3 6 5 :
P R I N T " t h a t ' s " ; D A I L Y . R A T E ; " a d a y "
70 FOR n = 1 t o 5 0 0 0 : N E X T n : G O T O 5
run
Note that the delay in line 70 has been increased to 5000 now that there' s more to read on the
screen. The result of the daily rate calculation is untidy - you might as well round it, to an integer
value. Add line 62 . . . . . . . . .
T H E N P R I N T
T H E N P R I N T

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents