An Introduction To Embedded Tk (page 11 of 32)

[Previous Page][Next Page][Table of Contents]

6.4 Summary Of Writing Tcl/Tk Commands In C

Before leaving this section, let's briefly summarize the steps needed to create new Tcl/Tk commands in C using ET. First you create one or more commands using the ET_PROC construct, as follows:

  ET_PROC( name-of-the-new-command ){
    /* C code to implement the command */
    return ET_OK;  /* Don't forget the return value! */
  }
Then, you register these commands with the Tcl interpreter using an ET_INSTALL_COMMANDS statement after the Et_Init() function call within main(). Like this:
  ET_INSTALL_COMMANDS( name-of-file-containing-ET_PROCs.c );
And that's all you have to do!

The ET_PROC construct lets you put a C routine in the middle of Tcl/Tk. The next section will take a closer look at ET() which allows you to put Tcl/Tk in the middle of a C routine.

[Next Page][Table of Contents]