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.

Discrete Simulation Concepts<br />

of events, before the event notice is destroyed, the values of the user-defined attributes are assigned,<br />

in order, to these local argument variables. Only as many attributes as have corresponding argument<br />

positions are copied. Specification of more arguments than there are user-defined attributes<br />

has no meaning, and is not permitted. Care must be taken in selecting these argument names.<br />

Should they be chosen as identical with the declared attribute names, then the local argument usage<br />

will always take precedence, rendering subsequent access to the entity attributes themselves impossible.<br />

This may be of significance in the process case, where the process notice must retain information<br />

across the sequence of events within the process activity. The above event routine definition<br />

could be written as:<br />

event ARRIVAL given ORIGIN<br />

where the now local argument ORIGIN will be initialized from the attribute value specified at the<br />

time of scheduling.<br />

Event notices that have not been destroyed may be reused, as in a case when the word this is required<br />

in the scheduling statement, avoiding the creation of a new event notice entity. Care should<br />

be taken, if this is done, that event notices be used only in appropriate event classes. It will become<br />

apparent that this is the mechanism by which processes may represent more than one of the events<br />

within an activity. The following examples demonstrate some of these points.<br />

1. Accessing the attributes of a saved event notice. The event notice entity is saved for filing<br />

in a user-defined set:<br />

event DEPARTURE(NAME, DESTINATION) saving the event notice<br />

let DEPARTURE.TIME(DEPARTURE) = time.v<br />

add 1 to PASSENGER.LIST(DESTINATION(DEPARTURE))<br />

file DEPARTURE in DEPARTURES.SET<br />

return<br />

end<br />

2. Event notice reused to schedule another similar event. A separate entity is created for program-defined<br />

manipulations:<br />

event ARRIVAL given NAME, ORIGIN saving the event notice<br />

define NAME, ORIGIN as text variables<br />

create a JOB<br />

let IDENTITY(JOB) = NAME<br />

let PLACE(JOB) = LOCATION<br />

file JOB in LIST.OF.JOBS<br />

reschedule this ARRIVAL("WALDO", "ALASKA") in 5 days<br />

return<br />

end<br />

3. A simple instantaneous process routine which behaves like an event. Note that the process<br />

notice is not destroyed until exit from the routine and so the attribute IDENT may be accessed<br />

from within the routine.<br />

199

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

Saved successfully!

Ooh no, something went wrong!