Debian Codegraph @

doc/ExprLongObj.3

raw
1 '\"
2 '\" Copyright (c) 1996-1997 Sun Microsystems, Inc.
3 '\"
4 '\" See the file "license.terms" for information on usage and redistribution
5 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6 '\"
7 .TH Tcl_ExprLongObj 3 8.0 Tcl "Tcl Library Procedures"
8 .so man.macros
9 .BS
10 .SH NAME
11 Tcl_ExprLongObj, Tcl_ExprDoubleObj, Tcl_ExprBooleanObj, Tcl_ExprObj \- evaluate an expression
12 .SH SYNOPSIS
13 .nf
14 \fB#include <tcl.h>\fR
15 .sp
16 int
17 \fBTcl_ExprLongObj\fR(\fIinterp, objPtr, longPtr\fR)
18 .sp
19 int
20 \fBTcl_ExprDoubleObj\fR(\fIinterp, objPtr, doublePtr\fR)
21 .sp
22 int
23 \fBTcl_ExprBooleanObj\fR(\fIinterp, objPtr, booleanPtr\fR)
24 .sp
25 int
26 \fBTcl_ExprObj\fR(\fIinterp, objPtr, resultPtrPtr\fR)
27 .SH ARGUMENTS
28 .AS Tcl_Interp **resultPtrPtr out
29 .AP Tcl_Interp *interp in
30 Interpreter in whose context to evaluate \fIobjPtr\fR.
31 .AP Tcl_Obj *objPtr in
32 Pointer to a value containing the expression to evaluate.
33 .AP long *longPtr out
34 Pointer to location in which to store the integer value of the
35 expression.
36 .AP int *doublePtr out
37 Pointer to location in which to store the floating-point value of the
38 expression.
39 .AP int *booleanPtr out
40 Pointer to location in which to store the 0/1 boolean value of the
41 expression.
42 .AP Tcl_Obj **resultPtrPtr out
43 Pointer to location in which to store a pointer to the value
44 that is the result of the expression.
45 .BE
46
47 .SH DESCRIPTION
48 .PP
49 These four procedures all evaluate an expression, returning
50 the result in one of four different forms.
51 The expression is given by the \fIobjPtr\fR argument, and it
52 can have any of the forms accepted by the \fBexpr\fR command.
53 .PP
54 The \fIinterp\fR argument refers to an interpreter used to
55 evaluate the expression (e.g. for variables and nested Tcl
56 commands) and to return error information.
57 .PP
58 For all of these procedures the return value is a standard
59 Tcl result: \fBTCL_OK\fR means the expression was successfully
60 evaluated, and \fBTCL_ERROR\fR means that an error occurred while
61 evaluating the expression.
62 If \fBTCL_ERROR\fR is returned,
63 then a message describing the error
64 can be retrieved using \fBTcl_GetObjResult\fR.
65 If an error occurs while executing a Tcl command embedded in
66 the expression then that error will be returned.
67 .PP
68 If the expression is successfully evaluated, then its value is
69 returned in one of four forms, depending on which procedure
70 is invoked.
71 \fBTcl_ExprLongObj\fR stores an integer value at \fI*longPtr\fR.
72 If the expression's actual value is a floating-point number,
73 then it is truncated to an integer.
74 If the expression's actual value is a non-numeric string then
75 an error is returned.
76 .PP
77 \fBTcl_ExprDoubleObj\fR stores a floating-point value at \fI*doublePtr\fR.
78 If the expression's actual value is an integer, it is converted to
79 floating-point.
80 If the expression's actual value is a non-numeric string then
81 an error is returned.
82 .PP
83 \fBTcl_ExprBooleanObj\fR stores a 0/1 integer value at \fI*booleanPtr\fR.
84 If the expression's actual value is an integer or floating-point
85 number, then they store 0 at \fI*booleanPtr\fR if
86 the value was zero and 1 otherwise.
87 If the expression's actual value is a non-numeric string then
88 it must be one of the values accepted by \fBTcl_GetBoolean\fR
89 such as
90 .QW yes
91 or
92 .QW no ,
93 or else an error occurs.
94 .PP
95 If \fBTcl_ExprObj\fR successfully evaluates the expression,
96 it stores a pointer to the Tcl value
97 containing the expression's value at \fI*resultPtrPtr\fR.
98 In this case, the caller is responsible for calling
99 \fBTcl_DecrRefCount\fR to decrement the value's reference count
100 when it is finished with the value.
101
102 .SH "SEE ALSO"
103 Tcl_ExprLong, Tcl_ExprDouble, Tcl_ExprBoolean, Tcl_ExprString, Tcl_GetObjResult
104
105 .SH KEYWORDS
106 boolean, double, evaluate, expression, integer, value, string