Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/BoolObj.3 @ 52

Last change on this file since 52 was 25, checked in by landauf, 16 years ago

added tcl to libs

File size: 3.7 KB
Line 
1'\"
2'\" Copyright (c) 1996-1997 Sun Microsystems, Inc.
3'\" Contributions from Don Porter, NIST, 2005.  (not subject to US copyright)
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: BoolObj.3,v 1.11 2007/12/13 15:22:30 dgp Exp $
9'\"
10.so man.macros
11.TH Tcl_BooleanObj 3 8.5 Tcl "Tcl Library Procedures"
12.BS
13.SH NAME
14Tcl_NewBooleanObj, Tcl_SetBooleanObj, Tcl_GetBooleanFromObj \- store/retrieve boolean value in a Tcl_Obj
15.SH SYNOPSIS
16.nf
17\fB#include <tcl.h>\fR
18.sp
19Tcl_Obj *
20\fBTcl_NewBooleanObj\fR(\fIboolValue\fR)
21.sp
22\fBTcl_SetBooleanObj\fR(\fIobjPtr, boolValue\fR)
23.sp
24int
25\fBTcl_GetBooleanFromObj\fR(\fIinterp, objPtr, boolPtr\fR)
26.SH ARGUMENTS
27.AS Tcl_Interp boolValue in/out
28.AP int boolValue in
29Integer value to be stored as a boolean value in a Tcl_Obj.
30.AP Tcl_Obj *objPtr in/out
31Points to the Tcl_Obj in which to store, or from which to
32retrieve a boolean value.
33.AP Tcl_Interp *interp in/out
34If a boolean value cannot be retrieved,
35an error message is left in the interpreter's result object
36unless \fIinterp\fR is NULL.
37.AP int *boolPtr out
38Points to place where \fBTcl_GetBooleanFromObj\fR
39stores the boolean value (0 or 1) obtained from \fIobjPtr\fR.
40.BE
41
42.SH DESCRIPTION
43.PP
44These procedures are used to pass boolean values to and from
45Tcl as Tcl_Obj's.  When storing a boolean value into a Tcl_Obj,
46any non-zero integer value in \fIboolValue\fR is taken to be
47the boolean value \fB1\fR, and the integer value \fB0\fR is
48taken to be the boolean value \fB0\fR.
49.PP
50\fBTcl_NewBooleanObj\fR creates a new Tcl_Obj, stores the boolean
51value \fIboolValue\fR in it, and returns a pointer to the new Tcl_Obj.
52The new Tcl_Obj has reference count of zero.
53.PP
54\fBTcl_SetBooleanObj\fR accepts \fIobjPtr\fR, a pointer to
55an existing Tcl_Obj, and stores in the Tcl_Obj \fI*objPtr\fR
56the boolean value \fIboolValue\fR.  This is a write operation
57on \fI*objPtr\fR, so \fIobjPtr\fR must be unshared.  Attempts to
58write to a shared Tcl_Obj will panic.  A successful write
59of \fIboolValue\fR into \fI*objPtr\fR implies the freeing of
60any former value stored in \fI*objPtr\fR.
61.PP
62\fBTcl_GetBooleanFromObj\fR attempts to retrive a boolean value
63from the value stored in \fI*objPtr\fR.
64If \fIobjPtr\fR holds a string value recognized by \fBTcl_GetBoolean\fR,
65then the recognized boolean value is written at the address given
66by \fIboolPtr\fR. 
67If \fIobjPtr\fR holds any value recognized as
68a number by Tcl, then if that value is zero a 0 is written at
69the address given by \fIboolPtr\fR and if that
70value is non-zero a 1 is written at the address given by \fIboolPtr\fR.
71In all cases where a value is written at the address given
72by \fIboolPtr\fR, \fBTcl_GetBooleanFromObj\fR returns \fBTCL_OK\fR.
73If the value of \fIobjPtr\fR does not meet any of the conditions
74above, then \fBTCL_ERROR\fR is returned and an error message is
75left in the interpreter's result unless \fIinterp\fR is NULL.
76\fBTcl_GetBooleanFromObj\fR may also make changes to the internal
77fields of \fI*objPtr\fR so that future calls to
78\fBTcl_GetBooleanFromObj\fR on the same \fIobjPtr\fR can be
79performed more efficiently.
80.PP
81Note that the routines \fBTcl_GetBooleanFromObj\fR and
82\fBTcl_GetBoolean\fR are not functional equivalents.
83The set of values for which \fBTcl_GetBooleanFromObj\fR
84will return \fBTCL_OK\fR is strictly larger than
85the set of values for which \fBTcl_GetBoolean\fR will do the same.
86For example, the value
87.QW 5
88passed to \fBTcl_GetBooleanFromObj\fR
89will lead to a \fBTCL_OK\fR return (and the boolean value 1),
90while the same value passed to \fBTcl_GetBoolean\fR will lead to
91a \fBTCL_ERROR\fR return.
92
93.SH "SEE ALSO"
94Tcl_NewObj, Tcl_IsShared, Tcl_GetBoolean
95
96.SH KEYWORDS
97boolean, object
Note: See TracBrowser for help on using the repository browser.