<HTML><HEAD><TITLE>Library Procedures - Tcl_GetInt manual page</TITLE></HEAD><BODY> <H3><A NAME="M2">NAME</A></H3> Tcl_GetInt, Tcl_GetDouble, Tcl_GetBoolean - convert from string to integer, double, or boolean <H3><A NAME="M3">SYNOPSIS</A></H3> <B>#include <tcl.h></B><BR> int<BR> <B>Tcl_GetInt</B>(<I>interp, string, intPtr</I>)<BR> int<BR> <B>Tcl_GetDouble</B>(<I>interp, string, doublePtr</I>)<BR> int<BR> <B>Tcl_GetBoolean</B>(<I>interp, string, boolPtr</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 to use for error reporting. <P><DT>char <B>*string</B> (in)<DD> Textual value to be converted. <P><DT>int <B>*intPtr</B> (out)<DD> Points to place to store integer value converted from <I>string</I>. <P><DT>double <B>*doublePtr</B> (out)<DD> Points to place to store double-precision floating-point value converted from <I>string</I>. <P><DT>int <B>*boolPtr</B> (out)<DD> Points to place to store boolean value (0 or 1) converted from <I>string</I>. <P></DL> <H3><A NAME="M5">DESCRIPTION</A></H3> These procedures convert from strings to integers or double-precision floating-point values or booleans (represented as 0- or 1-valued integers). Each of the procedures takes a <I>string</I> argument, converts it to an internal form of a particular type, and stores the converted value at the location indicated by the procedure's third argument. If all goes well, each of the procedures returns TCL_OK. If <I>string</I> doesn't have the proper syntax for the desired type then TCL_ERROR is returned, an error message is left in <I>interp->result</I>, and nothing is stored at *<I>intPtr</I> or *<I>doublePtr</I> or *<I>boolPtr</I>. <P> <B>Tcl_GetInt</B> expects <I>string</I> to consist of a collection of integer digits, optionally signed and optionally preceded by white space. If the first two characters of <I>string</I> are ``0x'' then <I>string</I> is expected to be in hexadecimal form; otherwise, if the first character of <I>string</I> is ``0'' then <I>string</I> is expected to be in octal form; otherwise, <I>string</I> is expected to be in decimal form. <P> <B>Tcl_GetDouble</B> expects <I>string</I> to consist of a floating-point number, which is: white space; a sign; a sequence of digits; a decimal point; a sequence of digits; the letter ``e''; and a signed decimal exponent. Any of the fields may be omitted, except that the digits either before or after the decimal point must be present and if the ``e'' is present then it must be followed by the exponent number. <P> <B>Tcl_GetBoolean</B> expects <I>string</I> to specify a boolean value. If <I>string</I> is any of <B>0</B>, <B>false</B>, <B>no</B>, or <B>off</B>, then <B>Tcl_GetBoolean</B> stores a zero value at <I>*boolPtr</I>. If <I>string</I> is any of <B>1</B>, <B>true</B>, <B>yes</B>, or <B>on</B>, then 1 is stored at <I>*boolPtr</I>. Any of these values may be abbreviated, and upper-case spellings are also acceptable. <H3><A NAME="M6">KEYWORDS</A></H3> <A href="../Keywords/B.htm#boolean">boolean</A>, <A href="../Keywords/C.htm#conversion">conversion</A>, <A href="../Keywords/D.htm#double">double</A>, <A href="../Keywords/F.htm#floating-point">floating-point</A>, <A href="../Keywords/I.htm#integer">integer</A> <HR><PRE> <A HREF="../copyright.htm">Copyright</A> © 1989-1993 The Regents of the University of California. <A HREF="../copyright.htm">Copyright</A> © 1994-1996 Sun Microsystems, Inc. <A HREF="../copyright.htm">Copyright</A> © 1995-1997 Roger E. Critchlow Jr.</PRE> </BODY></HTML>