Transfer control to the next step in a chain
$chain
This command is used in place of a $next_box command to transfer control to an infobox sequence (or 'chain') previously established by means of a $set_chain command. If no infobox chain has been set up, or if the end of the chain has been reached, control transfers to the end-of-chain location, which defaults to state IIF_PROC_COMPLETE (state 191), or state 128 (KILL_MAINT_OP) if the infobox sequence was started from a $worker_box FS file. This final destination can be overridden by an assignment to the system variable CHAIN_END.
Before using this command you will have used $set_chain to define a series of standalone infoboxes, each standalone infobox or sequence ending with a $chain command. Then these sequences can be executed one after the other after as a 'chain'. See the $set_chain command description for information about setting up a chain.
The chain command is also used to initiate the processing of a newly-established chain and will cause control to be transferred to the first item in the chain when the processing of the current infobox script is finished.
![]() | As with $next_box, if you have a programming background, it is tempting to assume that $chain is equivalent to GOTO. It is not. The following commands in the infobox will still be executed. |
![]() | As the command is processed, the first destination in the chain is removed from the chain. |
This command has no parameters.
Position Requirement: To avoid accidental duplication, it is recommended that this command should written as the last command to be executed in the .IIF file.
Examples:
Set up several pre-process infoboxes. Each box could be processed individually, without a chain having been established, and would at the end transfer to state 191 (IIF_PROC_COMPLETE):
;ActionA.iif
$type decision
.... processing for action A
$chain
;ActionB.iif
$type decision
.... processing for action B
$chain
;ActionC.iif
$type decision
.... processing for action C
$chain
;ActionD.iif
$type decision
.... processing for action D
$chain
Define a main pre-process infobox which processes actions A, C and D in turn:
;PREPROC.IIF
$type decision
$set_chain ActionA,ActionC,ActionD
$chain
The above preprocess will run the selected three actions in turn, and at the end transfer to state 191.
This command is an alternative to $next_box and is overridden if a $next_box is executed following it in the same infobox. In the following example, the chain will never be selected, because the current infobox is processed in its entirety before the next box is selected, and the second command will always override the first:
$if @response = 1 ; !incorrect example
$chain ; ineffective
$endif
$next_box 9 ; always selected
The correct way to code the above example is:
$if @response = 1
$chain
$else
$next_box 9
$endif
Note that skipping the chain command in this way does not affect the established chain, which will be re-activated when a $chain command is eventually reached.