18.10.2014 Views

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

define statements, depending on whether it is to apply as a background condition or to specifically<br />

named arrays. The phrase is written somewhat differently in each case.<br />

An n-dimensional array background condition may be declared with a normally statement using<br />

the phrase:<br />

dimension is n<br />

as in the statements:<br />

normally dimension is 1<br />

normally, mode is integer, dimension is 2<br />

In a define statement, a dimensionality specification can be made for a list of subscripted variables<br />

with the dimensionality phrase n-dimensional as in the statements:<br />

define LIST as an integer, 1-dimensional array<br />

define LIST and VECTOR as real, 1-dimensional arrays<br />

define CUBE as a 3-dimensional, integer array<br />

In general, if a majority of program variables share some definable property, this may be declared<br />

as a background condition, using a normally statement. Define statements may then be used to<br />

override this specification for specific variables, as in the example:<br />

preamble<br />

normally, mode is integer, dimension is 2<br />

define X, Y, Z and Q as real variables<br />

define VECTOR as a 1-dimensional array<br />

end<br />

A variable must not, however, be used in more than one define statement. It is permissible to<br />

write:<br />

normally, mode is real, dimension is 1<br />

define X as an integer, 0-dimensional variable<br />

It is not permissible to write:<br />

normally, mode is real, dimension is 1<br />

define X as an integer variable<br />

.<br />

.<br />

define X as a 0-dimensional variable<br />

Each unsubscripted (zero-dimensional) variable requires a location in computer memory in which<br />

to record its current value at any time. Similarly, each element of each array requires a distinct<br />

memory location where its value can be stored. A one-dimensional array with 10 elements uses 10<br />

such memory locations, a two-dimensional array with 3 rows and 5 columns uses (3*5) = 15 memory<br />

locations, and so forth.<br />

46

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

Saved successfully!

Ooh no, something went wrong!