SCAPE
It is a special call whose destination is a GENERATE.
SCAPE is used when an entity must completely abandon its current flow and start a new one. This is useful when a condition requires restarting, changing behavior, or irreversibly branching the flow.
The SCAPE jump leads to the only clean, stack-safe entry points: the GENERATE blocks. All ASSIGN values are preserved.
SCAPE generateName, 50, P$value, V$object
BACKPACK (LOAD / UNLOAD)
An entity can only be loaded (LOAD) if it is in REST, because it is asleep, does not consume simulation cycles, cannot wake itself up, and is safe to manipulate.
That is why BACKPACK is a logistics tool, not a flow-control mechanism.
In the example: A city and a museum are connected by a road. Citizens may travel by private vehicle or by bus. Buses load sleeping citizens, transport them, and unload them at a new GENERATE, where each continues its own life flow.
Example
POSITION {NAME:Exit, X:178, Y:39}
POSITION {NAME:RoadStart, X:150, Y:313}
POSITION {NAME:RoadEnd, X:514, Y:314}
Facility {NAME:Museum, capacity:50, X:534, Y:77 }
Restroom {NAME:CityBusStop, X:68, Y:321 }
Restroom {NAME:MuseumBusStop, X:588, Y:312 }
START 500
;----------------------------------------
GENERATE 15,0 {NAME:"GenUsers", X:100, Y:100 }
if (P$museumVisited==1)
advance 100,50 {from:RoadStart ,to:Exit}
terminate 1
endif
ASSIGN MODE,0 ; PRIVATE VEHICLE
if (RANDOM > 0.2)
ASSIGN MODE,1 ; BUS
endif
advance 10 {to:RoadStart}
if (P$MODE==1)
REST CityBusStop
endif
advance 50,10 {to:RoadEnd}
SCAPE GenMuseum
ENDGENERATE 1
;----------------------------------------
GENERATE 0,0,0,0 {NAME:"GenMuseum", X:600, Y:160 }
advance 20,30 {from:RoadEnd,to:Museum}
seize Museum
advance 30,50
assign museumVisited,1
mod {color:green}
release Museum
advance 10 {to:RoadEnd}
if (P$MODE==1)
REST MuseumBusStop
endif
advance 50 {to:RoadStart}
SCAPE GenUsers
ENDGENERATE 1
;----------------------------------------
;----------------------------------------
GENERATE 50,0,0,2 {NAME:"GenBuses", X:300, Y:460,ecolor:red,eradio:10,visible:0 }
advance 50 {to:RoadStart}
while (1==1)
load outboundBackpack, CityBusStop
mod {subtitle:"Passengers P$(outboundBackpack.LENGTH)"}
advance 80,10 {to:RoadEnd}
unload outboundBackpack, GenMuseum
advance 10
load returnBackpack, MuseumBusStop
mod {subtitle:"Passengers P$(returnBackpack.LENGTH)"}
advance 80,10 {to:RoadStart}
unload returnBackpack, GenUsers
advance 10
endwhile
ENDGENERATE 0