Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bd5c3d824c3db63ffd9226c15941e6ad > files > 2055

mozart-1.4.0-1mdv2010.0.i586.rpm

<HTML><HEAD><TITLE>Tcl Library Procedures - Tcl_ExprLong manual page</TITLE></HEAD><BODY>
<H3><A NAME="M2">NAME</A></H3>
Tcl_ExprLong, Tcl_ExprDouble, Tcl_ExprBoolean, Tcl_ExprString - evaluate an expression
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>#include &lt;tcl.h&gt;</B><BR>
int<BR>
<B>Tcl_ExprLong</B>(<I>interp, string, longPtr</I>)<BR>
int<BR>
<B>Tcl_ExprDouble</B>(<I>interp, string, doublePtr</I>)<BR>
int<BR>
<B>Tcl_ExprBoolean</B>(<I>interp, string, booleanPtr</I>)<BR>
int<BR>
<B>Tcl_ExprString</B>(<I>interp, string</I>)<BR>
<H3><A NAME="M4">ARGUMENTS</A></H3>
<DL>
<P><DT><A HREF="../TclLib/Interp.htm">Tcl_Interp</A> <B>*interp</B> (in)<DD>
Interpreter in whose context to evaluate <I>string</I> or <I>objPtr</I>.
<P><DT>char <B>*string</B> (in)<DD>
Expression to be evaluated.  Must be in writable memory (the expression
parser makes temporary modifications to the string during parsing, which
it undoes before returning).
<P><DT>long <B>*longPtr</B> (out)<DD>
Pointer to location in which to store the integer value of the
expression.
<P><DT>int <B>*doublePtr</B> (out)<DD>
Pointer to location in which to store the floating-point value of the
expression.
<P><DT>int <B>*booleanPtr</B> (out)<DD>
Pointer to location in which to store the 0/1 boolean value of the
expression.
<P></DL>
<H3><A NAME="M5">DESCRIPTION</A></H3>
These four procedures all evaluate the expression
given by the <I>string</I> argument
and return the result in one of four different forms.
The expression can have any of the forms accepted by the <B><A HREF="../TclCmd/expr.htm">expr</A></B> command.
Note that these procedures have been largely replaced by the
object-based procedures <B><A HREF="../TclLib/ExprLongObj.htm">Tcl_ExprLongObj</A></B>, <B><A HREF="../TclLib/ExprLongObj.htm">Tcl_ExprDoubleObj</A></B>,
<B><A HREF="../TclLib/ExprLongObj.htm">Tcl_ExprBooleanObj</A></B>, and <B>Tcl_ExprStringObj</B>.
Those object-based procedures evaluate an expression held in a Tcl object
instead of a string.
The object argument can retain an internal representation
that is more efficient to execute.
<P>
The <I>interp</I> argument refers to an interpreter used to
evaluate the expression (e.g. for variables and nested Tcl
commands) and to return error information.
<I>interp-&gt;result</I> is assumed to be initialized
in the standard fashion when they are invoked.
<P>
For all of these procedures the return value is a standard
Tcl result: <B>TCL_OK</B> means the expression was successfully
evaluated, and <B>TCL_ERROR</B> means that an error occurred while
evaluating the expression.
If <B>TCL_ERROR</B> is returned then
<I>interp-&gt;result</I> will hold a message describing the error.
If an error occurs while executing a Tcl command embedded in
the expression then that error will be returned.
<P>
If the expression is successfully evaluated, then its value is
returned in one of four forms, depending on which procedure
is invoked.
<B>Tcl_ExprLong</B> stores an integer value at <I>*longPtr</I>.
If the expression's actual value is a floating-point number,
then it is truncated to an integer.
If the expression's actual value is a non-numeric string then
an error is returned.
<P>
<B>Tcl_ExprDouble</B> stores a floating-point value at <I>*doublePtr</I>.
If the expression's actual value is an integer, it is converted to
floating-point.
If the expression's actual value is a non-numeric string then
an error is returned.
<P>
<B>Tcl_ExprBoolean</B> stores a 0/1 integer value at <I>*booleanPtr</I>.
If the expression's actual value is an integer or floating-point
number, then they store 0 at <I>*booleanPtr</I> if
the value was zero and 1 otherwise.
If the expression's actual value is a non-numeric string then
it must be one of the values accepted by <B><A HREF="../TclLib/GetInt.htm">Tcl_GetBoolean</A></B>
such as ``yes'' or ``no'', or else an error occurs.
<P>
<B>Tcl_ExprString</B> returns the value of the expression as a
string stored in <I>interp-&gt;result</I>.
If the expression's actual value is an integer
then <B>Tcl_ExprString</B> converts it to a string using <B>sprintf</B>
with a ``%d'' converter.
If the expression's actual value is a floating-point
number, then <B>Tcl_ExprString</B> calls <B><A HREF="../TclLib/PrintDbl.htm">Tcl_PrintDouble</A></B>
to convert it to a string.

<H3><A NAME="M6">SEE ALSO</A></H3>
<B><A HREF="../TclLib/ExprLongObj.htm">Tcl_ExprLongObj</A></B>, <B><A HREF="../TclLib/ExprLongObj.htm">Tcl_ExprDoubleObj</A></B>, <B><A HREF="../TclLib/ExprLongObj.htm">Tcl_ExprBooleanObj</A></B>, <B><A HREF="../TclLib/ExprLongObj.htm">Tcl_ExprObj</A></B>
<H3><A NAME="M7">KEYWORDS</A></H3>
<A href="../Keywords/B.htm#boolean">boolean</A>, <A href="../Keywords/D.htm#double">double</A>, <A href="../Keywords/E.htm#evaluate">evaluate</A>, <A href="../Keywords/E.htm#expression">expression</A>, <A href="../Keywords/I.htm#integer">integer</A>, <A href="../Keywords/O.htm#object">object</A>, <A href="../Keywords/S.htm#string">string</A>
<HR><PRE>
<A HREF="../copyright.htm">Copyright</A> &#169; 1989-1993 The Regents of the University of California.
<A HREF="../copyright.htm">Copyright</A> &#169; 1994-1997 Sun Microsystems, Inc.
<A HREF="../copyright.htm">Copyright</A> &#169; 1995-1997 Roger E. Critchlow Jr.</PRE>
</BODY></HTML>