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

3.5 Miscellaneous Input/Output Statements and Facilities<br />

3.5.1 Logical File Assignment: The OPEN Statement<br />

Physical device or data characteristics, specified by execution control commands to the operating<br />

system, are associated with <strong>SIMSCRIPT</strong> <strong>II.5</strong> logical unit numbers through a logical file name. As<br />

mentioned previously, this is usually constructed from the logical unit number to give a name of the<br />

form SIMUnn.<br />

To allow the specification of device or file characteristics within a program, the <strong>SIMSCRIPT</strong> <strong>II.5</strong><br />

language supports an open statement. The open statement provides a means of explicitly specifying<br />

a logical filename and some of the associated data characteristics at program level rather than<br />

at execution command level. Consult the <strong>SIMSCRIPT</strong> <strong>II.5</strong> user manual for specific details of the<br />

parameters.<br />

The general form of the statement is:<br />

open unit device for input (or output), data characteristics<br />

where device is an arithmetic expression evaluating to the logical unit number. The clause for<br />

input or for output designates whether the device is to be used as an input or output device. The<br />

word for is optional. The data characteristics may describe required characteristics of the data<br />

stream. An example of the use is:<br />

open unit 2 for output, file name is "OUTFILE"<br />

use 2 for output<br />

which will open a file, referred to in the future as unit 2, using the logical name "OUTFILE". This<br />

logical file name must be a text variable. If the file name is not specified, the default logical file<br />

name, simu02, is created as described above.<br />

Many file and I/O device data characteristics may be specified at program level in the open statement.<br />

Some of these are common across machines, while some are particular to one machine or<br />

language implementation. In general, however, the characteristics consist of logical filename assignment<br />

and file format and file-type description.<br />

File format parameters contain information on how the file is structured internally. The basic physical<br />

unit of the data file is the record, which usually corresponds to a line of input or output. File<br />

format parameters that may usually be specified are the recordsize, or length of each record, and<br />

whether this size is fixed or indicates the maximum of variable length records. For example:<br />

open unit 2 for output,<br />

file name is "OUTFILE", recordsize = 80, fixed<br />

assigns unit 2, in the output mode, to a file or device whose logical filename is "OUTFILE",<br />

which is composed of 80-character fixed length records.<br />

119

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

Saved successfully!

Ooh no, something went wrong!