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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tcl/] [doc/] [Eval.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) 1989-1993 The Regents of the University of California.
3
'\" Copyright (c) 1994-1997 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: Eval.3,v 1.1.1.1 2002-01-16 10:25:23 markom Exp $
9
'\"
10
.so man.macros
11
.TH Tcl_Eval 3 7.0 Tcl "Tcl Library Procedures"
12
.BS
13
.SH NAME
14
Tcl_Eval, Tcl_VarEval, Tcl_EvalFile, Tcl_GlobalEval \- execute Tcl commands
15
.SH SYNOPSIS
16
.nf
17
\fB#include \fR
18
.sp
19
int
20
\fBTcl_Eval\fR(\fIinterp, cmd\fR)
21
.sp
22
int
23
\fBTcl_VarEval\fR(\fIinterp, string, string, ... \fB(char *) NULL\fR)
24
.sp
25
int
26
\fBTcl_EvalFile\fR(\fIinterp, fileName\fR)
27
.sp
28
int
29
\fBTcl_GlobalEval\fR(\fIinterp, cmd\fR)
30
.SH ARGUMENTS
31
.AS Tcl_Interp **termPtr;
32
.AP Tcl_Interp *interp in
33
Interpreter in which to execute the command.
34
A string result will be stored in \fIinterp->result\fR.
35
.AP char *cmd in
36
Command (or sequence of commands) to execute.  Must be in writable
37
memory (\fBTcl_Eval\fR makes temporary modifications to the command).
38
.AP char *string in
39
String forming part of Tcl command.
40
.AP char *fileName in
41
Name of file containing Tcl command string.
42
.BE
43
 
44
.SH DESCRIPTION
45
.PP
46
All four of these procedures execute Tcl commands.
47
\fBTcl_Eval\fR is the core procedure and is used by all the others.
48
It executes the commands in the script held by \fIcmd\fR
49
until either an error occurs or it reaches the end of the script.
50
.PP
51
Note that \fBTcl_Eval\fR and \fBTcl_GlobalEval\fR
52
have been largely replaced by the
53
object-based procedures \fBTcl_EvalObj\fR and \fBTcl_GlobalEvalObj\fR.
54
Those object-based procedures evaluate a script held in a Tcl object
55
instead of a string.
56
The object argument can retain the bytecode instructions for the script
57
and so avoid reparsing the script each time it is executed.
58
\fBTcl_Eval\fR is implemented using \fBTcl_EvalObj\fR
59
but is slower because it must reparse the script each time
60
since there is no object to retain the bytecode instructions.
61
.PP
62
The return value from \fBTcl_Eval\fR is one of the Tcl return codes
63
\fBTCL_OK\fR, \fBTCL_ERROR\fR, \fBTCL_RETURN\fR, \fBTCL_BREAK\fR, or
64
\fBTCL_CONTINUE\fR, and \fIinterp->result\fR will point to
65
a string with additional information (a result value or error message).
66
If an error occurs during compilation, this return information
67
describes the error.
68
Otherwise, this return information corresponds to the last command
69
executed from \fIcmd\fR.
70
.PP
71
\fBTcl_VarEval\fR takes any number of string arguments
72
of any length, concatenates them into a single string,
73
then calls \fBTcl_Eval\fR to execute that string as a Tcl command.
74
It returns the result of the command and also modifies
75
\fIinterp->result\fR in the usual fashion for Tcl commands.
76
The last argument to \fBTcl_VarEval\fR must be NULL to indicate the end
77
of arguments.
78
.PP
79
\fBTcl_EvalFile\fR reads the file given by \fIfileName\fR and evaluates
80
its contents as a Tcl command by calling \fBTcl_Eval\fR.  It returns
81
a standard Tcl result that reflects the result of evaluating the file.
82
If the file couldn't be read then a Tcl error is returned to describe
83
why the file couldn't be read.
84
.PP
85
During the processing of a Tcl command it is legal to make nested
86
calls to evaluate other commands (this is how procedures and
87
some control structures are implemented).
88
If a code other than \fBTCL_OK\fR is returned
89
from a nested \fBTcl_Eval\fR invocation,
90
then the caller should normally return immediately,
91
passing that same return code back to its caller,
92
and so on until the top-level application is reached.
93
A few commands, like \fBfor\fR, will check for certain
94
return codes, like \fBTCL_BREAK\fR and \fBTCL_CONTINUE\fR, and process them
95
specially without returning.
96
.PP
97
\fBTcl_Eval\fR keeps track of how many nested \fBTcl_Eval\fR
98
invocations are in progress for \fIinterp\fR.
99
If a code of \fBTCL_RETURN\fR, \fBTCL_BREAK\fR, or \fBTCL_CONTINUE\fR is
100
about to be returned from the topmost \fBTcl_Eval\fR
101
invocation for \fIinterp\fR,
102
it converts the return code to \fBTCL_ERROR\fR
103
and sets \fIinterp->result\fR
104
to point to an error message indicating that
105
the \fBreturn\fR, \fBbreak\fR, or \fBcontinue\fR command was
106
invoked in an inappropriate place.
107
This means that top-level applications should never see a return code
108
from \fBTcl_Eval\fR other then \fBTCL_OK\fR or \fBTCL_ERROR\fR.
109
 
110
.SH "SEE ALSO"
111
Tcl_EvalObj, Tcl_GlobalEvalObj
112
 
113
.SH KEYWORDS
114
command, execute, file, global, object, object result, variable

powered by: WebSVN 2.1.0

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