Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

The following operators may be used as part of expressions. Arithmetic operators

The arithmetic operators take two numbers as operands.

+ add

multiply

A    raise to the power

subtract divide

Relational operators

The relational operators can compare numbers, and return a logical value of FALSE=O and TRUE=-1.

<    less than

<= less than or equal to <> not equal to

Logical operatorsequal to

>    greater than

>= greater than or equal to

The logical operators operate on numeric or logical values. Boolean FALSE is taken as zero, TRUE as —1.

Indirection operators

The following operators allow the programmer to access memory directly (called PEEK in other versions of BASIC) or to alter the contents of specified memory locations (called POKE in other BASICs).

These operators should only be used by experienced programmers, since they give the programmer the capability of altering the operation of other activities in the Cambridge Z88 operating system; in general, only addresses within the region allocated by a BASIC DIM statement should be altered.

byte indirection    word indirection string indirection

The usual way of using these operators is to allocate a vector using the DIM statement, and then manipulate elements of this vector with the indirection operators. For example,

DIM vec 15

allocates a vector of 16 bytes, and assigns its address to the variable vec. These bytes can be addressed as

Note that ?vec is an alternative way of writing vec ? 0. A typical manipulation might be

vec?l = vec?l + 1

Alternatively the vector could be addressed as 4 four-byte words:

Finally, the string indirection operator allows a string to be stored directly into an area of memory. For example:

$vec = "THE COMPUTER"

stores characters in the vector as follows:

The string can be accessed with the $ operator, so the following statement will print the string:

PRINT $vec

Individual characters can be accessed with the ? operator.

Order of precedence

The order of precedence of the operators is as follows:

Group 1

Group 2

Group 3

Group 4

Group 5

Group 6

Group 7

unary minus brackets

logical NOT

A    raise to the power

multiply divide

+    add subtract

less than

equal to

less than or equal to greater than

not equal to

greater than or equal to

AND Logical AND

OR    Logical OR

FOR Logical Exclusive-OR

 

NOT

so, for example, A-B*CAD is equivalent to A-(B*(CAD)).

  • No labels