If you're restless to start programming and are the type of person who prefers to learn at the keyboard rather than from a book, this section is for you. It contains a terse overview of the features of ET. Peruse this section, glance quickly at the examples, and you'll be ready to start coding. You can use the rest of the article as a reference guide when you run into trouble.
On the other hand, if you are new to graphical interface programming, are a little unsteady with C, or just have a more deliberate and cautious attitude toward life, then you may prefer to lightly skim or even skip this section and focus instead on the tutorial-like text that follows.
The ET system consists of two things: the et2c
preprocessor and the
Among the support routines in Et_Init()
and Et_MainLoop()
for initializing the ET package and implement the event loop, respectively.
A third routine, Et_ReadStdin()
,
allows standard input
to be read and interpreted by the Tcl/Tk interpreter at run-time.
The Et_Interp
is a pointer to the Tcl/Tk interpreter used by ET.
Et_MainWindow
is the main window.
Et_Display
is the Display
pointer required
as the first argument to many Xlib routines.
ET also provides two global Tcl variables, cmd_name
and
cmd_dir
. These contain the name of the executable and the
directory where the executable is found.
The et2c preprocessor is used to convert an ET source
file into real C code.
It creates the illusion of giving the C language some new statements,
like ET_INSTALL_COMMANDS
and ET_PROC
and
some special new functions like ET()
.
The ET()
function is used as if it were
a regular C function, except that its argument is a
Tcl/Tk script.
The job of the ET()
is to execute the script.
ET()
returns either ET_OK
or ET_ERROR
depending upon whether the script suceeded or failed.
Similar routines ET_STR()
, ET_INT()
, and
ET_DBL()
also take a Tcl/Tk script
as their argument, but return the string, the integer,
or the double-precision floating point number
that was the result of the last Tcl/Tk command in the argument script.
Wherever the string %d(x)
occurs inside an
ET()
function, the integer C expression x
is converted to ASCII and substituted in place of the
%d(x)
.
Similarly, %s(x)
can be used to substitute
a character string, and %f(x)
substitutes
a floating point value.
The string %q(x)
works like %s(x)
except
that a backslash is inserted before each character
that has special meaning to Tcl/Tk.
The special construct
ET_PROC( newcmd ){...}
defines a
C function that is invoked whenever the newcmd
Tcl/Tk command is executed.
Formal parameters to this function, argc
and argv
,
describe the arguments to the command.
The formal parameter interp
is a pointer to the
Tcl/Tk interpreter.
If a file named ET_PROC
macros, the commands associated with
those macros are registered with the Tcl/Tk interpreter by
invoking ET_INSTALL_COMMANDS(aux.c)
after
the Et_Init()
in the
main procedure.
The statement ET_INCLUDE( script.tcl )
causes the Tcl/Tk
script in the file script.tcl
to be made a part of the
C program and executed at the point where
the ET_INCLUDE()
macro is found.
The external Tcl/Tk script is normally read into the C program
at compile-time and thus becomes part of the executable.
However, if the -dynamic
command-line option is given to the
et2c preprocessor, loading of the external
Tcl/Tk script is deferred to run-time.
Finally, at the top of its output files,
the et2c preprocessor inserts
#define
s that
make ET_OK
and ET_ERROR
equivalent to
TCL_OK
and TCL_ERROR
. This often
eliminates the need
to put ``#include <tcl.h>
''
at the beginning of files that use ET.
And that's everything in ET! All the rest is just detail.