Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

User Equation Library in User-RPL

109 views
Skip to first unread message

John H Meyers

unread,
May 29, 1998, 3:00:00 AM5/29/98
to

Here we go again:

o More features (well, is there anything now left out?)

o Uses more memory (ah, but you can delete anything you don't want :)

-----------------------------------------------------------
With best wishes from: John H Meyers <jhme...@mum.edu>
-----------------------------------------------------------

%%HP: T(3); @ Multi-level User Equation Library (HP48G/GX)
@ Contributed by John H Meyers. Version: 1998/05/28

@ Has features resembling the built-in Equation Library,
@ but allows you to supply the equations, etc.

@ This version adds units support, in that it allows you to supply
@ a list of initial values (including units) for all variables;
@ before starting the solver, it will use any such values
@ to create any variables which do not already exist.
@ You would normally supply zero values with units attached,
@ but you can also use this feature to supply any other constants
@ which the equation might utilize.

@ Also includes support for equation title and custom solver menus.

@ If you don't want some of the optional features, e.g. Vars, Pic, etc.,
@ you can delete their programs and custom menu entries, to save memory.

@ You may substitute a full-screen CHOOSE replacement, if you prefer.

@ The entire equation library presented here is a directory [e.g. EQLIB];
@ within this directory, you may create arbitrarily named subdirectories,
@ perhaps each pertaining to a separate topic, as in the built-in EQ LIB.

@ You may even create nested subdirectories, if you wish, or you may elect
@ to have no subdirectories (storing all equations in the main directory).

@ Within each subdirectory, you may create arbitrarily named equations;
@ names up to 14-15 characters will appear in full in the "choose" boxes
@ (longer names will fit if you use any full-screen CHOOSE replacement),
@ and may be mixed upper/lower case letters if you wish.

@ Press CST and then [Menu] or [Up^] to select topics and/or equations.
@ Press CST again, after selecting an equation, for all other features.

@ The correct solver is automatically selected for each equation or set.
@ Use right-shift VIEW to view multiple variable values at once.
@ See User's Guide Chapter 25 for other Multiple Equation Solver features.

@ A "custom" menu (invoked via the [CST] key) is provided,
@ resembling the built-in Equation Library menu:
@
@ [Solv] Re-start the solver, using the current equation (or set).
@ [EQN] Recall current equation (or set) to the stack.
@ [Vars] Display meanings of current equation's variables (optional).
@ [Pic ] Display current equation's picture, if any.
@ [Menu] List current subdirectories and/or equations ("choose" box).
@ [Up^] Up one level (and automatically display its menu).
@ ------ Press NXT for additional options -----------------
@ [MSOL] Restart M.E.S. without re-initializing.
@ [MSop] Toggle M.E.S. option for use of right-shift with var keys.
@ [Purg] Purge all extraneous variables created from solving equations
@ (purges only numeric and unit-valued variables, plus EQ & Mpar)
@ [CST] Invoke any custom menu found in the HOME directory.

@ Store this complete directory in HOME, perhaps named 'EQLIB'

DIR @ Directory: name <object> name <object> ...

Sample @ Sample sub-directory of equations:
DIR
@ Deeper sub-directories are permitted, if desired.
Trip 'Dist=Rate*Time' @ Uses standard solver
Lamp { 'V=I*R' 'W=V^2/R' } @ Uses Multiple-Equation solver
Prog \<< P Q * 1 - \>> @ Programs may be used as equations
Stop { } @ Stops menu listing when encountered
@ Optional units for Trip:
TripINIT { 0_mi Dist 0_mph Rate 0_h Time } @ Value VarName ...
@ Optional units for Lamp:
LampINIT { 0_V V 0_W W 0_A I 0_\GW R } @ Special char. for Ohms
@ Optional variable descriptions for Lamp:
LampVARS { "V: Voltage" "W: Wattage" "I: Current" "R: Resistance" }
@ Optional Multi-equation title and menu labels:
LampMITM { "Lamp" { V W "" I R } }
@ An optional picture may also be stored in LampPICT, etc.
END

Set2 DIR END @ Second sub-directory, etc.

@ If you use a variable hider, you may hide the remaining variables:

Stop { } @ Stops menu listing in this directory (even without hider).

Solv @ [Re]start the solver, using the most recent equation (or set):
\<< RCEQ DROP IFERR MINIT Mitm THEN 30 MENU ELSE MSOLVR END Init \>>
@ Remove 'Init' and 'Mitm' if you delete the corresponding programs.

Vars @ Display current equation's variable descriptions, if provided:
@ (info list for equation 'xxx' must be stored in 'xxxVARS')
\<< RCEQ DROP 'EQ' RCL DUP "" + "'" ROT + "VARS" + OBJ\->
DUP VTYPE 5 == @ Is it a list?
{ RCL 1 CHOOSE { DROP } IFT } @ Display the list
{ DROP2 "No Info" DOERR } IFTE \>> @ No list provided

Pic @ Display current equation's picture, if any
@ (picture for equation 'xxx' must be stored in 'xxxPICT')
\<< RCEQ DROP "'" 'EQ' RCL + PICT + OBJ\->
DUP VTYPE 11 == @ Is it a grob?
{ RCL \->LCD 3 FREEZE } @ Or: { RCL PICT STO { } PVIEW }
{ DROP "No Pic" DOERR } IFTE \>> @ No picture provided

Menu @ Catalog of directories and/or equations to choose from
@ (added optional 'name' argument for initial item selection)
\<< DEPTH { DUP TYPE 6 \=/ } 1 IFTE @ Current DIR or EQ name
{ IFERR RCEQ DROP ::EQ RCL THEN 0 END } IFT @ (if any)
PATH DUP SIZE GET "" + { 5 8 9 15 } TVARS @ Added lines above
'Stop' DUP2 + SWAP POS 1 - 1 SWAP SUB @ Stop at 'Stop' variable
IF DUP SIZE THEN ROT OVER SWAP POS 1 MAX CHOOSE @ Was: THEN 1 CHOOSE
{ DUP VTYPE 15 == { EVAL Menu } { STEQ Solv } IFTE } IFT
ELSE DROP2 DROP "No Items" DOERR END \>> @ Added DROP

Purg @ Purge all extraneous variables created from solving equations
@ (purges only numeric and unit-valued variables, plus EQ & Mpar)
\<< { 0 13 } TVARS { EQ Mpar } + PURGE \>>

Init @ Initialize equation variables, if a list is provided
@ (init list for equation 'xxx' must be stored in 'xxxINIT')
\<< RCEQ DROP "'" 'EQ' RCL + "INIT" + OBJ\->
DUP VTYPE 5 == @ Is it a list?
{ RCL 2 :: \<< DUP TYPE 6 == @ Only for non-existent variables
{ DUP #185C7h SYSEVAL VTYPE 0 < { DUP2 STO } IFT } IFT
@ SysRPL "DoHere:" [supported] ensures var is in current dir
DROP2 \>> DOSUBS } { DROP } IFTE \>>

Mitm @ Optional title and menu labels for Multiple Equation Solver
@ (MITM arg list for equation 'xxx' must be stored in 'xxxMITM')
@ See User's Guide Ch. 18 to customize single-equation SOLVR menu.
\<< RCEQ DROP "'" 'EQ' RCL + "MITM" + OBJ\->
DUP VTYPE 5 == @ Is it a list?
{ RCL OBJ\-> DROP MITM } { DROP } IFTE \>>

CST @ Indirect pointer, protects CSTM from accidental MENU command.
CSTM

CSTM @ Custom menu for User Equation Library (Use it!)

{ @ Protect programs from being stored into:

{ Solv \<< Solv \>> } @ Solver

{ EQN RCEQ } @ Recall current equation

{ Vars \<< Vars \>> } @ Optional variable descriptions

{ Pic \<< Pic \>> } @ Optional picture

{ Menu \<< Menu \>> } @ Choose directory and/or equation

@ Up one level (inserted PATH DUP SIZE GET for 'Menu' argument)
{ \|^ \<< PATH SIZE 2 > { PATH DUP SIZE GET UPDIR } IFT Menu \>> }
@ Adjust the constant if this directory is at a lower level
@ (to prevent going above the main directory level).

@ ---- Next page (six labels) of CST menu ----

MSOLVR @ Restart multiple equation solver without re-initializing

@ With flag 63 clear, right-shift 'var' recalls variable.
@ With flag 63 set, right-shift 'var' toggles MUSER/MCALC state.
{ MSopt \<< 63 DUP IF FS? THEN CF ELSE SF END MSOLVR \>> }

{ } @ Blank key

{ Purg \<< Purg 1 MENU \>> } @ Purge extraneous variables

{ } @ Blank key

@ An optional feature, used by the author:
{ CST \<< { HOME CSTM } RCL TMENU \>> } @ Display CST[M] from HOME

} @ End of custom menu CSTM

END @ Directory ends.

Peter Karp

unread,
Jun 2, 1998, 3:00:00 AM6/2/98
to

Hi to all!
Just a question. Has someone tried this
> Multi-level User Equation Library (HP48G/GX)
> Contributed by John H Meyers. Version: 1998/05/28 ???
It

>@ Has features resembling the built-in Equation Library,
>@ but allows you to supply the equations, etc.
I did! And I really like it very much. I have tried most of the other
EQ managers .. EQ librarys and so on, but personally did not like
them, because they forced me to store the EQ's in a specific form
and/or the EQ's could not be accessed without that specific program.
But this great User Equation Library by John is small, highly
integrated and fully customizable (because it's in User-RPL). Even I,
who are not very experienced with User RPL are able to change, add or
delete parts of the program! It's really great.
By the way John has posted some very usefull tools and programs! Thank
you John!
Do you like that program too?
I am looking forward to hear from, and sure John does also!

P.S.: For the ones who can not see the original thread (containing
this great program: You can find it at DejaNews. 1998/05/29 subject:
User Equation Library in User-RPL
Maybe someday we can encourage John to collect all his programs in
*John's User RPL program collection* and to put it to the HP48
Software Archive and/or to the Goodies Disks (if Joe likes them too),
so it will be easier to find Johns excellent programs! :-)

Greetings from Cologne
Peter
________________________________
Newbies: Do you know the great Frequently Asked Questions?
http://www.engr.uvic.ca/~aschoorl/faq/
and the superb HP48 Software Archive?
http://hp48.ml.org
to look for *old* HP48 postings see
http://search.dejanews.com/filter.xp?groups=comp.sys.hp48

joe...@usa.net

unread,
Jun 2, 1998, 3:00:00 AM6/2/98
to

Peter Karp wrote:
>
> Maybe someday we can encourage John to collect all his programs in
> *John's User RPL program collection* and to put it to the HP48
> Software Archive and/or to the Goodies Disks (if Joe likes them too),
> so it will be easier to find Johns excellent programs! :-)

Excellent idea! I asked John Meyers a long time ago if he'd mind
me making a collection of his stuff, but when I started I was
overwhelmed by the sheer bulk of it! He's more prolific than
Isaac Asimov was!

Eric Richlin's HP48 Archive website < http://hp48.ml.org/ > has a
special section for "Compilations". C'mon, John, make a few new
sets of "goodies" containing all your own favorite stuff! Deja News
is nice and all, but fast & easy & organized access to your great
stuff would be a great benefit to the entire user community. We
all know that you have copious free time that you don't know what
to do with. ;-)

-Joe-

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading

HPS...@my-dejanews.com

unread,
Jun 2, 1998, 3:00:00 AM6/2/98
to

In article <6l1c4r$1r9$1...@nnrp1.dejanews.com>,

joe...@usa.net wrote:
>
> Peter Karp wrote:
> >
> > Maybe someday we can encourage John to collect all his programs in
> > *John's User RPL program collection* and to put it to the HP48
> > Software Archive and/or to the Goodies Disks (if Joe likes them too),
> > so it will be easier to find Johns excellent programs! :-)
>
> Excellent idea! I asked John Meyers a long time ago if he'd mind
> me making a collection of his stuff, but when I started I was
> overwhelmed by the sheer bulk of it! He's more prolific than
> Isaac Asimov was!
>
> Eric Richlin's HP48 Archive website < http://hp48.ml.org/ > has a
> special section for "Compilations". C'mon, John, make a few new
> sets of "goodies" containing all your own favorite stuff! Deja News
> is nice and all, but fast & easy & organized access to your great
> stuff would be a great benefit to the entire user community. We
> all know that you have copious free time that you don't know what
> to do with. ;-)

And as soon as you get this project done, please inform me at:
hdu...@junix.ju.edu so I can add to the USER-RPL programming section of my
HP48 page at http://users.ju.edu/~hduong/hp48

Han

John H Meyers

unread,
Jun 3, 1998, 3:00:00 AM6/3/98
to

Here's an optional added bit of sophistication which mimics the
lesser-known behaviors of the built-in G/GX Equation Library;
of course, churning out more complex logic spoils the goal
of keeping everything extremely simple, but even Einstein said
"Everything should be as simple as possible -- but no simpler :)"

I can't help having the nagging feeling that there should exist an
unnamed library function already in the G/GX which can do this for us
without our having to bother; however, I haven't found it yet,
so here's a pure User-RPL solution to the problem:

%%HP: T(3); @ Re: Multi-level User Equation Library (HP48G/GX)

@ The following is a more complex optional replacement for the 'Init'
@ function (needed only if you want to pre-assign units to variables)
@ contained in the previously-posted User Equation Library directory.

@ Our original version never adjusted pre-existing variables;
@ this version (as well as the built-in Equation Library)
@ adjusts units as necessary in any pre-existing variables
@ which currently contain real or unit objects, but only if
@ the units needed by the new equation are incompatible.

@ This avoids errors caused by variables left-over from a previous
@ equation which have the same name but different meaning and units
@ in a new equation, or were not originally stored with any units.

@ Optionally replace the 'Init' program with the following:

@ Initialize equation variables, if a list is provided
@ (init list for equation 'xxx' must be stored in 'xxxINIT')
\<< RCEQ DROP "'" 'EQ' RCL + "INIT" + OBJ\->
DUP VTYPE 5 == @ Is it a list?

{ RCL 2 :: \<< DUP TYPE 6 == @ Value1 Name1, Value2 Name2, ...
{ DUP #185C7h SYSEVAL VTYPE 0 < { DUP2 STO } @ New variable.
@ Was:{ DUP #185C7h SYSEVAL VTYPE 0 < { DUP2 STO } IFT } IFT
@ SysRPL "DoHere:" [supported] ensures var is in current dir.
{ @ Additional new logic [ adds 110 bytes ]:
{ 0 13 } OVER VTYPE POS @ Examine existing real/unit var.
{ OVER UBASE 0 * OVER RCL UBASE 0 * SAME NOT @ Compatible?
{ DUP2 RCL UVAL SWAP @ Existing value, default units
DUP TYPE { \->UNIT } { DROP } IFTE @ Unit vs. Real
OVER STO @ Replace existing variable
} IFT @ Compatible
} IFT @ Existing Real/Unit
} IFTE @ VType 0 <
} IFT @ Type 6 ==
DROP2 \>> DOSUBS } { DROP } IFTE \>> @ [ Original last line ]

John H Meyers

unread,
Jun 3, 1998, 3:00:00 AM6/3/98
to

In article <6l1c4r$1r9$1...@nnrp1.dejanews.com>, joe...@usa.net writes:

> He's more prolific than Isaac Asimov!

Easy to do, from the advantageous position of remaining alive :)
[which is about the same way the fabled Tortoise once beat the Hare]

Anyway, the last time I tried browsing at
<http://www.dejanews.com/home_ps.shtml>
and entered "jhmeyers*" into the "Author(s)" field,
I still seemed to be the only one using said user name.

Since said search engine is quite able to locate articles by
title words and/or content words (exactly how I do it myself :)
it would seem that the tough job of making that archive has
already been done by these folks, so why shouldn't I just
stay in my lounge chair and watch the corn grow?

Anyway, all you need for prodigious results in answering HP48 questions
is an AUR, a FAQ, a set of Goodies Disks, a book or two by Donnelly
and/or Wickes, some Hack and Jazz libraries, and the previous postings
of all the giants upon whose shoulders any newbie may now stand :)

It's also fortuitous that some folks like to develop the substantial
software projects which make the HP48 a contender against TI etc.,
and not just small User-RPL programs for inconsequential tasks :)

There also were once teams at HP which developed some things that have
been a little bit useful, long-lasting, and perhaps even inspiring,
in the midst of a world filled with so many lesser products.

huy...@my-dejanews.com

unread,
Jun 3, 1998, 3:00:00 AM6/3/98
to

In article <6l2sl2$rj2$1...@news.iastate.edu>,
jhme...@miu.edu wrote:
[snip]

> DUP TYPE { \->UNIT } { DROP } IFTE @ Unit vs. Real

The exception to the rule:
IF DUP TYPE
THEN \->UNIT
ELSE DROP
END
is actually 5 nibs shorter!
This is nitpicking, of course...

John H Meyers

unread,
Jun 4, 1998, 3:00:00 AM6/4/98
to

In article <6l3c25$sj9$1...@nnrp1.dejanews.com>,
huy...@my-dejanews.com writes:

jhm: DUP TYPE { \->UNIT } { DROP } IFTE @ Unit vs. Real

> IF DUP TYPE THEN \->UNIT ELSE DROP END

> is actually 5 nibs [2.5 bytes] shorter!

If it were not for the fact that this program fragment appears
within a list, it would be so; however, when the above alternative
choices appear within a list, the former is shorter than the latter,
because the command-line User-RPL compiler then embeds the IF ... END
structure within a "secondary" (a program), which tips the balance
in the other direction! I don't doubt that some other opportunities
to shorten the program (bytes-wise or execution-time wise) do exist,
however -- I think I even know of one myself, but I'll keep mum
about it, since sometimes I go for better readability,
even at the expense of five bytes or so :)

HPS...@my-dejanews.com

unread,
Jun 6, 1998, 3:00:00 AM6/6/98
to

In article <6l6k5a$fat$1...@news.iastate.edu>,

jhme...@miu.edu wrote:
>
> In article <6l3c25$sj9$1...@nnrp1.dejanews.com>,
> huy...@my-dejanews.com writes:
>
> jhm: DUP TYPE { \->UNIT } { DROP } IFTE @ Unit vs. Real
>
> > IF DUP TYPE THEN \->UNIT ELSE DROP END
> > is actually 5 nibs [2.5 bytes] shorter!
>
> If it were not for the fact that this program fragment appears
> within a list, it would be so; however, when the above alternative
> choices appear within a list, the former is shorter than the latter,
> because the command-line User-RPL compiler then embeds the IF ... END
> structure within a "secondary" (a program), which tips the balance
> in the other direction! I don't doubt that some other opportunities
> to shorten the program (bytes-wise or execution-time wise) do exist,
> however -- I think I even know of one myself, but I'll keep mum
> about it, since sometimes I go for better readability,
> even at the expense of five bytes or so :)

>
> -----------------------------------------------------------
> With best wishes from: John H Meyers <jhme...@mum.edu>
>

Well, if anyone cares to drop an extra 0.5 byte off the fragment given by:
IF DUP TYPE THEN \->UNIT ELSE DROP END then try the following:
DUP TYPE ::\->UNIT ::DROP IFTE This uses null tags; I call it the
USR-RPL version of ' (tic mark in SYS-RPL).

Regards,
Han Duong, hdu...@junix.ju.edu

0 new messages