TclXInit(3tclx)
π TclXInit π
okay bestie, welcome to TclXInit(3tclx) β the page where we learn how to actually start up Extended Tcl and everything built on top of it. This is the "how do I boot my interpreter without crying" manual, section 3tclx, and yes it also spills the tea on integrating TclX into other apps. Grab a snack. π
β¨ NAME β¨
These are the glow-up functions that bring TclX to life β Extended Tcl initialization, periodt:
Tclx_InitTclxcmd_InitTclX_MainTkx_InitTkX_Main
π SYNOPSIS π
-ltclx -ltcl
#include "tclExtend.h"
int
Tclx_Init (Tcl_Interp *interp);
int
Tclxcmd_Init (Tcl_Interp *interp);
int
void
TclX_Main (int argc,
char **argv,
Tcl_AppInitProc *appInitProc);
int
Tkx_Init (Tcl_Interp *interp);
void
TkX_Main (int argc,
char **argv,
Tcl_AppInitProc *appInitProc);
void
TclX_SetAppInfo (int defaultValues,
char *appName,
char *appLongName,
char *appVersion,
int appPatchlevel);
π DESCRIPTION π
So like β these functions initialize Extended Tcl, and also apps that are based on Extended Tcl. And because we're being thorough girlies, this page also yaps about the various issues and approaches for integrating TclX into other applications. No cap. π
πΈ Tclx_Init πΈ
Initializes Extended Tcl β it adds the extended command set to the interpreter. You call this from Tcl_AppInit, and it must be called after the Tcl_Init function. Besides the standard command set, it enables use of tlib packages libraries and makes the standard TclX library available. Iconic behaviour honestly.
Parameters:
interpβ a pointer to the interpreter to add the commands to.
Returns:
TCL_OK if all is ok, TCL_ERROR if an error occurred.
π¦ Tclxcmd_Init π¦
Adds the TclX command set to the interpreter, with the exception of the TclX library management commands. This is normally called by Tclx_Init, so only use it if you don't want the TclX library handling. It's giving "I'll do it myself". π
Parameters:
interpβ a pointer to the interpreter to add the commands to.
Returns:
TCL_OK if all is ok, TCL_ERROR if an error occurred.
π₯ TclX_Main π₯
This function parses the command line according to the TclX shell specification (Unix shell compatible, bestie β¨). It creates an interpreter and calls the specified function appInitProc to initialize any application specific commands. Then it either evaluates the command of script specified on the command line, or enters an interactive command loop.
Heads up: this procedure never returns β it exits the process when it's done. Not coming back. Gone. Main character exit. π
Using the TclX shell also gives you SIGINT handling in interactive shells.
π Tkx_Init π
Initializes the Extended Tcl Tk environment. This is called from Tcl_AppInit after the Tk_Init function.
Parameters:
interpβ a pointer to the interpreter to add the commands to.
Returns:
TCL_OK if all is ok, TCL_ERROR if an error occurred.
π TkX_Main π
This function parses the command line according to the wish shell specification. It creates an interpreter and calls the specified function appInitProc to initialize any application specific commands. Then it either evaluates the command of script specified on the command line, or enters an interactive command loop.
Same deal, bestie: this procedure never returns β it exits the process when it's done. π
Using the TclX wish shell gives you SIGINT handling in interactive shells; otherwise it is identical to standard wish.
β TclX_SetAppInfo β
Stores the application information returned by infox.
Parameters:
defaultValuesβ if true, then the values are assigned only if they are not already defined (defaulted). If false, the values are always set.appNameβ application symbolic name.appLongNameβ long, natural language application name.appVersionβ version number of the application.appPatchlevelβ patch level of the application. If less than zero, don't change.
β οΈ String pointers are saved without copying, so do not release the memory. And if the arguments are NULL, don't change the values. Respect the pointers, they're fragile. π«Ά
π DYNAMIC LOADING OF TCLX π
TclX can be dynamically loaded on systems that support shared libraries and the load command. You can do this using either the load or the package require commands.
If package require is to be used, a pkgIndex,tcl must be constructed. The pkg_mkIndex does not generate a pkgIndex.tcl file that works with TclX. Instead, a command similar to
package ifneeded Tclx 7.5.0 "load $dir/libtclx.so"
should be placed in the directory containing the TclX shared library. A prototype pkgIndex,tcl file is build by TclX and is installed in the run time directory under the name pkgIndex,proto. This file can't be used as-is, but should be renamed and copied or combined with an existing pkgIndex,tcl in the directory containing the shared library.
There is no need to dynamically load libtkx.so, since it only contains support for wishx.
π§ INTEGRATING TCLX WITH OTHER EXTENSIONS AND APPLICATIONS π§
The main aspects to integrating TclX with into an application is to decide if the application is based on the standard Tcl/Tk shells or the TclX shells.
- If the standard shells are desired, then all that is necessary is to call
Tclx_InitafterTcl_InitandTkx_InitafterTk_Init. This functionality may also be dynamically loaded. β¨ - To get the TclX shell in a Tcl only application, with the
tclcommand functionality, callTclX_Mainfrom themainfunction instead ofTcl_Main. This shell has arguments conforming to other Unix shells andSIGINTsignal handling when interactive. π₯ - To get the Tclx shell in a Tk application, with the
wishxcommand functionality, callTkX_Mainfrom themainfunction instead ofTk_Main. This shell hasSIGINTsignal handling when interactive. π
and that's the whole page, bestie!! π this one came from the Tcl manual, page TclXInit(3tclx) β no date on it, so don't come for me about timestamps. go initialize something iconic. periodt. π
β¨π¦
π¦ where this page comes from
- debian bookworm: tclx8.4-doc 8.4.1-4
- debian trixie: tclx8.4-doc 8.4.1-5
- ubuntu jammy: tclx8.4-doc 8.4.1-4
- ubuntu noble: tclx8.4-doc 8.4.1-4
- ubuntu questing: tclx8.4-doc 8.4.1-5
- ubuntu resolute: tclx8.4-doc 8.4.1-6
- ubuntu stonking: tclx8.4-doc 8.4.1-6
- Copyright 1992-1999 Karl Lehenbauer and Mark Diekhans
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms