home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 58 / af058b.adf / PV21.lha / REXX / Measure.pvrx < prev    next >
Text File  |  1991-07-18  |  2KB  |  56 lines

  1. /* Measure.pvrx
  2.    Copyright © 1991 by Stylus, Inc.
  3.    Author - Ross Cunniff & Jeff Blume
  4.  
  5. To run from its own User Menu item, add this line to
  6.     ProVector.pvrx:  'Define "Measure" "Measure MENU"'
  7.  
  8. To run from User/Rexxecute type "MENU" after the filename in the
  9.     macro file requester.  Thus 'File' text gadget
  10.     should read "Measure.pvrx MENU".
  11. */
  12.  
  13. /* Get the argument list to see whether this is a MENU, or an OK */
  14. arg arglist
  15. Cmd = word(arglist,1)
  16.  
  17. /* Get the rexxmathlib.library */
  18. if ~exists("LIBS:rexxmathlib.library") then do
  19.     'GetBool "Can not find REXXMATHLIB.LIBRARY" "Cancel" "Cancel"' 
  20.     exit
  21.     end
  22. else call addlib "rexxmathlib.library",0,-30,0
  23.  
  24. /* Always do this for a ProVector AREXX macro */
  25. 'Lock'
  26. if RC ~= 0 then exit
  27.  
  28. if Cmd = 'MENU' then do
  29.     /* This was called directly from the menu */
  30.     'Prompt "Click points to measure:"'
  31.     'GetUserData 1 2 2 "Measure OK" ""'
  32. end
  33. if Cmd = 'OK' then do
  34.     /* This was called from GetUserData */
  35.     'EndPrompt'
  36.     'GetInputPoints Pts'
  37.  
  38.     X0 = Pts.0.X;    Y0 = Pts.0.Y
  39.     X1 = Pts.1.X;    Y1 = Pts.1.Y
  40.  
  41.     /* Next, calculate the parameters for the text string */
  42.     DX = X1 - X0;        DY = Y1 - Y0
  43.     Dist = sqrt( DX*DX + DY*DY )
  44.  
  45.     /* Convert scientific notation to a number mortals can relate to */
  46.     Exp = right(Dist,3)    /* Exponent is rightmost 3 chars */
  47.     Len = length(Dist)    /* Length of 'Dist' text string */ 
  48.     Mant = left(Dist,Len-4)    /* Mantissa is length less "e" and exponent */
  49.     Dist = Mant * (10**Exp)
  50.  
  51.     GetBool '"Distance = '||Dist||'"' OK OK
  52. end
  53.  
  54. /* All done!  Unlock ProVector */
  55. 'UnLock'
  56.