4 * Provides a default version of the Tcl_AppInit procedure for
5 * use in 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
11 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13 * RCS: @(#) $Id: tkAppInit.c,v 1.7 2002/06/21 20:24:29 dgp Exp $
20 extern int Tktest_Init
_ANSI_ARGS_((Tcl_Interp
*interp
));
24 *----------------------------------------------------------------------
28 * This is the main program for the application.
31 * None: Tk_Main never returns here, so this procedure never
35 * Whatever the application does.
37 *----------------------------------------------------------------------
42 int argc
; /* Number of command-line arguments. */
43 char **argv
; /* Values of command-line arguments. */
46 * The following #if block allows you to change the AppInit
47 * function by using a #define of TCL_LOCAL_APPINIT instead
48 * of rewriting this entire file. The #if checks for that
49 * #define and uses Tcl_AppInit if it doesn't exist.
52 #ifndef TK_LOCAL_APPINIT
53 #define TK_LOCAL_APPINIT Tcl_AppInit
55 extern int TK_LOCAL_APPINIT
_ANSI_ARGS_((Tcl_Interp
*interp
));
58 * The following #if block allows you to change how Tcl finds the startup
59 * script, prime the library or encoding paths, fiddle with the argv,
60 * etc., without needing to rewrite Tk_Main()
63 #ifdef TK_LOCAL_MAIN_HOOK
64 extern int TK_LOCAL_MAIN_HOOK
_ANSI_ARGS_((int *argc
, char ***argv
));
65 TK_LOCAL_MAIN_HOOK(&argc
, &argv
);
68 Tk_Main(argc
, argv
, TK_LOCAL_APPINIT
);
69 return 0; /* Needed only to prevent compiler warning. */
73 *----------------------------------------------------------------------
77 * This procedure performs application-specific initialization.
78 * Most applications, especially those that incorporate additional
79 * packages, will have their own version of this procedure.
82 * Returns a standard Tcl completion code, and leaves an error
83 * message in the interp's result if an error occurs.
86 * Depends on the startup script.
88 *----------------------------------------------------------------------
93 Tcl_Interp
*interp
; /* Interpreter for application. */
95 if (Tcl_Init(interp
) == TCL_ERROR
) {
98 if (Tk_Init(interp
) == TCL_ERROR
) {
101 Tcl_StaticPackage(interp
, "Tk", Tk_Init
, Tk_SafeInit
);
103 if (Tktest_Init(interp
) == TCL_ERROR
) {
106 Tcl_StaticPackage(interp
, "Tktest", Tktest_Init
,
107 (Tcl_PackageInitProc
*) NULL
);
112 * Call the init procedures for included packages. Each call should
115 * if (Mod_Init(interp) == TCL_ERROR) {
119 * where "Mod" is the name of the module.
123 * Call Tcl_CreateCommand for application-specific commands, if
124 * they weren't already created by the init procedures called above.
128 * Specify a user-specific startup file to invoke if the application
129 * is run interactively. Typically the startup file is "~/.apprc"
130 * where "app" is the name of the application. If this line is deleted
131 * then no user-specific startup file will be run under any conditions.
134 Tcl_SetVar(interp
, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY
);