Getting Going; Conditional And Logical Statements - AMSTRAD CPC464 User Manual

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

Advertisement

Anything contained within brackets ( ) is dealt with first of all, and if the contents of the brackets are
themselves in the form a mixed calculation, then these will be handled in the order outlined above -
including any further brackets within the brackets. You must always end up with as many right
hand brackets as left hand brackets in such an expression or a Syntax Error will result.

4.4 Getting going

We' ve come some way since we introduced the PRINT statement back in 3.5. You should have picked
up enough of the ground rules of AMSTBAD BASIC to enable a progression to be made into the more
' computer' like realms of BASIC as opposed to the simple pseudo-calculator features. The BASIC
keywords will be introduced as necessary, refer to Chapter 8 for the alphabetical listing and
descriptions if their use is not obvious from the context in which they occur.
Many BASIC keywords say what they mean - the GOTO 50 command means go to the line numbered
50 and continue execution from there. END means just that, and BASIC returns to the direct
command prompt Ready whenever it encounters an END - even if it' s the first line of the program.
The direct (or immediate) mode allows you to enter a number of program steps by separating the
commands with a colon : . However, once you execute the line (press the
instructions are processed, and the line is discarded. You can always re-run it using the copy cursor
feature, assuming it' s still on the screen after it was executed.

4.5 Conditional and logical statements

BASIC makes extensive use of the computer' s capacity to do simple repetitive tasks at speed - and
without getting bored. A number of the programming commands are provided to assist in the
generation of this process (looping): commands that initiate, continue and spot when to finish
looping, if a predetermined set of conditions should be met.
The last of these elements of loop control concerns the ' relational expression' . In other words, how
one piece of data ' relates' to another is determined by a ' relational operator' . You can compare one
piece of variable data with another, or you can compare variable data with a predetermined
reference. The relational operators are:
<
less than
<=
less than or equal
=
equal
>
greater than
>=
greater than or equal
<>
Not equal
key) - the
[ENTER]

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents