We've seen how
the ET_PROC
constuct will create a new
Tcl/Tk command.
But that command must still be registered
with the Tcl interpreter before it can be used.
Fortunately, ET makes this very easy.
ET uses the ET_INSTALL_COMMANDS
keyword to register
ET_PROC
commands with the Tcl interpreter.
The et2c preprocessor converts the
ET_INSTALL_COMMANDS
keyword into a sequence of C
instructions that register every ET_PROC
in the current file.
In the main()
procedure of the
decimal clock example, the ET_INSTALL_COMMANDS
keyword that immediately follows the Et_Init()
function
is used to register the DecimalTime
command.
As it turns out, DecimalTime
is the only ET_PROC
function in the same source file, but even if there had be 100
others, they would have all been registered by that single
ET_INSTALL_COMMANDS
statement.
The ET_INSTALL_COMMANDS
keyword can also be used to
register ET_PROC
functions in separate source files,
simply by putting the name of the source file in
parentheses after the ET_INSTALL_COMMANDS
keyword.
Like this:
ET_INSTALL_COMMANDS( otherfile.c );A larger program will typically have many
ET_INSTALL_COMMANDS
statements immediately following the Et_Init()
function,
one statement for each file that contains ET_PROC
functions.
One recent commercial project used 33
ET_INSTALL_COMMANDS
statements following the
Et_Init()
function!