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.

Advanced Topics<br />

Program statements that employ optional attributes:<br />

let WHICH = 1 ‘’INDICATING THE FIRST OPTIONAL ATTRIBUTE<br />

let X = OPTIONAL(CITY)<br />

If an entity CITY has an entity filed in its OPTIONS set with a CODE value of 1, X is set to the<br />

VALUE of the entity. If an entity CITY has no such entity filed in OPTIONS, X is set to<br />

DEFAULT(1).<br />

The program can be made even more straightforward if functions are used to define the optional<br />

attributes themselves. If RAPID.TRANSIT is an optional attribute of CITY, it can be defined and<br />

used by the following statements:<br />

define RAPID.TRANSIT as an integer function<br />

routine RAPID.TRANSIT(CITY)<br />

define CITY as an integer variable<br />

let WHICH = 1<br />

return with OPTIONAL(CITY)<br />

end<br />

The diagram in figure 6-13 shows the record structures for a temporary entity of the type CITY that<br />

has several "normal attributes" and several "optional attributes."<br />

CITY 67 000 000<br />

F.OPTIONS 1 1 is the code for<br />

RAPID.TRANSIT<br />

L.OPTIONS<br />

P.OPTIONS<br />

N.OPTIONS<br />

S.OPTIONS<br />

NAME<br />

POPULATION 3 500 000<br />

STATE 4 4 is the code for<br />

EDUCATION.EXPENSE<br />

P.OPTIONS<br />

S.OPTIONS<br />

.<br />

DEFAULT .<br />

1 0 .<br />

2 0 257 532 000<br />

3 100 57 57 is the code for<br />

MUNICPAL.DEBT<br />

. . P.OPTIONS<br />

. . S.OPTIONS<br />

. .<br />

97 200<br />

98 10<br />

99 4510<br />

100 -1<br />

Figure 6-13. Record Structure<br />

277

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

Saved successfully!

Ooh no, something went wrong!