1 |
578 |
markom |
'\"
|
2 |
|
|
'\" Copyright (c) 1994 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: Tcl_Main.3,v 1.1.1.1 2002-01-16 10:25:24 markom Exp $
|
9 |
|
|
'\"
|
10 |
|
|
.so man.macros
|
11 |
|
|
.TH Tcl_Main 3 7.4 Tcl "Tcl Library Procedures"
|
12 |
|
|
.BS
|
13 |
|
|
.SH NAME
|
14 |
|
|
Tcl_Main \- main program for Tcl-based applications
|
15 |
|
|
.SH SYNOPSIS
|
16 |
|
|
.nf
|
17 |
|
|
\fB#include \fR
|
18 |
|
|
.sp
|
19 |
|
|
\fBTcl_Main\fR(\fIargc, argv, appInitProc\fR)
|
20 |
|
|
.SH ARGUMENTS
|
21 |
|
|
.AS Tcl_AppInitProc *appInitProc
|
22 |
|
|
.AP int argc in
|
23 |
|
|
Number of elements in \fIargv\fR.
|
24 |
|
|
.AP char *argv[] in
|
25 |
|
|
Array of strings containing command-line arguments.
|
26 |
|
|
.AP Tcl_AppInitProc *appInitProc in
|
27 |
|
|
Address of an application-specific initialization procedure.
|
28 |
|
|
The value for this argument is usually \fBTcl_AppInit\fR.
|
29 |
|
|
.BE
|
30 |
|
|
|
31 |
|
|
.SH DESCRIPTION
|
32 |
|
|
.PP
|
33 |
|
|
\fBTcl_Main\fR acts as the main program for most Tcl-based applications.
|
34 |
|
|
Starting with Tcl 7.4 it is not called \fBmain\fR anymore because it
|
35 |
|
|
is part of the Tcl library and having a function \fBmain\fR
|
36 |
|
|
in a library (particularly a shared library) causes problems on many
|
37 |
|
|
systems.
|
38 |
|
|
Having \fBmain\fR in the Tcl library would also make it hard to use
|
39 |
|
|
Tcl in C++ programs, since C++ programs must have special C++
|
40 |
|
|
\fBmain\fR functions.
|
41 |
|
|
.PP
|
42 |
|
|
Normally each application contains a small \fBmain\fR function that does
|
43 |
|
|
nothing but invoke \fBTcl_Main\fR.
|
44 |
|
|
\fBTcl_Main\fR then does all the work of creating and running a
|
45 |
|
|
\fBtclsh\fR-like application.
|
46 |
|
|
.PP
|
47 |
|
|
When it is has finished its own initialization, but before
|
48 |
|
|
it processes commands, \fBTcl_Main\fR calls the procedure given by
|
49 |
|
|
the \fIappInitProc\fR argument. This procedure provides a ``hook''
|
50 |
|
|
for the application to perform its own initialization, such as defining
|
51 |
|
|
application-specific commands. The procedure must have an interface
|
52 |
|
|
that matches the type \fBTcl_AppInitProc\fR:
|
53 |
|
|
.CS
|
54 |
|
|
typedef int Tcl_AppInitProc(Tcl_Interp *\fIinterp\fR);
|
55 |
|
|
.CE
|
56 |
|
|
\fIAppInitProc\fR is almost always a pointer to \fBTcl_AppInit\fR;
|
57 |
|
|
for more details on this procedure, see the documentation
|
58 |
|
|
for \fBTcl_AppInit\fR.
|
59 |
|
|
|
60 |
|
|
.SH KEYWORDS
|
61 |
|
|
application-specific initialization, command-line arguments, main program
|