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

Dynamic menu label tricks

132 views
Skip to first unread message

Travis Evans

unread,
Dec 26, 2012, 8:46:14 PM12/26/12
to
So last night I finally realized that the softkey menu was designed so
that instead of static strings or grobs for menu labels, you can use a
secondary starting with TakeOver that returns an object to be used as
the label. This immediately inspired me to try to (ab)use the menu
system and use it as a sort of additional custom "header" line. For
instance, the following object, compiled with MASD and stored to CST,
creates a custom menu with a label that displays the available RAM:

!RPL
{
{
::
TakeOver
GARBAGE MEM #800 #/ SWAPDROP
#>$ CHR_K >T$
MakeInvLabel
;
:: TakeOver DispMenu ;
}
}
@

It updates whenever the menu is redrawn (this seems to happen every time
the stack display is updated, so this particular application works quite
well). In this example, pressing the label also forces an immediate
update.

For displaying data that changes constantly (e.g., a clock), perhaps one
could abuse TOFF and STARTOFF to call DispMenu every few seconds of
inactivity or so. :-)

Probably not a new idea, but I thought it might be worth sharing.

--
Travis

Joe Horn

unread,
Dec 31, 2012, 5:45:37 PM12/31/12
to
Travis Evans wrote:
> So last night I finally realized that the softkey menu was designed so
> that instead of static strings or grobs for menu labels, you can use a
> secondary starting with TakeOver that returns an object to be used as
> the label.

Fun, huh? Another trick is to follow the TakeOver command with a string and a DROP. This has no effect on the operation or appearance of the key, but when you press right-shift down-cursor (to see the full names of the menu keys), the string you put after the TakeOver gets displayed! This lets you name your custom menu key whatever you want, even something totally different than what is displayed in the menu label.

The following example (a slightly modified version of CLKMENU on Goodies Disk #10) creates a "menu clock" which has 7 features:

(1) It displays the current time, updated when the menu line is updated (e.g. after every calculation).

(2) The menu label is in inverse video, which looks cool.

(3) Pressing it puts the current time, day of week, and date on the stack.

(4) Pressing it left-shifted performs ->TIME.

(5) Pressing it right-shifted performs ->DATE.

(6) Pressing right-shift down-cursor displays its name as "Time/Date".

(7) It works correctly regardless of the settings of flags -41 and -42 (12/24 mode and MDY/DMY mode).

As shown, it can be stored into 'CST' as-is. If included as one of several lists inside 'CST', then do 1 GET on it first, of course. The listing below is in HP50g MASD syntax.

{ { :: TakeOver "Time/Date" DROP
TOD TOD>t$ 41 SysITE
:: 2 6 SUB$ TOD ;
:: 1 5 SUB$ TOD %1- %12 %MOD %1+ ;
%10 %< IT :: 2 5 SUB$ ;
20 11 GROB 3A 8000051 MakeLabel ;
{ :: DATE TOD TIMESTR DUP
41 SysITE 15 14 LAST$ SWAP 1 12 SUB$ ;
xSETTIME xSETDATE } } }

HP 50g BYTES (when compiled): 193 #579Ch

-Joe-
0 new messages