4 * Provides a default version of the Tcl_AppInit procedure for use in
5 * wish and similar Tk-based applications.
7 * Copyright (c) 1993 The Regents of the University of California.
8 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
10 * See the file "license.terms" for information on usage and redistribution of
11 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
18 extern int Tktest_Init
_ANSI_ARGS_((Tcl_Interp
*interp
));
22 *----------------------------------------------------------------------
26 * This is the main program for the application.
29 * None: Tk_Main never returns here, so this procedure never returns
33 * Whatever the application does.
35 *----------------------------------------------------------------------
40 int argc
, /* Number of command-line arguments. */
41 char **argv
) /* Values of command-line arguments. */
44 * The following #if block allows you to change the AppInit function by
45 * using a #define of TCL_LOCAL_APPINIT instead of rewriting this entire
46 * file. The #if checks for that #define and uses Tcl_AppInit if it
50 #ifndef TK_LOCAL_APPINIT
51 #define TK_LOCAL_APPINIT Tcl_AppInit
53 extern int TK_LOCAL_APPINIT
_ANSI_ARGS_((Tcl_Interp
*interp
));
56 * The following #if block allows you to change how Tcl finds the startup
57 * script, prime the library or encoding paths, fiddle with the argv,
58 * etc., without needing to rewrite Tk_Main()
61 #ifdef TK_LOCAL_MAIN_HOOK
62 extern int TK_LOCAL_MAIN_HOOK
_ANSI_ARGS_((int *argc
, char ***argv
));
63 TK_LOCAL_MAIN_HOOK(&argc
, &argv
);
66 Tk_Main(argc
, argv
, TK_LOCAL_APPINIT
);
67 return 0; /* Needed only to prevent compiler warning. */
71 *----------------------------------------------------------------------
75 * This procedure performs application-specific initialization. Most
76 * applications, especially those that incorporate additional packages,
77 * will have their own version of this procedure.
80 * Returns a standard Tcl completion code, and leaves an error message in
81 * the interp's result if an error occurs.
84 * Depends on the startup script.
86 *----------------------------------------------------------------------
91 Tcl_Interp
*interp
) /* Interpreter for application. */
93 if (Tcl_Init(interp
) == TCL_ERROR
) {
96 if (Tk_Init(interp
) == TCL_ERROR
) {
99 Tcl_StaticPackage(interp
, "Tk", Tk_Init
, Tk_SafeInit
);
101 if (Tktest_Init(interp
) == TCL_ERROR
) {
104 Tcl_StaticPackage(interp
, "Tktest", Tktest_Init
,
105 (Tcl_PackageInitProc
*) NULL
);
109 * Call the init procedures for included packages. Each call should look
112 * if (Mod_Init(interp) == TCL_ERROR) {
116 * where "Mod" is the name of the module.
120 * Call Tcl_CreateCommand for application-specific commands, if they
121 * weren't already created by the init procedures called above.
125 * Specify a user-specific startup file to invoke if the application is
126 * run interactively. Typically the startup file is "~/.apprc" where "app"
127 * is the name of the application. If this line is deleted then no user-
128 * -specific startup file will be run under any conditions.
131 Tcl_SetVar(interp
, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY
);