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> Basic Concepts<br />

assigned to corresponding variables in the read list. The numbers can be entered in the input data<br />

in integer or decimal form. For example, the numbers 5, 5.0, and 5.000 are equivalent.<br />

Data items read into or printed by a computer are treated in physical groupings called records. Examples<br />

of a record are a single line typed on a computer terminal, a record, or a line printed on a<br />

printer. Within a record, data items are considered to be separated into fields. A field is a contiguous<br />

string of symbols delimited at the beginning and the end by at least one blank. Numeric data<br />

fields may also be delimited by the beginning or the end of a record. Each numeric value occupies<br />

one data field.<br />

Successive read statements do not necessarily read new input records, because a <strong>SIMSCRIPT</strong> <strong>II.5</strong><br />

program can treat input data as a continuous stream of data fields. The precise location, then, of a<br />

number within a record is not considered. An example illustrates this "free-form" concept: Read<br />

X, Y, Z sets X to the value 3, Y to the value 2.1, and Z to the value 67.33 when each of the sets<br />

of input data records in table 1-1 is read.<br />

Table 1-1. Sample Data Records<br />

_______________________________________________________________________________<br />

Record Number Values<br />

(1) record 1 3.0 2.1 67.33<br />

(2) record 1 3.00<br />

record 2 2.1 67.33<br />

(3) record 1 3<br />

record 2 2.1<br />

record 3 67.33<br />

_______________________________________________________________________________<br />

1.4 Constants<br />

Program statements may use numbers directly, such as the "2" in add 2 to SUM, or the number<br />

"3.14" in add 3.14 to VOLUME. These numbers are called constants. When used, they refer to<br />

their literal values. They are not names of variables and do not represent other values.<br />

Constants may have the same range of numeric values as variables, and where appropriate, may be<br />

used interchangeably in all computations. Constants differ from variables in that their values cannot<br />

be changed. Add 5 to X is a legal use of the variable X and the constant 5. Add 5 to 4 is not<br />

a legal use of the constant 4 because it is giving a new value of 9 to the constant 4.<br />

Whole numbers and fractional numbers, signed or unsigned, are allowed as constants. When equivalent<br />

representations of a number exist, they have the same value; 2.5 and 002.500 both represent<br />

the same number. The statements add 1 to COUNTER and add 1.00 to COUNTER have the<br />

same effect.<br />

3

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

Saved successfully!

Ooh no, something went wrong!