[25] | 1 | '\" |
---|
| 2 | '\" Copyright (c) 1989-1993 The Regents of the University of California. |
---|
| 3 | '\" Copyright (c) 1994-1996 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: GetInt.3,v 1.14 2007/12/13 15:22:31 dgp Exp $ |
---|
| 9 | '\" |
---|
| 10 | .so man.macros |
---|
| 11 | .TH Tcl_GetInt 3 "" Tcl "Tcl Library Procedures" |
---|
| 12 | .BS |
---|
| 13 | .SH NAME |
---|
| 14 | Tcl_GetInt, Tcl_GetDouble, Tcl_GetBoolean \- convert from string to integer, double, or boolean |
---|
| 15 | .SH SYNOPSIS |
---|
| 16 | .nf |
---|
| 17 | \fB#include <tcl.h>\fR |
---|
| 18 | .sp |
---|
| 19 | int |
---|
| 20 | \fBTcl_GetInt\fR(\fIinterp, src, intPtr\fR) |
---|
| 21 | .sp |
---|
| 22 | int |
---|
| 23 | \fBTcl_GetDouble\fR(\fIinterp, src, doublePtr\fR) |
---|
| 24 | .sp |
---|
| 25 | int |
---|
| 26 | \fBTcl_GetBoolean\fR(\fIinterp, src, boolPtr\fR) |
---|
| 27 | .SH ARGUMENTS |
---|
| 28 | .AS Tcl_Interp *doublePtr out |
---|
| 29 | .AP Tcl_Interp *interp in |
---|
| 30 | Interpreter to use for error reporting. |
---|
| 31 | .AP "const char" *src in |
---|
| 32 | Textual value to be converted. |
---|
| 33 | .AP int *intPtr out |
---|
| 34 | Points to place to store integer value converted from \fIsrc\fR. |
---|
| 35 | .AP double *doublePtr out |
---|
| 36 | Points to place to store double-precision floating-point |
---|
| 37 | value converted from \fIsrc\fR. |
---|
| 38 | .AP int *boolPtr out |
---|
| 39 | Points to place to store boolean value (0 or 1) converted from \fIsrc\fR. |
---|
| 40 | .BE |
---|
| 41 | |
---|
| 42 | .SH DESCRIPTION |
---|
| 43 | .PP |
---|
| 44 | These procedures convert from strings to integers or double-precision |
---|
| 45 | floating-point values or booleans (represented as 0- or 1-valued |
---|
| 46 | integers). Each of the procedures takes a \fIsrc\fR argument, |
---|
| 47 | converts it to an internal form of a particular type, and stores |
---|
| 48 | the converted value at the location indicated by the procedure's |
---|
| 49 | third argument. If all goes well, each of the procedures returns |
---|
| 50 | \fBTCL_OK\fR. If \fIsrc\fR does not have the proper syntax for the |
---|
| 51 | desired type then \fBTCL_ERROR\fR is returned, an error message is left |
---|
| 52 | in the interpreter's result, and nothing is stored at *\fIintPtr\fR |
---|
| 53 | or *\fIdoublePtr\fR or *\fIboolPtr\fR. |
---|
| 54 | .PP |
---|
| 55 | \fBTcl_GetInt\fR expects \fIsrc\fR to consist of a collection |
---|
| 56 | of integer digits, optionally signed and optionally preceded by |
---|
| 57 | white space. If the first two characters of \fIsrc\fR |
---|
| 58 | after the optional white space and sign are |
---|
| 59 | .QW 0x |
---|
| 60 | then \fIsrc\fR is expected to be in hexadecimal form; otherwise, |
---|
| 61 | if the first such character is |
---|
| 62 | .QW 0 |
---|
| 63 | then \fIsrc\fR |
---|
| 64 | is expected to be in octal form; otherwise, \fIsrc\fR is |
---|
| 65 | expected to be in decimal form. |
---|
| 66 | .PP |
---|
| 67 | \fBTcl_GetDouble\fR expects \fIsrc\fR to consist of a floating-point |
---|
| 68 | number, which is: white space; a sign; a sequence of digits; a |
---|
| 69 | decimal point; a sequence of digits; the letter |
---|
| 70 | .QW e ; |
---|
| 71 | a signed decimal exponent; and more white space. |
---|
| 72 | Any of the fields may be omitted, except that |
---|
| 73 | the digits either before or after the decimal point must be present |
---|
| 74 | and if the |
---|
| 75 | .QW e |
---|
| 76 | is present then it must be followed by the exponent number. |
---|
| 77 | .PP |
---|
| 78 | \fBTcl_GetBoolean\fR expects \fIsrc\fR to specify a boolean |
---|
| 79 | value. If \fIsrc\fR is any of \fB0\fR, \fBfalse\fR, |
---|
| 80 | \fBno\fR, or \fBoff\fR, then \fBTcl_GetBoolean\fR stores a zero |
---|
| 81 | value at \fI*boolPtr\fR. |
---|
| 82 | If \fIsrc\fR is any of \fB1\fR, \fBtrue\fR, \fByes\fR, or \fBon\fR, |
---|
| 83 | then 1 is stored at \fI*boolPtr\fR. |
---|
| 84 | Any of these values may be abbreviated, and upper-case spellings |
---|
| 85 | are also acceptable. |
---|
| 86 | |
---|
| 87 | .SH KEYWORDS |
---|
| 88 | boolean, conversion, double, floating-point, integer |
---|