Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/ExprLong.3 @ 33

Last change on this file since 33 was 25, checked in by landauf, 16 years ago

added tcl to libs

File size: 3.7 KB
Line 
1'\"
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: ExprLong.3,v 1.15 2007/12/13 15:22:31 dgp Exp $
9'\"
10.so man.macros
11.TH Tcl_ExprLong 3 7.0 Tcl "Tcl Library Procedures"
12.BS
13.SH NAME
14Tcl_ExprLong, Tcl_ExprDouble, Tcl_ExprBoolean, Tcl_ExprString \- evaluate an expression
15.SH SYNOPSIS
16.nf
17\fB#include <tcl.h>\fR
18.sp
19int
20\fBTcl_ExprLong\fR(\fIinterp, expr, longPtr\fR)
21.sp
22int
23\fBTcl_ExprDouble\fR(\fIinterp, expr, doublePtr\fR)
24.sp
25int
26\fBTcl_ExprBoolean\fR(\fIinterp, expr, booleanPtr\fR)
27.sp
28int
29\fBTcl_ExprString\fR(\fIinterp, expr\fR)
30.SH ARGUMENTS
31.AS Tcl_Interp *booleanPtr out
32.AP Tcl_Interp *interp in
33Interpreter in whose context to evaluate \fIexpr\fR.
34.AP "const char" *expr in
35Expression to be evaluated. 
36.AP long *longPtr out
37Pointer to location in which to store the integer value of the
38expression.
39.AP int *doublePtr out
40Pointer to location in which to store the floating-point value of the
41expression.
42.AP int *booleanPtr out
43Pointer to location in which to store the 0/1 boolean value of the
44expression.
45.BE
46
47.SH DESCRIPTION
48.PP
49These four procedures all evaluate the expression
50given by the \fIexpr\fR argument
51and return the result in one of four different forms.
52The expression can have any of the forms accepted by the \fBexpr\fR command.
53Note that these procedures have been largely replaced by the
54object-based procedures \fBTcl_ExprLongObj\fR, \fBTcl_ExprDoubleObj\fR,
55\fBTcl_ExprBooleanObj\fR, and \fBTcl_ExprObj\fR.
56Those object-based procedures evaluate an expression held in a Tcl object
57instead of a string.
58The object argument can retain an internal representation
59that is more efficient to execute.
60.PP
61The \fIinterp\fR argument refers to an interpreter used to
62evaluate the expression (e.g. for variables and nested Tcl
63commands) and to return error information.
64.PP
65For all of these procedures the return value is a standard
66Tcl result: \fBTCL_OK\fR means the expression was successfully
67evaluated, and \fBTCL_ERROR\fR means that an error occurred while
68evaluating the expression.
69If \fBTCL_ERROR\fR is returned then
70the interpreter's result will hold a message describing the error.
71If an error occurs while executing a Tcl command embedded in
72the expression then that error will be returned.
73.PP
74If the expression is successfully evaluated, then its value is
75returned in one of four forms, depending on which procedure
76is invoked.
77\fBTcl_ExprLong\fR stores an integer value at \fI*longPtr\fR.
78If the expression's actual value is a floating-point number,
79then it is truncated to an integer.
80If the expression's actual value is a non-numeric string then
81an error is returned.
82.PP
83\fBTcl_ExprDouble\fR stores a floating-point value at \fI*doublePtr\fR.
84If the expression's actual value is an integer, it is converted to
85floating-point.
86If the expression's actual value is a non-numeric string then
87an error is returned.
88.PP
89\fBTcl_ExprBoolean\fR stores a 0/1 integer value at \fI*booleanPtr\fR.
90If the expression's actual value is an integer or floating-point
91number, then they store 0 at \fI*booleanPtr\fR if
92the value was zero and 1 otherwise.
93If the expression's actual value is a non-numeric string then
94it must be one of the values accepted by \fBTcl_GetBoolean\fR
95such as
96.QW yes
97or
98.QW no ,
99or else an error occurs.
100.PP
101\fBTcl_ExprString\fR returns the value of the expression as a
102string stored in the interpreter's result.
103
104.SH "SEE ALSO"
105Tcl_ExprLongObj, Tcl_ExprDoubleObj, Tcl_ExprBooleanObj, Tcl_ExprObj
106
107.SH KEYWORDS
108boolean, double, evaluate, expression, integer, object, string
Note: See TracBrowser for help on using the repository browser.