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

The examples below illustrate how the buffer may be used for variable mode conversion.<br />

1. In this example, a text string containing numeric character fields is written to the<br />

buffer and then read in free form to assign values a list of integer variables.<br />

write as /, "11 12 13 14 15" using the buffer<br />

read V1,V2,V3,V4,V5 using the buffer<br />

Note that / clears the buffer and sets the current output column pointer to its first position.<br />

The buffer column pointer is arranged to be dynamically reset on read/write transitions. On<br />

the transition from a write to a read using the buffer, the column pointer is reset before<br />

the variables are read so the first free-form read starts at the beginning of the buffer. A similar<br />

transition from a read to a write using the buffer blanks the entire buffer and resets<br />

the column pointer.<br />

2. Alpha variables, ACODE(1), ACODE(2), ACODE(3), for example, might be written and<br />

then reread as a text variable as below:<br />

write ACODE(1), ACODE(2), ACODE(1), ACODE(3) as 4 A 1<br />

using the buffer<br />

read NEW.TEXT as T 4 using the buffer<br />

If ACODE(1)="C",<br />

assigned the text string "CACI".<br />

3.7 Writing Formatted Reports<br />

ACODE(2)="A", and ACODE(3)="I", then NEW.TEXT will be<br />

The print and write statements may be used to display messages and variable values as desired.<br />

Using these statements to produce lengthy reports, however, can involve much tedious programming.<br />

This section adds two phrases to the print statement and introduces two control statements<br />

that provide a report-generator capability.<br />

These features permit a programmer to specify the layout of printed results, to control the printing<br />

of headings and titles, to eject pages between various report sections, and to arrange "wide reports"<br />

on standard-width paper. Figure 3-1 below illustrates the kind of complex reports that can be generated.<br />

The statement begin report marks the start of a report section, within which various kinds of<br />

control can be exercised. A report section, like a routine, is terminated by an end statement. The<br />

statements:<br />

begin report<br />

for I = 1 to N,<br />

print 1 line with I, X(I) as follows<br />

** **.***<br />

end<br />

124

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

Saved successfully!

Ooh no, something went wrong!