home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / man / cat.3 / CrtMathFnc.3 < prev    next >
Encoding:
Text File  |  1995-07-26  |  6.8 KB  |  133 lines

  1.  
  2.  
  3.  
  4.      TTTTccccllll____CCCCrrrreeeeaaaatttteeeeMMMMaaaatttthhhhFFFFuuuunnnncccc((((3333))))       TTTTccccllll ((((7777....0000))))       TTTTccccllll____CCCCrrrreeeeaaaatttteeeeMMMMaaaatttthhhhFFFFuuuunnnncccc((((3333))))
  5.  
  6.  
  7.  
  8.      _________________________________________________________________
  9.  
  10.      NNNNAAAAMMMMEEEE
  11.           Tcl_CreateMathFunc  -  Define  a  new  math   function   for
  12.           expressions
  13.  
  14.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  15.           ####iiiinnnncccclllluuuuddddeeee <<<<ttttccccllll....hhhh>>>>
  16.  
  17.           TTTTccccllll____CCCCrrrreeeeaaaatttteeeeMMMMaaaatttthhhhFFFFuuuunnnncccc(_i_n_t_e_r_p, _n_a_m_e, _n_u_m_A_r_g_s, _a_r_g_T_y_p_e_s, _p_r_o_c, _c_l_i_e_n_t_D_a_t_a)
  18.  
  19.      AAAARRRRGGGGUUUUMMMMEEEENNNNTTTTSSSS
  20.           Tcl_Interp      *_i_n_t_e_r_p      (in)      Interpreter in  which
  21.                                                  new  function will be
  22.                                                  defined.
  23.  
  24.           char            *_n_a_m_e        (in)      Name     for      new
  25.                                                  function.
  26.  
  27.           int             _n_u_m_A_r_g_s      (in)      Number  of  arguments
  28.                                                  to    new   function;
  29.                                                  also  gives  size  of
  30.                                                  _a_r_g_T_y_p_e_s array.
  31.  
  32.           Tcl_ValueType   *_a_r_g_T_y_p_e_s    (in)      Points  to  an  array
  33.                                                  giving            the
  34.                                                  permissible types for
  35.                                                  each    argument   to
  36.                                                  function.
  37.  
  38.           Tcl_MathProc    *_p_r_o_c        (in)      Procedure        that
  39.                                                  implements        the
  40.                                                  function.
  41.  
  42.           ClientData      _c_l_i_e_n_t_D_a_t_a   (in)      Arbitrary    one-word
  43.                                                  value to pass to _p_r_o_c
  44.                                                  when it is invoked.
  45.      _________________________________________________________________
  46.  
  47.  
  48.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  49.           Tcl allows a number of mathematical functions to be used  in
  50.           expressions,     such    as    ssssiiiinnnn,    ccccoooossss,    and    hhhhyyyyppppooootttt.
  51.           TTTTccccllll____CCCCrrrreeeeaaaatttteeeeMMMMaaaatttthhhhFFFFuuuunnnncccc allows  applications  to  add  additional
  52.           functions  to  those  already  provided by Tcl or to replace
  53.           existing functions.  _N_a_m_e is the name of the function as  it
  54.           will  appear  in expressions.  If _n_a_m_e doesn't already exist
  55.           as a function then a new function is created.   If  it  does
  56.           exist,  then the existing function is replaced.  _N_u_m_A_r_g_s and
  57.           _a_r_g_T_y_p_e_s describe the arguments to the function.  Each entry
  58.           in the _a_r_g_T_y_p_e_s array must be either TCL_INT, TCL_DOUBLE, or
  59.           TCL_EITHER to indicate whether  the  corresponding  argument
  60.  
  61.  
  62.  
  63.      Page 1                                          (printed 7/10/95)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      TTTTccccllll____CCCCrrrreeeeaaaatttteeeeMMMMaaaatttthhhhFFFFuuuunnnncccc((((3333))))       TTTTccccllll ((((7777....0000))))       TTTTccccllll____CCCCrrrreeeeaaaatttteeeeMMMMaaaatttthhhhFFFFuuuunnnncccc((((3333))))
  71.  
  72.  
  73.  
  74.           must  be  an  integer, a double-precision floating value, or
  75.           either, respectively.
  76.  
  77.           Whenever the function is invoked in an expression  Tcl  will
  78.           invoke  _p_r_o_c.   _P_r_o_c  should  have arguments and result that
  79.           match the type TTTTccccllll____MMMMaaaatttthhhhPPPPrrrroooocccc:
  80.                typedef int Tcl_MathProc(
  81.                     ClientData _c_l_i_e_n_t_D_a_t_a,
  82.                     Tcl_Interp *_i_n_t_e_r_p,
  83.                     Tcl_Value *_a_r_g_s,
  84.                     Tcl_Value *resultPtr);
  85.  
  86.           When _p_r_o_c is invoked the  _c_l_i_e_n_t_D_a_t_a  and  _i_n_t_e_r_p  arguments
  87.           will  be  the  same  as  those passed to TTTTccccllll____CCCCrrrreeeeaaaatttteeeeMMMMaaaatttthhhhFFFFuuuunnnncccc.
  88.           _A_r_g_s will point to an array of _n_u_m_A_r_g_s Tcl_Value structures,
  89.           which describe the actual arguments to the function:
  90.                typedef struct Tcl_Value {
  91.                     Tcl_ValueType _t_y_p_e;
  92.                     int _i_n_t_V_a_l_u_e;
  93.                     double _d_o_u_b_l_e_V_a_l_u_e;
  94.                } Tcl_Value;
  95.  
  96.           The _t_y_p_e field indicates the type of  the  argument  and  is
  97.           either  TCL_INT  or  TCL_DOUBLE.  It will match the _a_r_g_T_y_p_e_s
  98.           value specified for the function unless the  _a_r_g_T_y_p_e_s  value
  99.           was  TCL_EITHER.  Tcl  converts the argument supplied in the
  100.           expression to the type requested in  _a_r_g_T_y_p_e_s,  if  that  is
  101.           necessary.   Depending  on  the value of the _t_y_p_e field, the
  102.           _i_n_t_V_a_l_u_e or _d_o_u_b_l_e_V_a_l_u_e field will contain the actual  value
  103.           of the argument.
  104.  
  105.           _P_r_o_c should compute its result and store  it  either  as  an
  106.           integer  in  _r_e_s_u_l_t_P_t_r->_i_n_t_V_a_l_u_e  or  as a floating value in
  107.           _r_e_s_u_l_t_P_t_r->_d_o_u_b_l_e_V_a_l_u_e.  It should set also  _r_e_s_u_l_t_P_t_r->_t_y_p_e
  108.           to  either TCL_INT or TCL_DOUBLE to indicate which value was
  109.           set.  Under normal circumstances _p_r_o_c should return  TCL_OK.
  110.           If an error occurs while executing the function, _p_r_o_c should
  111.           return TCL_ERROR and  leave  an  error  message  in  _i_n_t_e_r_p-
  112.           >_r_e_s_u_l_t.
  113.  
  114.  
  115.      KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS
  116.           expression, mathematical function
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                                          (printed 7/10/95)
  130.  
  131.  
  132.  
  133.