18.10.2014 Views

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>SIMSCRIPT</strong> <strong>II.5</strong> <strong>Programming</strong> <strong>Language</strong><br />

means add the current value of X to the current value of Y, giving Y a new value.<br />

A variable identifying name is any combination of letters, digits, and periods that contains at least<br />

one letter, so that it may be distinguished from a number. For example, X, COST,<br />

ACCOUNTS.RECEIVABLE, SIZE, MAN3, PART1, 5Y, and 1A are all legal names, whereas 27,<br />

1, and 4.6 are not. A slight restriction on variable naming is that any periods appearing as the last<br />

characters of a name are completely ignored. Upper and lower case distinctions are also ignored.<br />

Thus, Myvar, MyVar, and MYVAR all refer to the same quantity. It will be shown later in this<br />

manual how this rule may be used as a notational aid.<br />

Hereafter, whenever a variable name is used in a statement, it is understood to refer to the value of<br />

the variable identified by that name, not to the name itself. The values given to numeric variables<br />

may be whole numbers (integers) or numbers with a fractional part (decimal numbers). Thus, the<br />

value associated with a variable named X may at various times be 0 or 125 or 16.72 or -0.00001,<br />

or whatever number has most recently been assigned to X. The range in magnitude of numbers that<br />

can be internally represented in a computer and the accuracy with which numbers can be represented<br />

are, of course, subject to limits. These limits depend on the particular machine but, for the<br />

present, may be taken to be sufficiently generous not to be the subject of concern.<br />

At the start of program execution, the value of each numeric variable is set equal to zero. These<br />

variables are said to be "initialized to zero."<br />

1.3 Reading Input Data<br />

One way in which specific numeric values can be assigned to program variables is by reading numbers<br />

as input data. An example of the read statement is:<br />

read X, Y and QUANTITY<br />

X, Y, and QUANTITY are variable names. They are used in this statement in a variable name list.<br />

In general, a <strong>SIMSCRIPT</strong> <strong>II.5</strong> list consists of a string of quantities separated by either a comma, or<br />

the word and, or a comma followed by the word and. Some examples of variable name lists as they<br />

might appear in read statements are:<br />

read PRICE, QUANTITY, DISCOUNT<br />

read PLACE and DISTANCE<br />

read NAME, DATE, PLACE and TIME<br />

read NAME, and DATE, PLACE and TIME<br />

The general form of a read statement is:<br />

read variable name list<br />

When a <strong>SIMSCRIPT</strong> program executes a read statement, it reads as many fields from the input<br />

data as there are variable names listed in the statement. Successive numeric values are read and<br />

2

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

Saved successfully!

Ooh no, something went wrong!