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.

Modelling Concepts<br />

destroy entity name called entity name<br />

4.5 Permanent Entities<br />

Permanent entities are defined in much the same way as temporary entities, but these declarations<br />

must be preceded by the statement:<br />

permanent entities<br />

Entities declared as permanent are stored collectively rather than in individually identifiable<br />

records. The entire group of permanent entities of a given class is created by a single statement.<br />

The attributes of the entities in the group are stored as indexed arrays. The attributes for a particular<br />

entity are accessed by effectively selecting a common index for all the associated attribute arrays.<br />

The number of entities in a particular entity group is maintained in an implicitly declared global<br />

variable called N.entity. The attribute arrays are allocated by a create statement of a different<br />

form than that used for temporary entities. Given the preamble declaration:<br />

permanent entities<br />

every HOME has an ADDRESS and an AREA<br />

the number of HOME entities to exist may be set by assigning a value to N.HOME by a read or let<br />

statement. The statement:<br />

create each HOME<br />

allocates arrays for all the attributes of the N.HOME entities of the class by executing the statement<br />

reserve ADDRESS and AREA as N.HOME. The words every and all can be used in place of<br />

each. Several permanent entities can be created together by naming a list of entity names, as in:<br />

create every HOME, HOTEL and RESTAURANT<br />

which is of the general form:<br />

create permanent entity name list<br />

As an alternative to assigning a value to N.entity before permanent entity creation, an arithmetic<br />

expression can be used in the create statement to indicate the size of the attribute arrays. For<br />

example, the following statements are equivalent:<br />

let N.HOME = 5<br />

create every HOME<br />

create every HOME(5)<br />

When the second form is used, N.entity is thereafter set to the value of the parenthesized expression.<br />

Permanent entities are not referred to by a pointer value, but by an index value that varies between<br />

1 and N.entity. Thus we speak of the attributes of each HOME as ADDRESS(1), ADDRESS(2),<br />

..., ADDRESS(5), AREA(1), AREA(2), ..., AREA(5). The layout of these attributes is<br />

shown in figure 4-9.<br />

147

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

Saved successfully!

Ooh no, something went wrong!