VE Procedures: TIMER, TIMEOUT, ON_*, PRE_RUN

Updated: 2026-01-26

TIMEOUT / ON_* / PRE_RUN / TIMER

These procedures are executed by newly created virtual entities (VE).
VEs must terminate like any other entity using TERMINATE or TERMINATE_VE. The difference between both BLOCKS is that the former terminates any entity, while the latter only terminates virtual entities. By using the TERMINATE_VE block, the PROCEDURE can be invoked to be executed by both types of entities.
It is important to note that they must be terminated explicitly, because if execution reaches ENDPROCEDURE the system would not know where to return.

TIMEOUT abrirRecurso, 50, P$valor, V$Objeto

PROCEDURE abrirRecurso
  move {name:text1, text:"Executed at t=AC1$"}
  TERMINATE_VE
ENDPROCEDURE

Example

POSITION {NAME:Salida, X:624, Y:199}

Graphic {NAME:T1, type:TEXT, X:493, Y:505}
Graphic {NAME:T2, type:TEXT, X:493, Y:476}
Graphic {NAME:T3, type:TEXT, X:492, Y:444}

Facility {NAME:Ventana, ON_RELEASE: cuandoSale, X:249, Y:335 }

SYSTEM {TYPE:PRE_RUN, TRIGGER:PRE_RUN}

START 50

;----------------------------------------
PROCEDURE PRE_RUN
    move {name:T1, text:"PRE_RUN executed at t = AC1$"}
    TIMEOUT avisoInicial, 10
    TERMINATE_VE
ENDPROCEDURE

;----------------------------------------
GENERATE 15,0 {NAME:"GEN1", X:100, Y:100}
	ADVANCE 10 {to:Ventana}
    SEIZE Ventana
    ADVANCE 5
    RELEASE Ventana        ; will trigger ON_RELEASE
    ADVANCE 10 {to:Salida}
ENDGENERATE 1

;----------------------------------------
PROCEDURE avisoInicial
    move {name:T2, text:"TIMEOUT executed at t = AC1$"}
    TERMINATE_VE
ENDPROCEDURE

PROCEDURE cuandoSale
    move {name:T3, text:"ON_RELEASE executed at t = AC1$"}
    TERMINATE_VE
ENDPROCEDURE