home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tcl2-73c.zip / tcl7.3 / doc / LinkVar.3 < prev    next >
Text File  |  1993-07-28  |  4KB  |  114 lines

  1. '\"
  2. '\" Copyright (c) 1993 The Regents of the University of California.
  3. '\" All rights reserved.
  4. '\"
  5. '\" Permission is hereby granted, without written agreement and without
  6. '\" license or royalty fees, to use, copy, modify, and distribute this
  7. '\" documentation for any purpose, provided that the above copyright
  8. '\" notice and the following two paragraphs appear in all copies.
  9. '\"
  10. '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
  11. '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  12. '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  13. '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. '\"
  15. '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  16. '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  17. '\" AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  18. '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  19. '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. '\" 
  21. '\" $Header: /user6/ouster/tcl/man/RCS/LinkVar.3,v 1.4 93/07/28 15:18:56 ouster Exp $ SPRITE (Berkeley)
  22. '\" 
  23. .so man.macros
  24. .HS Tcl_LinkVar tclc 7.0
  25. .BS
  26. .SH NAME
  27. .na
  28. Tcl_LinkVar, Tcl_UnlinkVar \- link Tcl variable to C variable
  29. .ad
  30. .SH SYNOPSIS
  31. .nf
  32. \fB#include <tcl.h>\fR
  33. .sp
  34. int
  35. \fBTcl_LinkVar\fR(\fIinterp, varName, addr, type\fR)
  36. .sp
  37. \fBTcl_UnlinkVar\fR(\fIinterp, varName\fR)
  38. .SH ARGUMENTS
  39. .AS Tcl_Interp writable
  40. .AP Tcl_Interp *interp in
  41. Interpreter that contains \fIvarName\fR.
  42. Also used by \fBTcl_LinkVar\fR to return error messages.
  43. .AP char *varName in
  44. Name of global variable.
  45. .AP char *addr in
  46. Address of C variable that is to be linked to \fIvarName\fR.
  47. .AP int type in
  48. .na
  49. Type of C variable.  Must be one of TCL_LINK_INT, TCL_LINK_DOUBLE,
  50. TCL_LINK_BOOLEAN, or TCL_LINK_STRING, optionally OR'ed with
  51. TCL_LINK_READ_ONLY to make Tcl variable read-only.
  52. .ad
  53. .BE
  54.  
  55. .SH DESCRIPTION
  56. .PP
  57. \fBTcl_LinkVar\fR uses variable traces to keep the Tcl variable
  58. named by \fIvarName\fR in sync with the C variable at the address
  59. given by \fIaddr\fR.
  60. Whenever the Tcl variable is read the value of the C variable will
  61. be returned, and whenever the Tcl variable is written the C
  62. variable will be updated to have the same value.
  63. \fBTcl_LinkVar\fR normally returns TCL_OK;  if an error occurs
  64. while setting up the link (e.g. because \fIvarName\fR is the
  65. name of array) then TCL_ERROR is returned and \fIinterp->result\fR
  66. contains an error message.
  67. .PP
  68. The \fItype\fR argument specifies the type of the C variable,
  69. and must have one of the following values, optionally OR'ed with
  70. TCL_LINK_READ_ONLY:
  71. .TP
  72. \fBTCL_LINK_INT\fR
  73. The C variable is of type \fBint\fR.
  74. Any value written into the Tcl variable must have a proper integer
  75. form acceptable to \fBTcl_GetInt\fR;  attempts to write
  76. non-integer values into \fIvarName\fR will be rejected with
  77. Tcl errors.
  78. .TP
  79. \fBTCL_LINK_DOUBLE\fR
  80. The C variable is of type \fBdouble\fR.
  81. Any value written into the Tcl variable must have a proper real
  82. form acceptable to \fBTcl_GetDouble\fR;  attempts to write
  83. non-real values into \fIvarName\fR will be rejected with
  84. Tcl errors.
  85. .TP
  86. \fBTCL_LINK_BOOLEAN\fR
  87. The C variable is of type \fBint\fR.
  88. If its value is zero then it will read from Tcl as ``0'';
  89. otherwise it will read from Tcl as ``1''.
  90. Whenver \fIvarName\fR is
  91. modified, the C variable will be set to a 0 or 1 value.
  92. Any value written into the Tcl variable must have a proper boolean
  93. form acceptable to \fBTcl_GetBoolean\fR;  attempts to write
  94. non-boolean values into \fIvarName\fR will be rejected with
  95. Tcl errors.
  96. .TP
  97. \fBTCL_LINK_STRING\fR
  98. The C variable is of type \fBchar *\fR.
  99. If its value is not null then it must be a pointer to a string
  100. allocated with \fBmalloc\fR.
  101. Whenever the Tcl variable is modified the current C string will be
  102. freed and new memory will be allocated to hold a copy of the variable's
  103. new value.
  104. If the C variable contains a null pointer then the Tcl variable
  105. will read as ``NULL''.
  106. .PP
  107. If the TCL_LINK_READ_ONLY flag is present in \fItype\fR then the
  108. variable will be read-only from Tcl, so that its value can only be
  109. changed by modifying the C variable.
  110. Attempts to write the variable from Tcl will be rejected with errors.
  111.  
  112. .SH KEYWORDS
  113. boolean, integer, link, read-only, real, string, variable
  114.