Post Reply 
Name that calculator - from the program listing...
11-12-2018, 08:00 AM (This post was last modified: 11-12-2018 08:25 AM by Ángel Martin.)
Post: #6
RE: Name that calculator - from the program listing...
(11-12-2018 12:43 AM)Sylvain Cote Wrote:  Another jewel from Ángel the magician! Wink
HP-41 of course!
I would assume CL is not mandatory for this one, using alpha to hold enter/exit condition is brilliant.
  • DO ... "condition" WHILE
  • "condition" IF ... THEN ... ENDIF
Some questions ...
  • did you also include the loop : "condition" WHILE ... WEND ?
  • will it it support a control decision/loop inside another control decision/loop ?

You're all correct - but let's not set up expectations too high though:

- These extensions will be released in a forthcoming revision of the Formula_Evaluation Module, revision 1G.

- At the heart of the implementation lies the EVAL? function (which actually is a FOCAL routine, if you need to know). Both WHILE and IF perform some housekeeping with the RTN addresses, foreseeing both a TRUE and a FALSE contingency, and then launch EVAL? for a Boolean evaluation of the test condition stated in ALPHA. Depending on the result the RTN addresses are re-arranged so the program flow responds to the desired scheme.

- DO/WHILE supports up to three levels of nested calls, but IF.ELSE.ENDIF currently does not. However, it's possible to have and IF.ELSE.ENDIF structure within a DO/WHILE loop; and vice-versa.

Here's a couple of examples to whet you appetite (BTW, the mathematicians out there can provide some real-life application to try?)

The code below increments the value in Y until reaching 10, which (showing off the most inefficient way to do it) is tested using the value of its decimal LOG. This shows that the test condition can be *anything* supported by EVAL?

Code:
01  LBL "YLO10"
02  5.1
03  DO
04    VIEW Y
05    ISG  Y
06    "LG(IP(Y))#1"
07  WHILE
08  "DONE"
09  AVIEW
10  END

The next example shows the Fibonacci numbers between 1 and 100:

Code:
01  LBL "FIB$"
02  1
03  ENTER^
04  DO
05    "X+Y"
06    EVAL$
07    "L"
08    EVALY
09    VIEW X
10    PSE
11    "X<100"
12  WHILE
13  END

Exciting times in the ASDL, a.k.a "Archeological Software Development Lab ;-)

ÁM

"To live or die by your own sword one must first learn to wield it aptly."
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Name that calculator - from the program listing... - Ángel Martin - 11-12-2018 08:00 AM



User(s) browsing this thread: 1 Guest(s)