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

let POPULATION(CITY,STATE) = 400000<br />

let POPULATION(NEW.YORK) = 8000000<br />

interpreted as:<br />

let POPULATION(NEW.YORK,STATE) = 8000000<br />

Note that because attributes are stored as arrays, and the use of the unsubscripted name in a freeform<br />

read implies input of the entire attribute array, when implied subscripts are used in free-form<br />

read statements to reference attributes of permanent entities, the entire attribute array is input.<br />

Although implicit subscripting may be convenient, the absence of subscripting renders it difficult<br />

to distinguish attributes from simple variables. Recalling that periods following a name are ignored<br />

by the <strong>SIMSCRIPT</strong> <strong>II.5</strong> compiler, a commonly-used notation is to append two periods to a name to<br />

indicate an implied subscript. This is purely a programming convention, used to distinguish attributes.<br />

It has no effect on the interpretation of the statements. It will be used in subsequent examples<br />

to make clear when implicit subscripting is being used.<br />

4-13 Displaying Attribute Values<br />

Specific attribute values can be output by conventional print and write statements. An attribute<br />

reference appearing in an output list calls for the retrieval and display of a single value, just as does<br />

a subscripted variable or function reference. Some examples of attributes used in print and<br />

write statements are:<br />

print 1 line with POPULATION(STATE) as follows<br />

POPULATION IS ********<br />

write I, INDEX(I), NAME(INDEX(I)) as /, 2 I 5, T *<br />

for each CARROT in BUNCH,<br />

write LENGTH(CARROT) as I 4<br />

Implied subscripts can be used in print and formatted write statements, as well as in computational<br />

statements. Attributes declared by the statement:<br />

permanent entities<br />

every BOOK has a PAGE.COUNT, a SUBJECT and an<br />

AUTHOR<br />

can be displayed by the statement:<br />

for every BOOK,<br />

write PAGE.COUNT.., SUBJECT.. and AUTHOR..<br />

as I 4, 2 T 12<br />

The list statement can be used to display all the attributes of an entity without writing all their<br />

names. Three forms are available:<br />

174

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

Saved successfully!

Ooh no, something went wrong!