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
 Ángel Martin Senior Member Posts: 1,345 Joined: Dec 2013
RE: Name that calculator - from the program listing...
(11-12-2018 12:43 AM)Sylvain Cote Wrote:  Another jewel from Ángel the magician!
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
 « Next Oldest | Next Newest »

 Messages In This Thread Name that calculator - from the program listing... - Ángel Martin - 11-11-2018, 07:58 PM RE: Name that calculator - from the program listing... - Massimo Gnerucci - 11-11-2018, 08:16 PM RE: Name that calculator - from the program listing... - mfleming - 11-11-2018, 08:17 PM RE: Name that calculator - from the program listing... - JurgenRo - 11-11-2018, 08:18 PM RE: Name that calculator - from the program listing... - Sylvain Cote - 11-12-2018, 12:43 AM RE: Name that calculator - from the program listing... - Ángel Martin - 11-12-2018 08:00 AM RE: Name that calculator - from the program listing... - Ángel Martin - 11-12-2018, 10:17 AM RE: Name that calculator - from the program listing... - Ángel Martin - 11-12-2018, 03:20 PM RE: Name that calculator - from the program listing... - derekamos - 11-14-2018, 09:59 AM RE: Name that calculator - from the program listing... - Ángel Martin - 11-14-2018, 05:38 PM RE: Name that calculator - from the program listing... - Eddie W. Shore - 11-14-2018, 01:54 PM RE: Name that calculator - from the program listing... - Ángel Martin - 11-14-2018, 05:40 PM RE: Name that calculator - from the program listing... - derekamos - 11-14-2018, 11:26 PM

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