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> Basic Concepts<br />

The go to statement provides great flexibility in directing the flow of control. However, it can<br />

detract from the clarity of the logic and the readability of the program. Unwisely used, it can multiply<br />

the possible paths through the program, rendering comprehension and testing of the logic unnecessarily<br />

difficult. Structured programming principles suggest that the logic of a program should<br />

be expressed in restricted control flow structures. In particular, the concepts of conditional action<br />

and iteration should be represented using the if and do loop structures.<br />

1.18 The Logical End of a Program<br />

The stop statement is used to terminate a program. Because there may be more than one stop<br />

statement in a program, and control flow may be diverted around any stop statement, it does not<br />

always appear as the last statement of a program listing. The following program segment illustrates<br />

the use of the stop statement in conjunction with an if statement:<br />

if X is zero<br />

print 1 line as follows<br />

ZERO IS AN ILLEGAL VALUE FOR X<br />

stop<br />

otherwise<br />

let Z = Y/X<br />

Note: The stop statement is considered to be an unconditional transfer of control.<br />

1.19 The Physical End of a Program<br />

The last statement in every <strong>SIMSCRIPT</strong> <strong>II.5</strong> program must be end. It signals that the entire source<br />

program has been read. The example programs at the end of this chapter illustrate the use of the<br />

end statement.<br />

1.20 A Note on <strong>SIMSCRIPT</strong> <strong>II.5</strong> Program Form<br />

<strong>SIMSCRIPT</strong> <strong>II.5</strong> programs are composed of sequences of conventionally arranged symbols —<br />

some are standardized key words such as let and read and others are programmer-constructed<br />

variable names and numeric constants. The basic symbolic units recognized by the <strong>SIMSCRIPT</strong><br />

<strong>II.5</strong> compiler in scanning program statements are names and numbers, the special characters +, -, ',<br />

*, /, **, (, ), ", >,

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

Saved successfully!

Ooh no, something went wrong!