<HTML><HEAD><TITLE>Tcl Library Procedures - Tcl_ExprLongObj manual page</TITLE></HEAD><BODY> <H3><A NAME="M2">NAME</A></H3> Tcl_ExprLongObj, Tcl_ExprDoubleObj, Tcl_ExprBooleanObj, Tcl_ExprObj - evaluate an expression <H3><A NAME="M3">SYNOPSIS</A></H3> <B>#include <tcl.h></B><BR> int<BR> <B>Tcl_ExprLongObj</B>(<I>interp, objPtr, longPtr</I>)<BR> int<BR> <B>Tcl_ExprDoubleObj</B>(<I>interp, objPtr, doublePtr</I>)<BR> int<BR> <B>Tcl_ExprBooleanObj</B>(<I>interp, objPtr, booleanPtr</I>)<BR> int<BR> <B>Tcl_ExprObj</B>(<I>interp, objPtr, resultPtrPtr</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>Tcl_Obj <B>*objPtr</B> (in)<DD> Pointer to an object containing the expression to evaluate. <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><DT>Tcl_Obj <B>*resultPtrPtr</B> (out)<DD> Pointer to location in which to store a pointer to the object that is the result of the expression. <P></DL> <H3><A NAME="M5">DESCRIPTION</A></H3> These four procedures all evaluate an expression, returning the result in one of four different forms. The expression is given by the <I>objPtr</I> argument, and it can have any of the forms accepted by the <B><A HREF="../TclCmd/expr.htm">expr</A></B> command. <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. <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 a message describing the error can be retrieved using <B><A HREF="../TclLib/SetResult.htm">Tcl_GetObjResult</A></B>. 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_ExprLongObj</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_ExprDoubleObj</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_ExprBooleanObj</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> If <B>Tcl_ExprObj</B> successfully evaluates the expression, it stores a pointer to the Tcl object containing the expression's value at <I>*resultPtrPtr</I>. In this case, the caller is responsible for calling <B><A HREF="../TclLib/Object.htm">Tcl_DecrRefCount</A></B> to decrement the object's reference count when it is finished with the object. <H3><A NAME="M6">SEE ALSO</A></H3> <B><A HREF="../TclLib/ExprLong.htm">Tcl_ExprLong</A></B>, <B><A HREF="../TclLib/ExprLong.htm">Tcl_ExprDouble</A></B>, <B><A HREF="../TclLib/ExprLong.htm">Tcl_ExprBoolean</A></B>, <B><A HREF="../TclLib/ExprLong.htm">Tcl_ExprString</A></B>, <B><A HREF="../TclLib/SetResult.htm">Tcl_GetObjResult</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> © 1996-1997 Sun Microsystems, Inc. <A HREF="../copyright.htm">Copyright</A> © 1995-1997 Roger E. Critchlow Jr.</PRE> </BODY></HTML>