OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tcl/] [doc/] [AppInit.3] - Blame information for rev 1771

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
'\"
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.1.1.1 2002-01-16 10:25:23 markom Exp $
9
'\"
10
.so man.macros
11
.TH Tcl_AppInit 3 7.0 Tcl "Tcl Library Procedures"
12
.BS
13
.SH NAME
14
Tcl_AppInit \- perform application-specific initialization
15
.SH SYNOPSIS
16
.nf
17
\fB#include \fR
18
.sp
19
int
20
\fBTcl_AppInit\fR(\fIinterp\fR)
21
.SH ARGUMENTS
22
.AS Tcl_Interp *interp
23
.AP Tcl_Interp *interp in
24
Interpreter for the application.
25
.BE
26
 
27
.SH DESCRIPTION
28
.PP
29
\fBTcl_AppInit\fR is a ``hook'' procedure that is invoked by
30
the main programs for Tcl applications such as \fBtclsh\fR and \fBwish\fR.
31
Its purpose is to allow new Tcl applications to be created without
32
modifying the main programs provided as part of Tcl and Tk.
33
To create a new application you write a new version of
34
\fBTcl_AppInit\fR to replace the default version provided by Tcl,
35
then link your new \fBTcl_AppInit\fR with the Tcl library.
36
.PP
37
\fBTcl_AppInit\fR is invoked after by \fBTcl_Main\fR and \fBTk_Main\fR
38
after their own initialization and before entering the main loop
39
to process commands.
40
Here are some examples of things that \fBTcl_AppInit\fR might do:
41
.IP [1]
42
Call initialization procedures for various packages used by
43
the application.
44
Each initialization procedure adds new commands to \fIinterp\fR
45
for its package and performs other package-specific initialization.
46
.IP [2]
47
Process command-line arguments, which can be accessed from the
48
Tcl variables \fBargv\fR and \fBargv0\fR in \fIinterp\fR.
49
.IP [3]
50
Invoke a startup script to initialize the application.
51
.LP
52
\fBTcl_AppInit\fR returns TCL_OK or TCL_ERROR.
53
If it returns TCL_ERROR then it must leave an error message in
54
\fIinterp->result\fR;  otherwise the result is ignored.
55
.PP
56
In addition to \fBTcl_AppInit\fR, your application should also contain
57
a procedure \fBmain\fR that calls \fBTcl_Main\fR as follows:
58
.CS
59
Tcl_Main(argc, argv, Tcl_AppInit);
60
.CE
61
The third argument to \fBTcl_Main\fR gives the address of the
62
application-specific initialization procedure to invoke.
63
This means that you don't have to use the name \fBTcl_AppInit\fR
64
for the procedure, but in practice the name is nearly always
65
\fBTcl_AppInit\fR (in versions before Tcl 7.4 the name \fBTcl_AppInit\fR
66
was implicit;  there was no way to specify the procedure explicitly).
67
The best way to get started is to make a copy of the file
68
\fBtclAppInit.c\fR from the Tcl library or source directory.
69
It already contains a \fBmain\fR procedure and a template for
70
\fBTcl_AppInit\fR that you can modify for your application.
71
 
72
.SH KEYWORDS
73
application, argument, command, initialization, interpreter

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.