Programming Guide : Writing Scripts and Procedures : How Procedure Handles Work (ProcHandle Objects)
 
Share this page          
How Procedure Handles Work (ProcHandle Objects)
A procedure handle (ProcHandle object) represents a global or local procedure and the scope in which to execute it. ProcHandle objects have several uses, for example:
They let called frames call procedures declared locally in their calling frame.
They let field scripts declare local procedures that can be called from anywhere in the frame.
ProcHandle objects are useful to pass procedures to contexts in which the procedure is not otherwise visible. They are used similarly to function pointers in the C language.
For example, you could write a field script that defines its own local cleanup procedures. In its initialize block it could insert its handles into an array of cleanup procedure handles defined at the frame level. You can create local cleanup procedures for other field scripts as well. Later, at cleanup time, the frame can loop through the cleanup array and use the handle to call each procedure.