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.

Advanced Topics<br />

Program 6-4.<br />

_______________________________________________________________________________<br />

preamble<br />

normally, mode is integer<br />

define DATA as a real, 2-dimensional array<br />

monitored on the right and the left<br />

define M and N as variables<br />

end<br />

main<br />

read N and M''THE ARRAY BOUNDS<br />

reserve DATA(*) as N by M''RESERVE THE ARRAY<br />

until mode is alpha,<br />

read I,J,DATA(I,J)<br />

for I = 1 to N,<br />

for J = 1 to M<br />

do ''ASSIGN DEFAULT VALUES<br />

if DATA(I,J) eq 0<br />

if J greater than I<br />

let DATA(I,J) = 1<br />

else<br />

let DATA(I,J) = -1<br />

always<br />

always<br />

loop<br />

skip one field''THE ALPHA DELIMITER<br />

until mode is alpha<br />

do<br />

read I,J<br />

print 1 line with I,J,DATA(I,J) like this<br />

THE VALUE OF DATA(**,**) IS ****.**<br />

loop<br />

stop<br />

end<br />

function DATA(L,K)<br />

define VALUE as a real variable<br />

''THE FETCHING OF THE VALUE DATA(L,K) IS INHIBITED<br />

''UNTIL THE SUBSCRIPTS ARE VERIFIED<br />

if L less than 1<br />

or L greater than N<br />

or K less than 1<br />

or K greater than M<br />

print 1 line with L,K thus<br />

INVALID SUBSCRIPTS *** AND ***<br />

stop<br />

otherwise<br />

move to VALUE''THE VALUE OF DATA(L,K) IS FETCHED<br />

return with VALUE<br />

end<br />

285

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

Saved successfully!

Ooh no, something went wrong!