The list of condition; in an IF ... THEN structure can be any list of tests, including AND and OR. Try changing the conditions of the last example with either of the following lines:
E> If NIGHT=DAY And NIGHT<>12 Then Goto BED E> If NIGHT<DAY Or NIGHT=12 Then Edit
ELSE
structure: qualify a condition
If condition Then statement1 Else statement2
ELSE is also understood when making decisions, as to what action should be taken, depending on conditions. So the last example could be changed to something like this:
E> If NIGHT+1=DAY Then Goto BED Else Shoot
The alternative choice of statements in this sort of structure must be a list of one or more AMOS Professional instructions. Also remember to include a separate GOTO command if you want to jump to a label or a numbered line, otherwise the label will be treated as a procedure name and it could possibly generate an error. For example:
X> If NIGHT=1 Then Goto BED: Rem This is perfect X> If NIGHT=1 Then BED: Rem This looks for a BED procedure
An IF ... THEN statement is limited to a single line, of a listing, which is not very satisfactory to an AMOS Professional programmer. This technique has been superseded by a "structured test", where IF is used to trigger off a whole range of instructions, depending on the outcome of a single decision.
Structured tests
END IF
structure: terminate a structured test
If structured test End If
In a structured test, each test is set up with an IF and ended with a matching END IF, but under no circumstances can a THEN be used anywhere inside such a test! The statements in a structured test are separated by colons on any particular line, as usual, but can extend over any number of lines in your listing, as required. Look at this old fashioned schematic line:
X> If condition=true Then Goto Label1 Else Label2
This may now be replaced by the alternative structured test format:
X> If condition=true : Goto Label1 : Else Goto Label2 : End If