DO File Statements

Reviewed and reorganized June 2020

IF / ELSE / ENDIF Statements

These statements are similar to their BASIC counterparts. The following functions and expressions are supported by IF, with the same syntax as for BASIC:

ABS

CHR

FACT

LEFT

MID

SPACE

UCS

ACS

COS

FIX

LEN

RIGHT

SQR

VAL

ASC

DATN

INSTR

LOG

RND

STR

ASN

DEVICE

INT

LOG10

SGN

TAN

ATN

EXP

LCS

LOOKUP

SIN

TIME

 

The following operators are supported:

Relational Operators

 

Mathematical Operators

Symbol

Meaning

 

Symbol

Meaning

=

Equal

 

+

Addition

<> 

Not equal

 

-

Subtraction

#

Not equal

 

*

Multiplication

Greater than

 

/

Division

>=

Greater than or equal

 

^

Raise to power

Less than

 

**

Raise to power

<=

Less than or equal

 

 

 

 

Comments

The most useful of the above functions, LOOKUP, works slightly differently than the BASIC Plus equivalent. Instead of returning the file size, it always returns –1 if the file exists, else 0. See the example MAIN.DO.

Note that unlike in BASIC where many of the above functions could optionally have a $ suffix (e.g. LEFT or LEFT$), in DO files the $ variation is not acceptable.

IF statements frequently operate on the Special $ Variables, which see for further comments and examples.

 

GOTO and EXIT Statements

GOTO is similar to the BASIC GOTO statement, except that it can only jump forward in the command file. The syntax of a label consists of a semicolon followed by the label name. See the label ";DONE" in the sample MAIN.DO file.

EXIT causes an immediate exit to the A-Shell command prompt, even if you are currently nested multiple levels deep in a command file.

 

LOOKUP Statement

The LOOKUP statement is a variation of the LOOKUP function; see IF statements above. The syntax is:

LOOKUP <fspec>/Optional message if not found

If the specified file is not found, the optional message (following the /, which is mandatory) is displayed and execution continues with the following line. Otherwise, the following line is skipped. Typically this is used with GOTO to create a conditional branch, as in the following:

LOOKUP $0/$0 does not exist!

GOTO DONE                           ; (EXIT might also be appropriate here)

VUE $0

;DONE