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

In case 1 above, the indicated item is filed at the head (tail) of the set. In 2, the position of filing is<br />

specified relative to some entity already in the set. The actions that take place when a file first<br />

statement is executed are illustrated by two examples. The examples use a set whose owner and<br />

member entities are both temporary, but they can as well be both permanent, or one permanent and<br />

one temporary. The set and the entities are defined by the statements:<br />

temporary entities<br />

every FARM owns a KENNEL<br />

every DOG has a LICENSE<br />

and belongs to some KENNEL<br />

The two illustrations are included in the program segment shown below. We first consider the situation<br />

before and after the first dog is filed in a kennel. Later we examine a subsequent situation.<br />

Assume a FARM has been created whose identifying value is stored in the global variable FARM.<br />

This could have been done by the statement create a FARM.<br />

Program segment:<br />

read NUMBER.OF.DOGS<br />

for I = 1 to NUMBER.OF.DOGS<br />

do<br />

create a DOG<br />

read LICENSE(DOG)<br />

file DOG first in KENNEL(FARM)<br />

loop<br />

The entity FARM is shown in figure 4-13a. After the first dog is created, its entity will appear as in<br />

figure 4-13b.<br />

A: B:<br />

FARM<br />

F.KENNEL<br />

L.KENNEL<br />

N.KENNEL<br />

DOG<br />

LICENSE<br />

P.KENNEL<br />

S.KENNEL<br />

M.KENNEL<br />

Figure 4-13. Entity Structures for FARM and DOG<br />

At this point the variables F.KENNEL, L.KENNEL, N.KENNEL, P.KENNEL, S.KENNEL, and<br />

M.KENNEL are all zero, indicating that KENNEL(FARM) is empty and DOG is not in some KENNEL.<br />

A M.KENNEL is equal to 0.<br />

After the file statement is executed, the entity records are as shown in figure 4-14. The owner<br />

entity FARM points to the member entity DOG, which, being the only entity in KENNEL(FARM), is<br />

154

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

Saved successfully!

Ooh no, something went wrong!