Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/LinkVar.3 @ 25

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

added tcl to libs

File size: 8.1 KB
Line 
1'\"
2'\" Copyright (c) 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: LinkVar.3,v 1.16 2007/12/13 15:22:31 dgp Exp $
9'\"
10.so man.macros
11.TH Tcl_LinkVar 3 7.5 Tcl "Tcl Library Procedures"
12.BS
13.SH NAME
14Tcl_LinkVar, Tcl_UnlinkVar, Tcl_UpdateLinkedVar \- link Tcl variable to C variable
15.SH SYNOPSIS
16.nf
17\fB#include <tcl.h>\fR
18.sp
19int
20\fBTcl_LinkVar\fR(\fIinterp, varName, addr, type\fR)
21.sp
22\fBTcl_UnlinkVar\fR(\fIinterp, varName\fR)
23.sp
24\fBTcl_UpdateLinkedVar\fR(\fIinterp, varName\fR)
25.SH ARGUMENTS
26.AS Tcl_Interp writable
27.AP Tcl_Interp *interp in
28Interpreter that contains \fIvarName\fR.
29Also used by \fBTcl_LinkVar\fR to return error messages.
30.AP "const char" *varName in
31Name of global variable.
32.AP char *addr in
33Address of C variable that is to be linked to \fIvarName\fR.
34.AP int type in
35Type of C variable.  Must be one of \fBTCL_LINK_INT\fR,
36.VS 8.5
37\fBTCL_LINK_UINT\fR, \fBTCL_LINK_CHAR\fR, \fBTCL_LINK_UCHAR\fR,
38\fBTCL_LINK_SHORT\fR, \fBTCL_LINK_USHORT\fR, \fBTCL_LINK_LONG\fR,
39\fBTCL_LINK_ULONG\fR,
40.VE 8.5
41\fBTCL_LINK_WIDE_INT\fR,
42.VS 8.5
43\fBTCL_LINK_WIDE_UINT\fR, \fBTCL_LINK_FLOAT\fR,
44.VE 8.5
45\fBTCL_LINK_DOUBLE\fR, \fBTCL_LINK_BOOLEAN\fR, or
46\fBTCL_LINK_STRING\fR, optionally OR'ed with \fBTCL_LINK_READ_ONLY\fR
47to make Tcl variable read-only.
48.BE
49
50.SH DESCRIPTION
51.PP
52\fBTcl_LinkVar\fR uses variable traces to keep the Tcl variable
53named by \fIvarName\fR in sync with the C variable at the address
54given by \fIaddr\fR.
55Whenever the Tcl variable is read the value of the C variable will
56be returned, and whenever the Tcl variable is written the C
57variable will be updated to have the same value.
58\fBTcl_LinkVar\fR normally returns \fBTCL_OK\fR;  if an error occurs
59while setting up the link (e.g. because \fIvarName\fR is the
60name of array) then \fBTCL_ERROR\fR is returned and the interpreter's result
61contains an error message.
62.PP
63The \fItype\fR argument specifies the type of the C variable,
64and must have one of the following values, optionally OR'ed with
65\fBTCL_LINK_READ_ONLY\fR:
66.TP
67\fBTCL_LINK_INT\fR
68The C variable is of type \fBint\fR.
69Any value written into the Tcl variable must have a proper integer
70form acceptable to \fBTcl_GetIntFromObj\fR;  attempts to write
71non-integer values into \fIvarName\fR will be rejected with
72Tcl errors.
73.VS 8.5
74.TP
75\fBTCL_LINK_UINT\fR
76The C variable is of type \fBunsigned int\fR.
77Any value written into the Tcl variable must have a proper unsigned
78integer form acceptable to \fBTcl_GetWideIntFromObj\fR and in the
79platform's defined range for the \fBunsigned int\fR type; attempts to
80write non-integer values (or values outside the range) into
81\fIvarName\fR will be rejected with Tcl errors.
82.TP
83\fBTCL_LINK_CHAR\fR
84The C variable is of type \fBchar\fR.
85Any value written into the Tcl variable must have a proper integer
86form acceptable to \fBTcl_GetIntFromObj\fR and be in the range of the
87\fBchar\fR datatype; attempts to write non-integer or out-of-range
88values into \fIvarName\fR will be rejected with Tcl errors.
89.TP
90\fBTCL_LINK_UCHAR\fR
91The C variable is of type \fBunsigned char\fR.
92Any value written into the Tcl variable must have a proper unsigned
93integer form acceptable to \fBTcl_GetIntFromObj\fR and in the
94platform's defined range for the \fBunsigned char\fR type; attempts to
95write non-integer values (or values outside the range) into
96\fIvarName\fR will be rejected with Tcl errors.
97.TP
98\fBTCL_LINK_SHORT\fR
99The C variable is of type \fBshort\fR.
100Any value written into the Tcl variable must have a proper integer
101form acceptable to \fBTcl_GetIntFromObj\fR and be in the range of the
102\fBshort\fR datatype; attempts to write non-integer or out-of-range
103values into \fIvarName\fR will be rejected with Tcl errors.
104.TP
105\fBTCL_LINK_USHORT\fR
106The C variable is of type \fBunsigned short\fR.
107Any value written into the Tcl variable must have a proper unsigned
108integer form acceptable to \fBTcl_GetIntFromObj\fR and in the
109platform's defined range for the \fBunsigned short\fR type; attempts to
110write non-integer values (or values outside the range) into
111\fIvarName\fR will be rejected with Tcl errors.
112.TP
113\fBTCL_LINK_LONG\fR
114The C variable is of type \fBlong\fR.
115Any value written into the Tcl variable must have a proper integer
116form acceptable to \fBTcl_GetLongFromObj\fR; attempts to write
117non-integer or out-of-range
118values into \fIvarName\fR will be rejected with Tcl errors.
119.TP
120\fBTCL_LINK_ULONG\fR
121The C variable is of type \fBunsigned long\fR.
122Any value written into the Tcl variable must have a proper unsigned
123integer form acceptable to \fBTcl_GetWideIntFromObj\fR and in the
124platform's defined range for the \fBunsigned long\fR type; attempts to
125write non-integer values (or values outside the range) into
126\fIvarName\fR will be rejected with Tcl errors.
127.VE 8.5
128.TP
129\fBTCL_LINK_DOUBLE\fR
130The C variable is of type \fBdouble\fR.
131Any value written into the Tcl variable must have a proper real
132form acceptable to \fBTcl_GetDoubleFromObj\fR;  attempts to write
133non-real values into \fIvarName\fR will be rejected with
134Tcl errors.
135.VS 8.5
136.TP
137\fBTCL_LINK_FLOAT\fR
138The C variable is of type \fBfloat\fR.
139Any value written into the Tcl variable must have a proper real
140form acceptable to \fBTcl_GetDoubleFromObj\fR and must be within the
141range acceptable for a \fBfloat\fR; attempts to
142write non-real values (or values outside the range) into
143\fIvarName\fR will be rejected with Tcl errors.
144.VE 8.5
145.TP
146\fBTCL_LINK_WIDE_INT\fR
147The C variable is of type \fBTcl_WideInt\fR (which is an integer type
148at least 64-bits wide on all platforms that can support it.)
149Any value written into the Tcl variable must have a proper integer
150form acceptable to \fBTcl_GetWideIntFromObj\fR;  attempts to write
151non-integer values into \fIvarName\fR will be rejected with
152Tcl errors.
153.VS 8.5
154.TP
155\fBTCL_LINK_WIDE_UINT\fR
156The C variable is of type \fBTcl_WideUInt\fR (which is an unsigned
157integer type at least 64-bits wide on all platforms that can support
158it.)
159Any value written into the Tcl variable must have a proper unsigned
160integer form acceptable to \fBTcl_GetWideIntFromObj\fR (it will be
161cast to unsigned);
162.\" FIXME! Use bignums instead.
163attempts to write non-integer values into \fIvarName\fR will be
164rejected with Tcl errors.
165.VE 8.5
166.TP
167\fBTCL_LINK_BOOLEAN\fR
168The C variable is of type \fBint\fR.
169If its value is zero then it will read from Tcl as
170.QW 0 ;
171otherwise it will read from Tcl as
172.QW 1 .
173Whenever \fIvarName\fR is
174modified, the C variable will be set to a 0 or 1 value.
175Any value written into the Tcl variable must have a proper boolean
176form acceptable to \fBTcl_GetBooleanFromObj\fR;  attempts to write
177non-boolean values into \fIvarName\fR will be rejected with
178Tcl errors.
179.TP
180\fBTCL_LINK_STRING\fR
181The C variable is of type \fBchar *\fR.
182If its value is not NULL then it must be a pointer to a string
183allocated with \fBTcl_Alloc\fR or \fBckalloc\fR.
184Whenever the Tcl variable is modified the current C string will be
185freed and new memory will be allocated to hold a copy of the variable's
186new value.
187If the C variable contains a NULL pointer then the Tcl variable
188will read as
189.QW NULL .
190.PP
191If the \fBTCL_LINK_READ_ONLY\fR flag is present in \fItype\fR then the
192variable will be read-only from Tcl, so that its value can only be
193changed by modifying the C variable.
194Attempts to write the variable from Tcl will be rejected with errors.
195.PP
196\fBTcl_UnlinkVar\fR removes the link previously set up for the
197variable given by \fIvarName\fR.  If there does not exist a link
198for \fIvarName\fR then the procedure has no effect.
199.PP
200\fBTcl_UpdateLinkedVar\fR may be invoked after the C variable has
201changed to force the Tcl variable to be updated immediately.
202In many cases this procedure is not needed, since any attempt to
203read the Tcl variable will return the latest value of the C variable.
204However, if a trace has been set on the Tcl variable (such as a
205Tk widget that wishes to display the value of the variable), the
206trace will not trigger when the C variable has changed.
207\fBTcl_UpdateLinkedVar\fR ensures that any traces on the Tcl
208variable are invoked.
209
210.SH KEYWORDS
211boolean, integer, link, read-only, real, string, traces, variable
Note: See TracBrowser for help on using the repository browser.