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.

1 2 3 4 5 6 7 8 9 10<br />

AGE 1<br />

DEPENDENTS 2<br />

SOC.SEC.NO. 3<br />

Figure 4-1. Storage of Attributes in a Two-dimensional Array<br />

The entity and attribute structuring permits an entity type, WORKER, to be defined by the statement:<br />

every WORKER has an AGE, a NUMBER.OF.DEPENDENTS<br />

and a SOCIAL.SECURITY.NUMBER<br />

A particular entity of this type may be specified by the value of an implicitly declared global variable<br />

called WORKER, associated with this entity type, and the attribute values associated with this<br />

particular instance of a WORKER may be accessed by references such as:<br />

and<br />

AGE(WORKER)<br />

SOCIAL.SECURITY.NUMBER(WORKER)<br />

Thus, the every statement may define a class of entities, each having similar properties. Every<br />

WORKER entity, of which there may be many, has the same attributes; the actual values of these attributes<br />

may differ for each.<br />

Entities and their attributes are declared in a program preamble by statements of the general form:<br />

every entity name has an attribute name list<br />

Entity and attribute names follow the same naming convention as variables and routines, and each<br />

variable, entity, attribute, and routine name must be unique. To assist in the creation of readable<br />

programs, the words a, the, and some can be used in place of an, as in:<br />

every WORKER has an AGE, some DEPENDENTS and a<br />

SOCIAL.SECURITY.NUMBER<br />

In general, these entity declarations implicitly state the ordering of the attributes within the entity<br />

structure. The data structure associated with each instance of a WORKER entity may be pictured as<br />

shown in figure 4-2.<br />

138

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

Saved successfully!

Ooh no, something went wrong!