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>Programming</strong> <strong>Language</strong> Concepts<br />

write X as /, "The Buffer Contains", I 3, " Characters"<br />

empties the buffer and inserts the characters "The Buffer Contains" in character positions 1<br />

through 19, the value of X in positions 20 through 22, and the characters "Characters" in positions<br />

23 through 33. Assuming a buffer length of 132, the buffer could be edited, for example, so that<br />

blank positions in the text, indicated here by underscores, are replaced by periods, by the statements:<br />

for I = 1 to 131,<br />

until out.f(I)="_" and out.f(I+1)="_"<br />

do<br />

if out.f(I) = "_"<br />

let out.f(I) = "."<br />

always<br />

loop<br />

Wcolumn.v points to the last character written into the buffer, so the loop condition could be written:<br />

for I = 1 to wcolumn.v,<br />

do<br />

If numbers representing dollar amounts are written, dollar signs ($) can be put before the first digit<br />

of each number in a similar way:<br />

for I = 1 to wcolumn.v,<br />

do<br />

if out.f(I) = "_" and out.f(I+1) ne "_"<br />

let out.f(I) = "$"<br />

always<br />

loop<br />

A special internal buffer called the buffer may be used for data editing using read and write<br />

statements. The length of this special buffer is specified by setting a system global variable,<br />

buffer.v, before its first use. If buffer.v is not set, it is assigned a default value of 132. Input<br />

or output operations are directed to use the buffer in the usual way:<br />

and<br />

use the buffer for input<br />

use the buffer for output<br />

or the statements:<br />

and<br />

write variable list as format list using the buffer<br />

read variable list as format list using the buffer<br />

123

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

Saved successfully!

Ooh no, something went wrong!