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.

or<br />

if none<br />

These logical conditions obviously have no meaning outside the immediate context of a find statement.<br />

The following statements search a number of elements of array A for one that matches the<br />

value B, assigning a new element value if no match is found:<br />

for I = 1 to N<br />

with A(I) = B<br />

find the first case<br />

if none<br />

let N = N+1<br />

let A(N) = B<br />

always<br />

More than one for phrase can be used to control a find statement. Also more than one find variable<br />

may be assigned in one find statement. This is done by including a list of variable assignment<br />

phrases. The following example illustrates both features:<br />

for I = 1 to N,<br />

for J = 1 to M,<br />

with FN(I) less than FN(J)<br />

find FS(1) = the first I and FS(2) = the first J<br />

In cases where there is no expression to compute, a special form of the find statement can be used.<br />

The words the first case replace the variable assignment phrase. The search terminates, as<br />

before, with the first matching value. The terminating value of the for index variable is available<br />

for subsequent use. Both of the following statements terminate with the same value of I:<br />

for I = 1 to MAX,<br />

with V(I) less than QQ(I),<br />

find the first case<br />

for I = 1 to MAX,<br />

with V(I) less than QQ(I),<br />

find I = the first I<br />

3.3 A Statement for Computing Some Standard Functions of Variables<br />

Rather than selecting a single value satisfying some criterion, it may be desirable to summarize<br />

some statistics of a group of values. When these values are stored in arrays, or can be computed by<br />

some regular iteration, the compute statement facilitates compilation of descriptive statistics. An<br />

example of the use of a compute statement is:<br />

100

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

Saved successfully!

Ooh no, something went wrong!