Debian Codegraph @

doc/GetInt.3

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