From: jhmeyers@miu.edu (John H Meyers)
Newsgroups: comp.sys.hp48
Subject: Re: Units conversion aids
Date: 17 Oct 1998 20:50:22 GMT
Organization: MIU Computer Services,  Fairfield, IA 52557.  Not Approved.
Lines: 106
Message-ID: <70avue$78n$1@news.iastate.edu>
References: <7044d3$ga1$1@news.iastate.edu>
Reply-To: jhmeyers@miu.edu
NNTP-Posting-Host: vax1.mum.edu
Xref: republic.btigate.com comp.sys.hp48:17438

How about a replacement for the entire units menu system,
with menus you choose yourself, instead of what HP chose for you?

This sounds like something probably done before somewhere,
but Eric's CD may not yet be full, so here goes :)

You get a main units menu, as in the HP48, with as many
sub-menus as you wish, plus an additional program
which goes immediately to a menu of units you
can convert to, given any existing unit object.

Note that you can tailor this for either minimum memory
or maximum speed, as explained further in the listing.

The only thing this has failed to convert thus far
is unit trusts, but I'm working on it :)

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

Assume standard cautions re SYSEVAL (backup memory, verify program)

%%HP: T(3); @ Custom units menus and conversion system:

@ Replacing the functionality of the built-in units system, you may
@ create a set of customized menus for your own selected units;
@ units having no built-in menu or conversions may also be included
@ (see Acceleration, below).

@ A "master" menu listing all of the above menus may be created,
@ similar to the built-in right-shift Units menu.

@ Given any unit object on the stack, the custom menu
@ for the appropriate group may be immediately displayed,
@ allowing you to choose any desired conversion.

DIR @ Directory:  DIR  name1 obj1  name2 obj2  ...  END

  @ The first two programs may be assigned to shifted UNITS keys:
  @ 'Units' 74.3 ASN  'Ucnv' 74.2 ASN

  Units @ Display a "master" menu, like right-shift Units
    \<< 'Umnus' RCL 1 \<< "" + #3A3ECh SYSEVAL @ MakeDirLabel
      NSUB 'Umny' #4003h SYSEVAL #5445h SYSEVAL 2 \->LIST @ #2 ::N
      \>> DOSUBS Umnz TMENU \>>

  Ucnv @ Go immediately to menu for type of unit object on stack
    \<< DUP UBASE DUP UVAL / \->STR 4 OVER SIZE 1 - SUB
      'Ugrps' RCL 1 \<< IF DUP2 SWAP POS THEN
      Umnx ELSE DROP END \>> DOSUBS DROP \>>

  @ To enable 'Ucnv' to work properly, each menu group below
  @ should contain an entry for the UBASE units for each of its
  @ members (append it to the list if not already included):

  Ugrps @ To be customized by the user:
    { @ Lists of units (expressed as strings)
      { "mm" "cm" "in" "m" "ft" "?" "km" "mi" } @ Length (w/placeholder)
      { "cm^2" "in^2" "ft^2" "m^2" } @ Area
      { "ml" "in^3" "ozfl" "l" "gal" "m^3" "cu" "qt" } @ Volume
      { "ft/s" "m/s" "cm/s" "mph" "kph" } @ Speed
      { "ft/s^2" "m/s^2" "ga" } @ Acceleration (not built-in)
      { "g" "kg" "oz" "lb" "grain" } @ Mass
      { "W" "hp" "kg*m^2/s^3" } @ Power (with its UBASE unit)
      { "\^oF" "\^oC" "K" } @ Temperature
      { "s" "min" "h" "1/s" "1/min" "1/hr" "Hz" } @ Time (with extras)
      { "fc" "lx" "lam" "flam" "cd" "c" "cd/m^2" "cd*sr/m^2" } @ Light
      { "\^o" "r" "grad" } @ Angle
      @ Etc.
    }

  Umnus @ Must correspond to above groups list, in sequence
    { Leng Area Vol Speed Accel Mass Powr Temp Time Light Angle }

  Umnx @ Expand a list of strings into a units menu
      \<< 1 \<< "1_" SWAP + OBJ\-> \>> DOSUBS Umnz TMENU \>>

  @ Special note:

  @ The menus can be made much faster, at the expense of
  @ making the 'Ugrps' lists much larger,
  @ and 'Ucnv' slightly slower, as follows:

  @ Change 'Ugrps' to lists of actual unit objects instead of strings

  @ Shorten 'Umnx' to \<< Umnz TMENU \>>

  @ Change the first line of 'Ucnv' to:
  @ \<< DUP UBASE DUP UVAL / \->STR OBJ\->
  @ ( \->STR OBJ\-> is necessary to restructure the results of UBASE )

  Umny @ Select and expand one units list from all groups
    \<< 'Ugrps' RCL SWAP GET Umnx \>>

  Umnz @ Append to each menu a label for the "LastMenu" function
       @ (to return to the last previous menu);
       @ this may make the menus easier to use and navigate.
    \<< 158 CHR #3A3ECh SYSEVAL @ MakeDirLabel [Square box char]
      \<< 0 MENU \>> 2 \->LIST 1 \->LIST + \>>

  @ S/SX: Get DOSUBS from:
  @ <http://www.dejanews.com/getdoc.xp?AN=318142735&fmt=raw>

END @ End of directory
