1Tcl_ExprLongObj(3)          Tcl Library Procedures          Tcl_ExprLongObj(3)
2
3
4
5______________________________________________________________________________
6

NAME

8       Tcl_ExprLongObj,  Tcl_ExprDoubleObj,  Tcl_ExprBooleanObj, Tcl_ExprObj -
9       evaluate an expression
10

SYNOPSIS

12       #include <tcl.h>
13
14       int
15       Tcl_ExprLongObj(interp, objPtr, longPtr)
16
17       int
18       Tcl_ExprDoubleObj(interp, objPtr, doublePtr)
19
20       int
21       Tcl_ExprBooleanObj(interp, objPtr, booleanPtr)
22
23       int
24       Tcl_ExprObj(interp, objPtr, resultPtrPtr)
25

ARGUMENTS

27       Tcl_Interp *interp (in)                 Interpreter in whose context to
28                                               evaluate objPtr.
29
30       Tcl_Obj *objPtr (in)                    Pointer  to  a value containing
31                                               the expression to evaluate.
32
33       long *longPtr (out)                     Pointer to location in which to
34                                               store  the integer value of the
35                                               expression.
36
37       int *doublePtr (out)                    Pointer to location in which to
38                                               store  the floating-point value
39                                               of the expression.
40
41       int *booleanPtr (out)                   Pointer to location in which to
42                                               store  the 0/1 boolean value of
43                                               the expression.
44
45       Tcl_Obj **resultPtrPtr (out)            Pointer to location in which to
46                                               store  a  pointer  to the value
47                                               that is the result of  the  ex‐
48                                               pression.
49______________________________________________________________________________
50
51

DESCRIPTION

53       These  four procedures all evaluate an expression, returning the result
54       in one of four different forms.  The expression is given by the  objPtr
55       argument,  and  it  can have any of the forms accepted by the expr com‐
56       mand.
57
58       The interp argument refers to an interpreter used to evaluate  the  ex‐
59       pression (e.g. for variables and nested Tcl commands) and to return er‐
60       ror information.
61
62       For all of these procedures the return value is a standard Tcl  result:
63       TCL_OK  means  the expression was successfully evaluated, and TCL_ERROR
64       means that an error  occurred  while  evaluating  the  expression.   If
65       TCL_ERROR  is  returned, then a message describing the error can be re‐
66       trieved using Tcl_GetObjResult.  If an error occurs while  executing  a
67       Tcl  command  embedded  in  the  expression then that error will be re‐
68       turned.
69
70       If the expression is successfully evaluated, then its value is returned
71       in one of four forms, depending on which procedure is invoked.  Tcl_Ex‐
72       prLongObj stores an integer value at *longPtr.  If the expression's ac‐
73       tual value is a floating-point number, then it is truncated to an inte‐
74       ger.  If the expression's actual value is a non-numeric string then  an
75       error is returned.
76
77       Tcl_ExprDoubleObj  stores a floating-point value at *doublePtr.  If the
78       expression's actual value is an integer, it is converted  to  floating-
79       point.   If  the expression's actual value is a non-numeric string then
80       an error is returned.
81
82       Tcl_ExprBooleanObj stores a 0/1 integer value at *booleanPtr.   If  the
83       expression's  actual value is an integer or floating-point number, then
84       they store 0 at *booleanPtr if the value was zero and 1 otherwise.   If
85       the  expression's  actual value is a non-numeric string then it must be
86       one of the values accepted by Tcl_GetBoolean such as “yes” or “no”,  or
87       else an error occurs.
88
89       If  Tcl_ExprObj  successfully  evaluates  the  expression,  it stores a
90       pointer to the Tcl value containing the expression's value at *resultP‐
91       trPtr.   In  this case, the caller is responsible for calling Tcl_Decr‐
92       RefCount to decrement the value's reference count when it  is  finished
93       with the value.
94
95

SEE ALSO

97       Tcl_ExprLong,    Tcl_ExprDouble,    Tcl_ExprBoolean,    Tcl_ExprString,
98       Tcl_GetObjResult
99
100

KEYWORDS

102       boolean, double, evaluate, expression, integer, value, string
103
104
105
106Tcl                                   8.0                   Tcl_ExprLongObj(3)
Impressum