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

NAME

8       Tcl_ExprLong,  Tcl_ExprDouble, Tcl_ExprBoolean, Tcl_ExprString - evalu‐
9       ate an expression
10

SYNOPSIS

12       #include <tcl.h>
13
14       int
15       Tcl_ExprLong(interp, expr, longPtr)
16
17       int
18       Tcl_ExprDouble(interp, expr, doublePtr)
19
20       int
21       Tcl_ExprBoolean(interp, expr, booleanPtr)
22
23       int
24       Tcl_ExprString(interp, expr)
25

ARGUMENTS

27       Tcl_Interp *interp (in)              Interpreter in  whose  context  to
28                                            evaluate expr.
29
30       const char *expr (in)                Expression to be evaluated.
31
32       long *longPtr (out)                  Pointer  to  location  in which to
33                                            store the  integer  value  of  the
34                                            expression.
35
36       int *doublePtr (out)                 Pointer  to  location  in which to
37                                            store the floating-point value  of
38                                            the expression.
39
40       int *booleanPtr (out)                Pointer  to  location  in which to
41                                            store the 0/1 boolean value of the
42                                            expression.
43_________________________________________________________________
44
45

DESCRIPTION

47       These  four  procedures  all  evaluate the expression given by the expr
48       argument and return the result in one of  four  different  forms.   The
49       expression  can  have  any  of  the forms accepted by the expr command.
50       Note that these procedures have been largely replaced  by  the  object-
51       based    procedures   Tcl_ExprLongObj,   Tcl_ExprDoubleObj,   Tcl_Expr‐
52       BooleanObj, and Tcl_ExprObj.  Those object-based procedures evaluate an
53       expression  held in a Tcl object instead of a string.  The object argu‐
54       ment can retain an internal representation that is  more  efficient  to
55       execute.
56
57       The  interp  argument  refers  to  an  interpreter used to evaluate the
58       expression (e.g. for variables and nested Tcl commands) and  to  return
59       error information.
60
61       For  all of these procedures the return value is a standard Tcl result:
62       TCL_OK means the expression was successfully evaluated,  and  TCL_ERROR
63       means  that  an  error  occurred  while  evaluating the expression.  If
64       TCL_ERROR is returned then the interpreter's result will hold a message
65       describing the error.  If an error occurs while executing a Tcl command
66       embedded in the expression then that error will be returned.
67
68       If the expression is successfully evaluated, then its value is returned
69       in  one  of  four  forms,  depending  on  which  procedure  is invoked.
70       Tcl_ExprLong stores an integer value at *longPtr.  If the  expression's
71       actual  value  is  a  floating-point number, then it is truncated to an
72       integer.  If the expression's actual value is a non-numeric string then
73       an error is returned.
74
75       Tcl_ExprDouble  stores  a  floating-point  value at *doublePtr.  If the
76       expression's actual value is an integer, it is converted  to  floating-
77       point.   If  the expression's actual value is a non-numeric string then
78       an error is returned.
79
80       Tcl_ExprBoolean stores a 0/1 integer  value  at  *booleanPtr.   If  the
81       expression's  actual value is an integer or floating-point number, then
82       they store 0 at *booleanPtr if the value was zero and 1 otherwise.   If
83       the  expression's  actual value is a non-numeric string then it must be
84       one of the values accepted by Tcl_GetBoolean such as “yes” or “no”,  or
85       else an error occurs.
86
87       Tcl_ExprString  returns  the value of the expression as a string stored
88       in the interpreter's result.
89
90

SEE ALSO

92       Tcl_ExprLongObj, Tcl_ExprDoubleObj, Tcl_ExprBooleanObj, Tcl_ExprObj
93
94

KEYWORDS

96       boolean, double, evaluate, expression, integer, object, string
97
98
99
100Tcl                                   7.0                      Tcl_ExprLong(3)
Impressum