18.10.2014 Views

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>SIMSCRIPT</strong> <strong>II.5</strong> <strong>Programming</strong> <strong>Language</strong><br />

The failure of any test causes a transfer to one of the cascaded always statements, and hence a<br />

transfer out of the structure. Successive if statements add further logical tests to that of the first<br />

if statement. This structure may be simplified for readability by prefixing the word then to the<br />

second and subsequent if statements, and eliminating all but one of the consecutive always statements.<br />

The example shown above could be written as:<br />

if VALUE > 100.00<br />

let PRIORITY = 2<br />

then if TIME.DUE < 3<br />

add 1 to PRIORITY<br />

then if WORKTIME < 1<br />

add 1 to PRIORITY<br />

always<br />

Note that the then if construct is only applicable to nested logical tests in which the false condition<br />

for any of the tests is to have the same effect — a transfer of control out of the nest structure.<br />

While the use of then if may reduce the number of statements required, the programmer must<br />

judge whether such use obscures the logical intent of the structure.<br />

1.12 More on Logical Expressions<br />

The logical expressions described above have used relational operators to specify comparison between<br />

two arithmetic expressions, or between one such expression and defined properties such as<br />

zero or negative. This section elaborates on the structure of logical expressions.<br />

A logical expression may be negated by following it with the phrase is false, as in the expression:<br />

value < LIMIT is false<br />

The is false phrase may be used to improve readability by stating a desired condition without<br />

forcing an unnatural transposition of logic. For example, a test may be written as:<br />

or:<br />

if QUANTITY > INVENTORY<br />

let ORDER = ORDER - 1<br />

always<br />

if QUANTITY

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!