HP 48GX Indefinite Loops
03-30-2022, 01:02 AM
Post: #7
 ttw Member Posts: 286 Joined: Jun 2014
RE: HP 48GX Indefinite Loops
I've used two methods for the 50g (depending on other items). One is the DO...WHILE..END pattern and the other is to use the FOR...NEXT and set the FOR statement's bound dummy outside the correct range to trigger a stop. Either works.

In a language I developed (along with another colleague), I used several types of loops. (It still didn't fix the common DO...UNTIL...UNLESS..IN WHICH CASE... method of thinking.

Just to make things complicated, any combination of conditions could be combined. Loops could be named and these names were part of the syntax. The basic syntax for a Fortran style loop (the 50g FOR is like Fortran 66 rather than like Fortran 77 and later) Some of these structures might be useful if anyone makes another calculator language.

Loops initiated by DO followed by any of several conditions

I:j:k:l (I is the bound variable and j, k, l as the beginning, end, and increment. Default start and increment were each 1 (though, like Fortran, any values could be used to match the ability to index with negative numbers).)

WHILE logical_value (evaluated before the loop executes.)

k TIMES (k is the number of times the loop executes_

k IN (ENUMERATED SET) (Goes through an enumerated set defined elsewhere)

(There may have been more, I don't remember.)

Loops did have two types of ending.

END_DO

UNTIL logical_value

One could write things like:

LOOP: DO WHILE x > .001 100000 TIMES

LOOP: UNTIL Y < .007

The point of putting labels first is for ease of reading; it's psychologically hard not to left-justify each loop.

The statements CYCLE and EXIT or CYCLE_IF and EXIT _IF allow for "emergency" exits.

Nested loops CYCLE or EXIT from the inside out or to the label with LABEL: EXIT or the like.

There were some other weird but useful things like a BLOCK and END_BLOCK statement which can have and EXIT or newly defined variables with scope within the block.

And while I'm rambling. The GOTO statement could only target numbered labels like GOTO 234
and the statement 234: CONTINUE as a target. The idea is that one could put these labels in numerical order for ease of reading. Numerical labels were "nonstructured" but alphanumeric labels were "structured" thought with lots of exits.

Lots of array stuff and other numerical stuff, including unlimited integers and reals (though the latters two were not guaranteed to be fast.)
 « Next Oldest | Next Newest »

 Messages In This Thread HP 48GX Indefinite Loops - MNH - 03-28-2022, 01:11 AM RE: HP 48GX Indefinite Loops - Eddie W. Shore - 03-28-2022, 03:33 AM RE: HP 48GX Indefinite Loops - MNH - 04-02-2022, 02:15 PM RE: HP 48GX Indefinite Loops - DavidM - 03-28-2022, 04:11 AM RE: HP 48GX Indefinite Loops - Dave Britten - 03-28-2022, 06:13 PM RE: HP 48GX Indefinite Loops - Thomas Klemm - 03-28-2022, 07:13 PM RE: HP 48GX Indefinite Loops - DavidM - 03-29-2022, 12:30 PM RE: HP 48GX Indefinite Loops - MNH - 04-03-2022, 01:59 AM RE: HP 48GX Indefinite Loops - DavidM - 04-03-2022, 10:58 AM RE: HP 48GX Indefinite Loops - DavidM - 04-03-2022, 11:39 AM RE: HP 48GX Indefinite Loops - MNH - 04-03-2022, 05:39 PM RE: HP 48GX Indefinite Loops - ttw - 03-30-2022 01:02 AM RE: HP 48GX Indefinite Loops - Thomas Klemm - 04-03-2022, 02:39 AM RE: HP 48GX Indefinite Loops - Thomas Klemm - 04-03-2022, 03:09 AM RE: HP 48GX Indefinite Loops - MNH - 04-03-2022, 12:57 PM RE: HP 48GX Indefinite Loops - Thomas Klemm - 04-03-2022, 02:31 PM RE: HP 48GX Indefinite Loops - MNH - 04-03-2022, 04:25 PM

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