home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tcl2-73c.zip / tcl7.3 / doc / ExprLong.3 < prev    next >
Text File  |  1993-04-17  |  5KB  |  120 lines

  1. '\"
  2. '\" Copyright (c) 1989-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/ExprLong.3,v 1.11 93/04/17 15:31:16 ouster Exp $ SPRITE (Berkeley)
  22. '\" 
  23. .so man.macros
  24. .HS Tcl_ExprLong tclc 7.0
  25. .BS
  26. .SH NAME
  27. Tcl_ExprLong, Tcl_ExprDouble, Tcl_ExprBool, Tcl_ExprString \- evaluate an expression
  28. .SH SYNOPSIS
  29. .nf
  30. \fB#include <tcl.h>\fR
  31. .sp
  32. int
  33. \fBTcl_ExprLong\fR(\fIinterp, string, longPtr\fR)
  34. .sp
  35. int
  36. \fBTcl_ExprDouble\fR(\fIinterp, string, doublePtr\fR)
  37. .sp
  38. int
  39. \fBTcl_ExprBoolean\fR(\fIinterp, string, booleanPtr\fR)
  40. .sp
  41. int
  42. \fBTcl_ExprString\fR(\fIinterp, string\fR)
  43. .SH ARGUMENTS
  44. .AS Tcl_Interp *booleanPtr
  45. .AP Tcl_Interp *interp in
  46. Interpreter in whose context to evaluate \fIstring\fR.
  47. .AP char *string in
  48. Expression to be evaluated.  Must be in writable memory (the expression
  49. parser makes temporary modifications to the string during parsing, which
  50. it undoes before returning).
  51. .AP long *longPtr out
  52. Pointer to location in which to store the integer value of the
  53. expression.
  54. .AP int *doublePtr out
  55. Pointer to location in which to store the floating-point value of the
  56. expression.
  57. .AP int *booleanPtr out
  58. Pointer to location in which to store the 0/1 boolean value of the
  59. expression.
  60. .BE
  61.  
  62. .SH DESCRIPTION
  63. .PP
  64. These four procedures all evaluate an expression, returning
  65. the result in one of four different forms.
  66. The expression is given by the \fIstring\fR argument, and it
  67. can have any of the forms accepted by the \fBexpr\fR command.
  68. The \fIinterp\fR argument refers to an interpreter used to
  69. evaluate the expression (e.g. for variables and nested Tcl
  70. commands) and to return error information.  \fIInterp->result\fR
  71. is assumed to be initialized in the standard fashion when any
  72. of the procedures are invoked.
  73. .PP
  74. For all of these procedures the return value is a standard
  75. Tcl result:  \fBTCL_OK\fR means the expression was succesfully
  76. evaluated, and \fBTCL_ERROR\fR means that an error occurred while
  77. evaluating the expression.  If \fBTCL_ERROR\fR is returned then
  78. \fIinterp->result\fR will hold a message describing the error.
  79. If an error occurs while executing a Tcl command embedded in
  80. the expression then that error will be returned.
  81. .PP
  82. If the expression is successfully evaluated, then its value is
  83. returned in one of four forms, depending on which procedure
  84. is invoked.
  85. \fBTcl_ExprLong\fR stores an integer value at \fI*longPtr\fR.
  86. If the expression's actual value is a floating-point number,
  87. then it is truncated to an integer.
  88. If the expression's actual value is a non-numeric string then
  89. an error is returned.
  90. .PP
  91. \fBTcl_ExprDouble\fR stores a floating-point value at \fI*doublePtr\fR.
  92. If the expression's actual value is an integer, it is converted to
  93. floating-point.
  94. If the expression's actual value is a non-numeric string then
  95. an error is returned.
  96. .PP
  97. \fBTcl_ExprBoolean\fR stores a 0/1 integer value at \fI*booleanPtr\fR.
  98. If the expression's actual value is an integer or floating-point
  99. number, then \fBTcl_ExprBoolean\fR stores 0 at \fI*booleanPtr\fR if
  100. the value was zero and 1 otherwise.
  101. .VS
  102. If the expression's actual value is a non-numeric string then
  103. it must be one of the values accepted by \fBTcl_GetBoolean\fR,
  104. such as ``yes'' or ``no'', or else an error occurs.
  105. .VE
  106. .PP
  107. \fBTcl_ExprString\fR returns the value of the expression as a
  108. string stored in \fIinterp->result\fR.
  109. .VS
  110. If the expression's actual value is an integer
  111. then \fBTcl_ExprString\fR converts it to a string using \fBsprintf\fR
  112. with a ``%d'' converter.
  113. If the expression's actual value is a floating-point
  114. number, then \fBTcl_ExprString\fR calls \fBTcl_PrintDouble\fR
  115. to convert it to a string.
  116. .VE
  117.  
  118. .SH KEYWORDS
  119. boolean, double, evaluate, expression, integer, string
  120.