From: dberge@mx2.redestb.es
Newsgroups: comp.sys.hp48
Subject: EMENU -- Upgradeable Menus in Your Programs
Date: Fri, 31 Jul 1998 20:09:36 GMT
Organization: Deja News - The Leader in Internet Discussion
Lines: 111
Message-ID: <6pt8a0$d1s$1@nnrp1.dejanews.com>
NNTP-Posting-Host: 195.122.199.183
X-Article-Creation-Date: Fri Jul 31 20:09:36 1998 GMT
X-Http-User-Agent: Mozilla/3.01 (Win16; I)
Xref: republic.btigate.com comp.sys.hp48:14018

Hi,

  here's something that people who write libraries (especially those likely
to end up in a ROM card) may, hopefully, like.

   It's a short function that lets you build sort-of-'open architecture'
programs by enabling you to extend or modify a menu in a compiled application
without modyfing the application itself.

   In your application, instead of building your menus by calling TMENU (or
InitMenu), use this function, which I call EMENU. It's arguments are:

2: { list }
1: 'global.name'

'global.name' should contain a list, a program which evaluates to a list, or
any other object.

   So, for example, if your application has the following menu:

[ NEW  ] [ RCL  ] [ STO  ] [ DEL  ]

which you built by using something like:

\<< { NEW RCL STO DEL } TMENU \>>

you should use instead:

\<< { NEW RCL STO DEL } 'menuext' EMENU \>>

which will give the exact same result.

  If one day you choose to add a new function to your library, but don't want
/ can't re-edit, modify it, re-compile it and re-distribute it, you can
simply write the new function (which will generally be RAM-based) and add it
to the menu. Suppose that I wrote an EDIT function for the library in the
example, I'd distribute the following 'upgrade':

\<<
  \<< @ Edit Function \>> 'EDIT' STO
  { EDIT } 'menuext' STO
\>>

   Now my menu will look like:

[ NEW  ] [ RCL  ] [ STO  ] [ DEL  ] [ EDIT ]

   The program works, as you should see in the code, by appending the contents
of 'global.name' to the list in level 2. If 'global.name' contains something
other than a list, it will EVALuate the contents first. This feature adds more
flexibility and lets you not only append elements to the menu, but even modify
the menu itself. Here go a few examples:

\<< DATE TIME TSTR 1 3 SUB \>> 'menuext' STO

   Shows:

[ NEW  ] [ RCL  ] [ STO  ] [ DEL  ] [ FRI  ]

\<< REVLIST {} \>> 'menuext' STO

   Shows:

[ DEL  ] [ STO  ] [ RCL  ] [ NEW  ]


\<< OBJ\-> DROP 'EDIT'
4 ROLLD 5 \->LIST {} \>> 'menuext' STO

[ NEW  ] [ EDIT  ] [ RCL  ] [ STO  ] [ DEL  ]

  ( Note the {} in both programs. It's there because whatever there is in
'global.name', after evaluation, there must always be two objects in the
stack, which are then linked together by means of the User-RPl '+' command. )

   Well, I've been speaking too long already, here's the source (Jazz):

::
 CK2&Dispatch
 FIVESIX           ( list id )
 ::
  @                ( you may want to replace with RclHiddenVar )
  IT
  ::
   DUPTYPELIST?
   NOT
   IT
    EVAL
   x+
  ;
  xTMENU
 ;
;

( chksum: #58496d bytes: 40 )

   Here's the code in ASC form ( ASC-> is available at
<http://hp48.ml.org/utils/memory/asc.zip> )

%%HP: T(3)A(G)F(.);
"D9D20FDE8107C46D9D20B7970CB916D9D20112262FA30CB916E8F6076BA1B213
0D5112B2130B2130084E"

   Hope someone will appreciate its usefulness :)

Regards,
Diego Berge.
1998-07-31 19:52 UTC