C#cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc-------- PROGRAM calc0 C C line mode calculator that calls juexpr C IMPLICIT real*8 (A-H, O-Z) PARAMETER(IPvalue=255) PARAMETER(IPverb=20) CHARACTER*(IPvalue) event, line CHARACTER*(IPverb) outlin CALL stuff('PI',3.14159265358979323846,0) CALL stuff('E',2.71828,0) C Golden Ratio, around 1.61803 CALL stuff('GOLDEN_RATIO',(1.0+sqrt(5.0))/2.0,0) 100 CONTINUE READ(*,'(A)',END=999)line IF(line(1:1).EQ.'!')THEN ! lines beginning with ! are passed to system CALL system(line(2:)) GOTO 100 ENDIF C line is the input string to parse CALL juexpr(line,outlin,event,rvalue,ierr) C outlin is a string representation of a returned real value C event returns a string value or a message C rvalue is a real value returned when IERR=0 C ierr tells if a real value, string value, or message was returned C different meanings to the error flag returned by the calculator: IF(ierr.EQ.0)THEN C a numeric value was returned without error WRITE(6,'(A,A,A)')outlin,' = ',line ELSEIF(ierr.EQ.2)THEN C a string value was returned without error WRITE(6,'(A)')event ELSEIF(ierr.EQ.1)THEN C a request for a message has been returned (from DUMP or FUNC) WRITE(6,'(A,A)')'message===>',event ELSEIF(ierr.eq.-1)THEN C an error has occurred WRITE(6,'(A,A)')'error===>',event ELSE C this should not occur WRITE(6,'(A)')'warning===> unexpected ierr value from juexpr' ENDIF GO TO 100 999 CONTINUE END C#cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc--------