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 />

if STATUS.CODE = 1<br />

or DIRECTION = 2<br />

let STATUS = 0<br />

Defining constants in this symbolic way greatly eases the task of program modification, should<br />

some of these constant values have to be adjusted. Of course, variables could be assigned to these<br />

constant values with similar effect. However, it is possible for variables to be inadvertently modified<br />

with consequent effect on the meaning. In order to clearly distinguish constants defined in this<br />

manner from program variables, it is suggested that a unique name construction be reserved for<br />

those names that are to be substituted. The form used above, which does not detract from readability,<br />

is to prefix all such names with a period.<br />

Another potential use is in the redefinition of keywords in a program. For instance, the words procedure,<br />

execute, and finish may be preferred to the <strong>SIMSCRIPT</strong> <strong>II.5</strong> terms routine,<br />

call, and end. Preceding a program with the statements:<br />

define PROCEDURE to mean routine<br />

define EXECUTE to mean call<br />

define FINISH to mean end<br />

allows the program to be written with this redefined vocabulary and then be translated into<br />

<strong>SIMSCRIPT</strong> <strong>II.5</strong> vocabulary before compilation.<br />

The scope of the define to mean statement is similar to that of the normally statement. When<br />

used in a program preamble, it extends throughout an entire program unless overridden. When used<br />

in a routine, it holds (until overridden) for that routine only.<br />

Entire sequences of statements can be generated directly into a program by an extended form of the<br />

define to mean statement. The extended form allows more than one line of statements to be<br />

substituted for a particular word, and it offers greater possibilities for macro-instruction generation.<br />

The statement can be written in two ways:<br />

and<br />

substitute this line for word<br />

substitute these i lines for word<br />

In the first statement, the contents of the line following the statement are substituted for the word<br />

wherever it appears. In the second statement, the contents of the following i lines are substituted.<br />

As with the define to mean statement, totally blank cards and comments cannot be substituted.<br />

Define to mean and substitute statements can be used freely in a program with few restrictions.<br />

They can "call on" one another at different levels of substitution. The following statements<br />

show how a series of define to mean and substitute statements can be applied to a program<br />

statement and used to translate the words of the statement into legal <strong>SIMSCRIPT</strong> <strong>II.5</strong> code.<br />

82

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

Saved successfully!

Ooh no, something went wrong!