Dividing Scripts into Modules
Each module of a script usually performs a single function or task. You move between the modules of the script using the $next_box or $error_exit commands. You may also branch to various states within the CopiaFacts call processing cycle using these two commands. It is important to remember that $next_box commands do not take effect immediately. As the script lines in a module are processed, $next_box commands may occur many times within blocks of commands controlled by conditional statements such as $if. The last $next_box command actually executed in the module determines where the script branches when CopiaFacts finishes processing the module. Each line of the module is processed in order. An $error_exit branch is taken when a command such as $validate or $lookup_var fails or when a call transfer fails. The $error_exit command merely specifies what branch to take if an error does occur. It does not actually force such a branch to be taken when the command is encountered in the script. If no $error_exit is specified, the normal action is to fail the call, terminate the script, and hang up.
A stand-alone infobox, or a sequence of infoboxes, can also end in a $chain command instead of a $next_box command. The $chain command by default is equivalent to "$next_box s191", state 191 (IIF_PROC_COMPLETE), being the usual way to finish a pre- or post-process operation, or state 128 (KILL_MAINT_OP) if the infobox sequence was started from a $worker_box FS file. However when a $set_chain command has been used to set up a chain of infobox sequences, the $chain command will instead transfer control to the next element of the chain. The final end-point of a chain can also be modified by assignment to the CHAIN_END control variable, to override the transfer to state 191 or 128.