You can set execution trap points in the standard FoD script by using the $set_state command to specify a processing state that will trigger execution of your script starting with the module named in the $set_state command. For more complex applications a $set_state command can trap up to four different states, and you can use the SWITCHFROM system variable to determine which state triggered processing of your script.

Once a $set_state command triggers your script, the system resets the trigger so that reaching any of the states identified in the $set_state command will no longer call your script. The $set_state command is an advanced command and should be used with care. It is often used to trap the call hang up state (entered as either 's:HANG_UP' or 's31') to perform any clean up that needs to be done for a call. This is especially useful in cases where a caller hangs up or a call is disconnected and you need to complete some end of call processing.

Important: When you trap a state, consider carefully before you continue to a state which skips the trapped state completely. This may have unforeseen results.  And if you trap HANG_UP as described above, make sure to return to HANG_UP at the end of your infobox sequence.

Take extra care when trapping states visited during a call transfer or linked call operation, such as LINK_INIT and LINK_FINISH. CopiaFacts assumes that this process will be done under the control of a single infobox, so if you exit to your own infobox sequence or sequences, the next box and error exit specified in the $type transfer infobox will be lost.  To avoid this problem:

always return to the state which you have trapped at the end of an infobox sequence

use the 'R' syntax for $next_box to restore the next box and error box on return to this state.