User`s manual

44 digi.com Language
4.19 Function Chaining
Function chaining allows special segments of code to be distributed in one or more functions. When a
named function chain executes, all the segments belonging to that chain execute. Function chains allow the
software to perform initialization, data recovery, and other kinds of tasks on request. There are two direc-
tives, #makechain and #funcchain, and one keyword, segchain that create and control function
chains:
#makechain chain_name
Creates a function chain. When a program executes the named function chain, all of the func-
tions or chain segments belonging to that chain execute. (No particular order of execution can
be guaranteed.)
#funcchain chain_name name
Adds a function, or another function chain, to a function chain.
segchain chain_name { statements }
Defines a program segment (enclosed in curly braces) and attaches it to the named function
chain.
Function chain segments defined with segchain must appear in a function directly after data declara-
tions and before executable statements, as shown below.
A program will call a function chain as it would an ordinary void function that has no parameters. The fol-
lowing example shows how to call a function chain that is named recover.
my_function(){
/* data declarations */
segchain chain_x{
/* some statements which execute under chain_x */
}
segchain chain_y{
/* some statements which execute under chain_y */
}
/* function body which executes when my_function is called */
}
#makechain recover
...
recover();