/* CMD: Calculate
 * Handy Calculator thing! */
/* By Arnie Cachelin, Copyright © 1992 NewTek Inc. */
/* Thu Feb  4 14:36:06 1993 */

address "LWModelerARexx.port"
libadd = addlib("LWModelerARexx.port",0)
Continue=1

SIGNAL ON ERROR
SIGNAL ON SYNTAX
MATHLIB="rexxmathlib.library"
IF POS(MATHLIB , SHOW('L')) = 0 THEN
  IF ~ADDLIB(MATHLIB , 0 , -30 , 0) THEN DO
	call notify(1,"!Can't find "MATHLIB)
	exit
	END

call req_begin "Calculate"
EqId = req_addcontrol("",'S',40)
call req_setval EqId,'12.2*sin(45)/6', '1+1'
do while Continue
  x = req_post()
  if (x) then do
     RHS= req_getval(EqId)
     end
  else do
     call req_end()
     exit
     end
  interpret 'Val='RHS
  continue = notify(2, '!Calculated',RHS'='Val*1,'@Calculate Another?')
  end
call req_end()
exit

SYNTAX:
ERROR:
  say 'Sorry, Error #'RC' on line 'SIGL' has been detected.'
  say errortext(rc)
  t=Notify(1,'!Total Bummer Dude!','!An error has been detected.','@'ErrorText(rc),'Line 'SIGL,sourceline(SIGL))
  call req_end()
  exit
