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

5. read X as D(8,2)<br />

Such a data item might be written as:<br />

column 0 1 ...<br />

number 12345678901234<br />

16.5E 2<br />

The written decimal point overrides the format. The scale factor multiplies the resulting<br />

number by 10**2 so that the value 1650 is assigned to X. The flexibility of the decimal<br />

format is shown in the following statement that defines a data record so that a large range<br />

of numbers can be accommodated:<br />

6. read X(1), X(2), X(3), X(4), X(5) as 5 D(10,2)<br />

A data record may appear as:<br />

column 0 1 2 3 4 5...<br />

number 12345678901234567890123456789012345678901234567890...<br />

41.25 19.22E-03 4537992 -167.1<br />

in which case X(1) = 41.25, X(2) = 0.01922, X(3) = 45379.92, X(4) =<br />

0.00, and X(5) = -167.1.<br />

7. write A,B,C,D,E as 2 I 4, D(10,3), E(9,1), I 6<br />

This statement defines output formats for five expressions, A to E. Assume that A and B<br />

are integer variables, both having the value 9, C is a real variable having the value<br />

19.2, D is a real variable with the current value 8.25, and E is an integer variable with<br />

the value -1863976. The output will be:<br />

column 0 1 2 3 4<br />

number 1234567890123456789012345678901234567890123456789<br />

9 9 19.200 8.3E+00-2E+06<br />

The output of E illustrates the action taken when a value is too large for its field. In this<br />

instance, a seven-digit integer could not be printed in a six-digit field, and was converted<br />

to a six-character scientific representation. The actual value -1.86397x10 6 was rounded<br />

to a value that could be printed (-2x10 6 ) and would retain the most significance.<br />

8. read NAMES(1), NAMES(2), NAMES(3) as 3 T 10<br />

Assuming that the array NAMES has been declared as text, the above statement will read<br />

three successive 10-character fields assigning 10-character text strings to the variables<br />

NAMES(1), NAMES(2), and NAMES(3). Thus:<br />

112

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

Saved successfully!

Ooh no, something went wrong!