Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/AppInit.3 @ 37

Last change on this file since 37 was 25, checked in by landauf, 16 years ago

added tcl to libs

File size: 2.8 KB
Line 
1'\"
2'\" Copyright (c) 1993 The Regents of the University of California.
3'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4'\"
5'\" See the file "license.terms" for information on usage and redistribution
6'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7'\"
8'\" RCS: @(#) $Id: AppInit.3,v 1.9 2007/12/13 15:22:30 dgp Exp $
9'\"
10.so man.macros
11.TH Tcl_AppInit 3 7.0 Tcl "Tcl Library Procedures"
12.BS
13.SH NAME
14Tcl_AppInit \- perform application-specific initialization
15.SH SYNOPSIS
16.nf
17\fB#include <tcl.h>\fR
18.sp
19int
20\fBTcl_AppInit\fR(\fIinterp\fR)
21.SH ARGUMENTS
22.AS Tcl_Interp *interp
23.AP Tcl_Interp *interp in
24Interpreter for the application.
25.BE
26
27.SH DESCRIPTION
28.PP
29\fBTcl_AppInit\fR is a
30.QW hook
31procedure that is invoked by
32the main programs for Tcl applications such as \fBtclsh\fR and \fBwish\fR.
33Its purpose is to allow new Tcl applications to be created without
34modifying the main programs provided as part of Tcl and Tk.
35To create a new application you write a new version of
36\fBTcl_AppInit\fR to replace the default version provided by Tcl,
37then link your new \fBTcl_AppInit\fR with the Tcl library.
38.PP
39\fBTcl_AppInit\fR is invoked by \fBTcl_Main\fR and \fBTk_Main\fR
40after their own initialization and before entering the main loop
41to process commands.
42Here are some examples of things that \fBTcl_AppInit\fR might do:
43.IP [1]
44Call initialization procedures for various packages used by
45the application.
46Each initialization procedure adds new commands to \fIinterp\fR
47for its package and performs other package-specific initialization.
48.IP [2]
49Process command-line arguments, which can be accessed from the
50Tcl variables \fBargv\fR and \fBargv0\fR in \fIinterp\fR.
51.IP [3]
52Invoke a startup script to initialize the application.
53.LP
54\fBTcl_AppInit\fR returns \fBTCL_OK\fR or \fBTCL_ERROR\fR.
55If it returns \fBTCL_ERROR\fR then it must leave an error message in
56for the interpreter's result;  otherwise the result is ignored.
57.PP
58In addition to \fBTcl_AppInit\fR, your application should also contain
59a procedure \fBmain\fR that calls \fBTcl_Main\fR as follows:
60.CS
61Tcl_Main(argc, argv, Tcl_AppInit);
62.CE
63The third argument to \fBTcl_Main\fR gives the address of the
64application-specific initialization procedure to invoke.
65This means that you do not have to use the name \fBTcl_AppInit\fR
66for the procedure, but in practice the name is nearly always
67\fBTcl_AppInit\fR (in versions before Tcl 7.4 the name \fBTcl_AppInit\fR
68was implicit;  there was no way to specify the procedure explicitly).
69The best way to get started is to make a copy of the file
70\fBtclAppInit.c\fR from the Tcl library or source directory.
71It already contains a \fBmain\fR procedure and a template for
72\fBTcl_AppInit\fR that you can modify for your application.
73
74.SH KEYWORDS
75application, argument, command, initialization, interpreter
Note: See TracBrowser for help on using the repository browser.