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

reserve MATRIX(*,*) as 5 by 7<br />

The dimensionality of an array, then, is frozen either by explicit declaration in a define statement,<br />

or when it is first referenced in an executable statement — which, of course, should be a reserve<br />

statement. Although the dimensionality of an array may be apparent from the context, the explicit<br />

declaration is recommended as an aid to program documentation. Once the array dimensionality<br />

has been frozen, the array must be referenced consistently. Any inconsistent reference is detected<br />

as an error during program compilation.<br />

Subscript size expressions may be arithmetic expressions containing variables, including other subscripted<br />

variables. If such expressions are real, they are rounded to integer before they are used<br />

as array dimension specifiers. Thus, the statement:<br />

reserve LIST(*) as N, TABLE (*,*) as N by 2*M<br />

allocates space for the arrays LIST and TABLE where the space requirement is dependent on the values<br />

of the variables N and M.<br />

A subscript size expression should not evaluate to zero or a negative value. An attempt to reserve<br />

space using a zero- or negative-valued size expression will cause a program to terminate with an<br />

error message. If any subscript expression in a reserve statement evaluates to 1, there is only one<br />

element allocated to that dimension of the array. The statement:<br />

reserve X(*) as 1, Y(*,*) as 1 by 3<br />

allocates space to an array X with one element, X(1), and a two-dimensional array Y with three elements,<br />

Y(1,1), Y(1,2), and Y(1,3). For all practical purposes, these one- and two-dimensional<br />

arrays are equivalent to the unsubscripted variable X and a one-dimensional array Y.<br />

When two or more arrays are to be allocated with the same dimensions, they may be combined in<br />

a list of array names. Thus, the following is acceptable:<br />

reserve A (*,*), B(*,*), C(*,*) as 5 by 10<br />

Any reserve statement can contain a sublist of this form among its list of arrays, as in:<br />

reserve VECTOR(*) as 5,<br />

A(*), B(*) and C(*) as 15,<br />

LIST1(*) and LIST2(*) as N+M,<br />

TABLE(*,*) as 3 by Y,<br />

.<br />

.<br />

48

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

Saved successfully!

Ooh no, something went wrong!