18.10.2014 Views

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

every PERSON has a NAME, and an ADDRESS,<br />

owns some CHILDREN<br />

and may belong to the MASONS, a CHURCH, and a FAMILY<br />

every X has a P, a Q, a R and an A<br />

Set names should follow the same naming conventions as entities and attributes and must be unique.<br />

Recall the guidelines on variable naming given in Chapter 1. It may now be apparent why care<br />

should be taken in assigning names of the form letter-dot-name, as the declaration of set names implicitly<br />

defines a number of attribute names, made up from the set name by just this form of prefixing.<br />

An every statement defines a data structure. The next several paragraphs explain how these data<br />

structures are created and used, and the items within them are given further definition.<br />

4.4 Temporary Entities<br />

An every statement defines the structure of a class of entities. Entity classes can be temporary or<br />

permanent. This paragraph describes temporary entities. Paragraph 4.5 discusses permanent entities.<br />

When the statement:<br />

temporary entities<br />

appears before a collection of every statements in a preamble, it declares that all following entities<br />

are temporary. This means that storage is allocated to entities individually as they are created during<br />

the course of program execution. Individual entity records are provided for each temporary entity<br />

when a create statement is encountered. The form is:<br />

create entity name called variable<br />

A create statement allocates space in memory for the entity representation and assigns a pointer<br />

to this space to the indicated variable. Each entity is a unique and distinct individual that is identified<br />

by its pointer . As long as the variables into which these pointer values are placed are distinct,<br />

the identity of individual entities is preserved. For example:<br />

Entity definition in a preamble:<br />

temporary entities<br />

every SHIP has a NAME and a TONNAGE<br />

Create statements in a program:<br />

create SHIP called VESSEL<br />

create SHIP called V(I)<br />

These two create statements assign pointers to distinct copies of the SHIP entity structure to the<br />

variables VESSEL and V(I). Figure 4-8 provides an illustration.<br />

144

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

Saved successfully!

Ooh no, something went wrong!