Short Cuts; Multi-Statement Lines And Mixed Calculations - AMSTRAD CPC464 User Manual

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

Advertisement

4.2 Short cuts

It' s tedious typing PRINT every time, so you can use a ? instead, and BASIC will understand this
means PRINT (so long as it is not placed inside any phrase within quotation marks "" ). Note that
the ? option does not require to be de-limited using a space like the word PRIN T
line as a program rather than a direct command:
10?4*4
run
The answer is still the same, but now LIST this one-line program and as if by magic.....
list
1 0 P R I N T 4 * 4
BASIC has also inserted a space before expanding the question mark. In PRINT statements that
use quotation marks....
1 0 ? " H E L L O "
You may also get lazy and drop the final quote marks " on a line, as evidenced by the small
[CTRL][ENTER] shorthand cassette load and run routine which prints RUN" on the screen. The
same works in program lines, but it' s not a good habit to get into, since if you subsequently go back
to the line and add to it, you will probably forget to close the quotes again.

4.3 Multi-statement lines and Mixed calculations

You can perform a number of operations on a single line of BASIC - in fact, as many as you like up to
the maximum line length of 255 characters. As usual, statements should be separated by colons :
?2*8/5+5-4*777E9/3
returns.. . . . . . .
-1.036E+12
However, it is essential to understand the order in which the various mathematical operators (+ - * /
MO D etc) are recognised by BASIC, or you will make fundamental mistakes. They are:
Exponentiation - raising a number to a given power of 10.
Modulus - The remainder after Integer division.
MOD
Unary Minus (the minus sign used to declare a number as negative)
-
Multiply
Divide
/
Integer division: the result is shortened to give the whole number part of the
\
result, the decimal part is discarded by BASIC.
Addition
+
Subtraction
-
.
If you write the

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents