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

1. read IVAR and JVAR as I 5, /, I 5<br />

A value for IVAR is read from the first five columns following the present location of the<br />

current input pointer for the current input unit. A value for JVAR is read from columns 1-<br />

5 of the record following.<br />

2. read IVAR and JVAR as B 1, I 5, /, I 5<br />

The current input pointer is returned to the first column of the current record. If the pointer<br />

is greater than 1, a new record is not selected; instead, the pointer is moved back. Values<br />

for IVAR and JVAR are then read from the first five columns of this record and the one following.<br />

3. read IVAR, JVAR, KVAR, as 3 D(10,2), /<br />

The above statement establishes a "record-oriented" input format. Each group of 3 variable<br />

values is contained on a different record. After one group is read, a new record is read in<br />

preparation for the next group.<br />

4. write A,B,C,D,E,F as I 5, S 50, I 5, /,/,/,/, 4 D(10,4)<br />

This statement writes two integer variables spaced 50 columns apart in an integer format,<br />

concludes this record, bringing the current output pointer to the head of the output buffer,<br />

skips three records, and writes four decimal values on a second record.<br />

5. write N and AVERAGE as "Of", I 3, " To Date, The Average Is ",D(6,2)<br />

Two values embedded in character strings are written from the above statement. If writing<br />

occurs on a line printer and the current output pointer is at the beginning of a line, the output<br />

looks as follows for N=97 and AVERAGE = 53.287:<br />

Of 97 To Date, The Average Is 53.29<br />

6. read A(1),B(2),A(3),A(4),A(5) as B 5, I 10, D(7,3), /, B 20, 3 I 5<br />

This statement begins in column 5 of the current input unit, reads two values in integer and<br />

decimal formats, respectively, and then starts a new record and reads three integer values<br />

starting in column 20.<br />

7. write as *,/,/,/,/<br />

The statement starts a new output page and skips four lines. No output values are written.<br />

3.4.4 Controlled READ and WRITE Statements<br />

It is commonly required to read a number of subscripted variable values under the control of a for<br />

statement, as in:<br />

116

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

Saved successfully!

Ooh no, something went wrong!