We already know that an ASSIGN creates an attribute (variable) associated with each entity or virtual entity, and that a SAVEVALUE is a global system value.
We have also seen that they are accessed through expressions such as P$name or X$name.
These expressions are called SNA, String/Numeric Accessors, and they are a fundamental language mechanism to dynamically access any value in the model.
P$name— Returns the content as text. Useful for traces, graphic labels, or string concatenation.V$name— Returns the raw value (string, number, object, or array), exactly as it was assigned.X$name— Returns the content of aSAVEVALUE(global value).
ASSIGN aVariable, {name:"Antonio", age:30}
CALL fun, V$(aVariable) ; sends the object itself
Additionally, there are specific SNAs to access system data:
AC1$— Current system time.TG1$— Number of entities pending execution.
And also resource properties:
R$(resource, property)— Returns the requested property value.R$(storage1, IN)— Entries into aSTORAGE.R$(facility3, ENTRIES)— Number of uses of aFACILITY.R$(market1, QUEUE)— Current queue length.
SNAs are not instructions; they are expressions.
They are evaluated anywhere a value is expected, which makes them an essential tool for decisions, message construction, calculations, or access to complex structures.
In the example, two very representative SNAs are used:
AC1$: the current system time.R$(VENTANILLA,QUEUE): current queue state of the resource.D$N: returns the identifier of the current virtual entity. In this case, it is stored in a variablenumberviaASSIGN, and later accessed usingP$number.
This shows how SNAs can be used both to obtain system data and to manipulate entity-specific variables, and how they integrate seamlessly with visual commands such as MOVE.
Finally, we have the SYS$ SNA, which contains basic system variables inside an object, such as date and time information:
ASSIGN sys, SYS$
MOVE {NAME:REALTIME1, TEXT:"P$(sys.date.year)/P$(sys.date.month)/P$(sys.date.day)"}
MOVE {NAME:REALTIME2, TEXT:"P$(sys.date.hour):P$(sys.date.min):P$(sys.date.sec)"}
Direct access to entity data:
The D$ SNA allows querying internal properties of any entity in the system.
Its general syntax is:
D$(property) ; current entity D$(property, entityNumber) ; specific entity
If the second parameter is omitted, D$N (the current entity) is assumed.
All these properties apply both to the current entity and to any other entity if its number is specified:
- N, ID — Entity identifier
- M0, M1 — Parameters M0 and M1
- BLOCK — Current block index
- STEP — Executed step number
- RESOURCETIME — Time inside the current FACILITY/STORAGE
- RESOURCENAME — Name of the occupied resource
- ADVANCESTART — Time when the current ADVANCE started
- ADVANCELAPSE — Remaining duration of the ADVANCE
- X, Y, Z — Visual coordinates
- T — Absolute creation time
- CX — Entity context
It is also possible to check for the existence of an entity using the same D$ SNA:
IF (D$(EXIST,1000)==1)
; entity 1000 is active
ENDIF
Example
/* SNA: System and Resource Attributes
A virtual entity monitors the queue state of a resource.
*/
SYSTEM {TYPE:ON_TIMER, TRIGGER:Timer1, INTERVAL: 5}
FACILITY {NAME:Ventanilla,X:470,Y:308}
GRAPHIC {NAME:Text1,Type:TEXT,X:471,Y:254}
GRAPHIC {NAME:Text2,Type:TEXT,X:471,Y:234}
START 100
GENERATE 10,0 {NAME:gen1,X:115,Y:307}
ADVANCE 20 {TO:Ventanilla}
SEIZE Ventanilla
ADVANCE 20
RELEASE Ventanilla
ENDGENERATE 1
; Display current queue status periodically
PROCEDURE Timer1
ASSIGN number, D$N
MOVE {NAME:Text1, TEXT:"I am virtual entity number: P$number"}
MOVE {NAME:Text2, TEXT:"T: AC1$ Entities in queue: R$(Ventanilla,QUEUE)"}
TERMINATE
ENDPROCEDURE 1