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_Init
  • Tclxcmd_Init
  • TclX_Main
  • Tkx_Init
  • TkX_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_Init after Tcl_Init and Tkx_Init after Tk_Init. This functionality may also be dynamically loaded. ✨
  • To get the TclX shell in a Tcl only application, with the tcl command functionality, call TclX_Main from the main function instead of Tcl_Main. This shell has arguments conforming to other Unix shells and SIGINT signal handling when interactive. πŸ”₯
  • To get the Tclx shell in a Tk application, with the wishx command functionality, call TkX_Main from the main function instead of Tk_Main. This shell has SIGINT signal 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