home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 626a.lha / Textra_v1.12 / Scripts / eval.textra < prev    next >
Text File  |  1991-12-14  |  2KB  |  52 lines

  1.     /*******************************************************************
  2.      *   TEXTRA AREXX script -- Mike Haas, 1991, All Rights Reserved.  *
  3.      * Freely distributable ONLY as a component of the TEXTRA package. *
  4.      * This banner may not be removed or altered (improvements to the  *
  5.      *    actual program welcome).  Please document and send to me.    *
  6.      *        !!! PLACE THIS FILE IN YOUR REXX: DIRECTORY !!!          *
  7.      *******************************************************************/
  8.  
  9.             /***   Thanks (ONCE AGAIN) to Dr. Martin Kees   ***/
  10.  
  11. /* evaluate a selected (pure math) expression */
  12.  
  13. /* TO USE...
  14.  
  15.    Select the text that comprises the mathematical expression (even
  16.    if it spans several lines).  Then launch this script.
  17.    
  18.    TEXTRA will tell you the answer!
  19.    
  20.    For example, double-click on this -->  4*2.1
  21.    and then execute this script.
  22.    
  23.    00001 15-dec-91 mdh Added 'action' argument initially for 'replace'
  24. */
  25.  
  26. options results
  27.  
  28. parse arg action   /* get the argument 00001 */
  29. if (action == "") then action = notify   /* set notify as default 00001 */
  30.  
  31. expression= 'EX= '
  32.  
  33. get select text
  34. parse var result num  thisselect
  35. if num='NO' then exit
  36.  
  37. expression= expression thisselect
  38.  
  39. do until num=0
  40.    get select next
  41.    parse var result num thisselect
  42.    expression= expression thisselect
  43.    end
  44.  
  45. interpret expression
  46. if (action == "replace") then  /* check for 'replace' 00001 */
  47.    text ex
  48. else do
  49.    val= "The value is: " ex
  50.    notify '"' val '"'
  51. end
  52.