1Tcl_IntObj(3)               Tcl Library Procedures               Tcl_IntObj(3)
2
3
4
5______________________________________________________________________________
6

NAME

8       Tcl_NewIntObj,    Tcl_NewLongObj,   Tcl_NewWideIntObj,   Tcl_SetIntObj,
9       Tcl_SetLongObj, Tcl_SetWideIntObj,  Tcl_GetIntFromObj,  Tcl_GetLongFro‐
10       mObj,  Tcl_GetWideIntFromObj  -  manipulate Tcl objects as integers and
11       wide integers
12

SYNOPSIS

14       #include <tcl.h>
15
16       Tcl_Obj *
17       Tcl_NewIntObj(intValue)
18
19       Tcl_Obj *
20       Tcl_NewLongObj(longValue)
21
22       Tcl_Obj *                                                               │
23       Tcl_NewWideIntObj(wideValue)                                            │
24
25       Tcl_SetIntObj(objPtr, intValue)
26
27       Tcl_SetLongObj(objPtr, longValue)
28
29       Tcl_SetWideIntObj(objPtr, wideValue)                                    │
30
31       int
32       Tcl_GetIntFromObj(interp, objPtr, intPtr)
33
34       int
35       Tcl_GetLongFromObj(interp, objPtr, longPtr)
36
37       int                                                                     │
38       Tcl_GetWideIntFromObj(interp, objPtr, widePtr)                          │
39

ARGUMENTS

41       int           intValue  (in)      Integer value used to  initialize  or
42                                         set an integer object.
43
44       long          longValue (in)      Long integer value used to initialize
45                                         or set an integer object.
46
47       Tcl_WideInt   wideValue (in)      Wide integer value  (minimum  64-bits │
48                                         wide where supported by the compiler) │
49                                         used to  initialize  or  set  a  wide │
50                                         integer object.
51
52       Tcl_Obj       *objPtr   (in/out)  For   Tcl_SetIntObj,  Tcl_SetLongObj,
53                                         and Tcl_SetWideIntObj, this points to │
54                                         the object to be converted to integer │
55                                         type.      For     Tcl_GetIntFromObj, │
56                                         Tcl_GetLongFromObj,               and │
57                                         Tcl_GetWideIntFromObj, this refers to │
58                                         the object from which to get an inte‐ │
59                                         ger or long integer value; if  objPtr
60                                         does  not already point to an integer │
61                                         object (or a wide integer  object  in │
62                                         the  case  of  Tcl_SetWideIntObj  and │
63                                         Tcl_GetWideIntFromObj,)  an   attempt
64                                         will be made to convert it to one.
65
66       Tcl_Interp    *interp   (in/out)  If an error occurs during conversion,
67                                         an  error  message  is  left  in  the
68                                         interpreter's  result  object  unless
69                                         interp is NULL.
70
71       int           *intPtr   (out)     Points to place to store the  integer
72                                         value  obtained  by Tcl_GetIntFromObj
73                                         from objPtr.
74
75       long          *longPtr  (out)     Points to place  to  store  the  long
76                                         integer  value  obtained  by Tcl_Get‐
77                                         LongFromObj from objPtr.
78
79       Tcl_WideInt   *widePtr  (out)     Points to place  to  store  the  wide │
80                                         integer     value     obtained     by │
81                                         Tcl_GetWideIntFromObj from objPtr.
82_________________________________________________________________
83
84

DESCRIPTION

86       These procedures are used to create, modify, and read integer and  wide
87       integer  Tcl  objects  from  C  code.   Tcl_NewIntObj,  Tcl_NewLongObj,
88       Tcl_SetIntObj, and Tcl_SetLongObj create a new object of  integer  type
89       or  modify  an existing object to have integer type, and Tcl_NewWideIn‐ 
90       tObj and Tcl_SetWideIntObj create a new object of wide integer type  or │
91       modify an existing object to have wide integer type.  Tcl_NewIntObj and
92       Tcl_SetIntObj set the object to have the integer value  given  by  int‐
93       Value,  Tcl_NewLongObj  and  Tcl_SetLongObj  set the object to have the
94       long integer  value  given  by  longValue,  and  Tcl_NewWideIntObj  and │
95       Tcl_SetWideIntObj  set  the object to have the wide integer value given │
96       by  wideValue.   Tcl_NewIntObj,  Tcl_NewLongObj  and  Tcl_NewWideIntObj 
97       return  a  pointer to a newly created object with reference count zero. │
98       These procedures set the object's type to be  integer  and  assign  the │
99       integer  value  to  the  object's  internal representation longValue or │
100       wideValue member (as appropriate).  Tcl_SetIntObj,  Tcl_SetLongObj  and │
101       Tcl_SetWideIntObj  invalidate any old string representation and, if the
102       object is not already an integer object, free any old  internal  repre‐
103       sentation.
104
105       Tcl_GetIntFromObj  and  Tcl_GetLongFromObj attempt to return an integer
106       value from the Tcl object objPtr, and Tcl_GetWideIntFromObj attempts to │
107       return  a wide integer value from the Tcl object objPtr.  If the object │
108       is not already an integer object, or a wide integer object in the  case │
109       of Tcl_GetWideIntFromObj they will attempt to convert it to one.  If an
110       error occurs during conversion, they  return  TCL_ERROR  and  leave  an
111       error message in the interpreter's result object unless interp is NULL.
112       Also, if the long integer held in the object's internal  representation
113       longValue  member  can  not  be  represented  in  a (non-long) integer,
114       Tcl_GetIntFromObj returns TCL_ERROR and leaves an error message in  the
115       interpreter's  result  object  unless  interp  is NULL.  Otherwise, all
116       three procedures return TCL_OK and  store  the  integer,  long  integer
117       value  or  wide  integer  in  the  address given by intPtr, longPtr and │
118       widePtr respectively.  If the object is not already an integer or  wide
119       integer  object,  the conversion will free any old internal representa‐
120       tion.
121
122

SEE ALSO

124       Tcl_NewObj, Tcl_DecrRefCount, Tcl_IncrRefCount, Tcl_GetObjResult
125
126

KEYWORDS

128       integer, integer object, integer type, internal representation, object,
129       object type, string representation
130
131
132
133Tcl                                   8.0                        Tcl_IntObj(3)
Impressum