HP Forums
How Drawmenu work's? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: How Drawmenu work's? (/thread-7163.html)



How Drawmenu work's? - fabio.hdl - 11-03-2016 05:02 PM

First of all Hello to everybody, i'm new in this forum!
If i'm posting this in the wrong place, since here is my apology.

Well, i'm having some trouble with HP PPL, more especifically with DRAWMENU command, i want to know how i handle with it, I managed to draw the menu but i don't know how to interact with it.
My question is, do the HP PPL have a command to menu events? Like ISKEYDOWN();?
Or i'll have to make a MOUSE event to know the coordenate of the menu?

Again, i'm sorry if this question has already been answered, like i said i'm new here!


RE: How Drawmenu work's? - Han - 11-03-2016 06:41 PM

It's only a drawing routine. You would have to build your own key handler and interface.

Old and extremely simple example: http://www.hpmuseum.org/forum/thread-315.html

Just look at the main loop for an example of how to trap screen touches.


RE: How Drawmenu work's? - Tyann - 11-03-2016 07:02 PM

Bonjour

Juste une petite idée, d'amélioration pour une prochaine version.
Gérer ces touches de fonctions avec Getkey ou/et ISKEYDOWN
Bonne idée ou pas ?


Hello

Just an idea, improvement for a future release.
Manage these function keys with Getkey and/or ISKEYDOWN
Good idea or not ?


RE: How Drawmenu work's? - StephenG1CMZ - 11-03-2016 08:58 PM

(11-03-2016 07:02 PM)Tyann Wrote:  Bonjour

Juste une petite idée, d'amélioration pour une prochaine version.
Gérer ces touches de fonctions avec Getkey ou/et ISKEYDOWN
Bonne idée ou pas ?


Hello

Just an idea, improvement for a future release.
Manage these function keys with Getkey and/or ISKEYDOWN
Good idea or not ?

Bonne idee

Checking for a button is much clearer than checking mouse pixels coordinates.

I have previously suggested
iF button(1)
Or
If button("Edit") (or whatever your buttons are called)

But including it within iskeydown would be ok too.

Also useful would be a way of erasing the Drawmenu when you have finished with it:
DRAWMENU({}); instead gives 6 empty buttons.


RE: How Drawmenu work's? - toml_12953 - 11-04-2016 02:28 PM

(11-03-2016 07:02 PM)Tyann Wrote:  Bonjour

Juste une petite idée, d'amélioration pour une prochaine version.
Gérer ces touches de fonctions avec Getkey ou/et ISKEYDOWN
Bonne idée ou pas ?


Hello

Just an idea, improvement for a future release.
Manage these function keys with Getkey and/or ISKEYDOWN
Good idea or not ?

Easter! (Bunny Day - Bonne idée)

Tom L


RE: How Drawmenu work's? - fabio.hdl - 11-05-2016 08:22 PM

(11-03-2016 07:02 PM)Tyann Wrote:  Bonjour

Juste une petite idée, d'amélioration pour une prochaine version.
Gérer ces touches de fonctions avec Getkey ou/et ISKEYDOWN
Bonne idée ou pas ?


Hello

Just an idea, improvement for a future release.
Manage these function keys with Getkey and/or ISKEYDOWN
Good idea or not ?

Yes, it would be much easier handle that with this commands!

And thanks to Han for giving this tip!


RE: How Drawmenu work's? - primer - 11-11-2016 07:31 PM

(11-03-2016 06:41 PM)Han Wrote:  It's only a drawing routine. You would have to build your own key handler and interface.

Hi,
I just published a lib I made to handle events.
Please take a look and download my LibMenu.

By the way,
I made a small program example to show how to do [attachment=4137]
This example does require LibMenu, don't forget to install it.


hope it can help you.


RE: How Drawmenu work's? - compsystems - 11-12-2016 01:36 AM

+1 Good program

suggestions
1: on the libMenu directory, please write a subroutine to exit the menu
2: A single argument for input as array,

PHP Code:
{
  { 
"name menu 1" "prg menu 1"}
  { 
"name menu 2" "prg menu 2"}
  { 
"name menu 3" "prg menu 3"}
  { 
"name menu 4" "prg menu 4"}
  { 
"name menu 5" "prg menu 5"}
  { 
"name menu 6" "prg menu 6"}


"prg menu x" -> Path of the directory or program ([dirName.]prg([args]) ), If the sublist is empty, black menu (off)

sample
PHP Code:
{
  {
"abc","tstLibM.f1()"}
  {
"menu2","tstLibM.f2()"}
  {}
  {
"nothing"}
  {}
 {
"menu6","abs(-3)"}


3: Please comment on each line, to learn how the event captures
// to manage events, trigger actions
PHP Code:
EXPORT events()
BEGIN
  
IF MOUSE(1)<200 //
  
THEN RETURN; 
  
END;
  
LOCAL m:=1+FLOOR(MOUSE(2)/53); //
  
callit(a(m));
END


PHP Code:
callit(F)
BEGIN
  
IF F=="" THEN  // If there is not program, nop
  
RETURN; 
  
END;
  
EXPR(F); // Evaluates the program.
  
draw(); // Put the menu
END



RE: How Drawmenu work's? - StephenG1CMZ - 11-12-2016 08:23 AM

Primer: Great program, I think*.

An obvious improvement in functionality would be to also handle long-clicks, so the user can call two functions from one button, or maybe one function with a mouse-click-type parameter.(Or can it do that already?)

Another possibility might be to also handle button events on the main screen, as well as on the bottom row...either by repeating the existing row, or having the user define more buttons.

*I haven't used it yet: Android doesnt know what a .hpprgm is, so will not open it for cutting and pasting.


RE: How Drawmenu work's? - primer - 11-12-2016 10:41 AM

Thank you for your comments,

(11-12-2016 01:36 AM)compsystems Wrote:  suggestions
1: on the libMenu directory, please write a subroutine to exit the menu
sorry, I don't understand, can you exaplin what you want ?

(11-12-2016 01:36 AM)compsystems Wrote:  2: A single argument for input as array,
I make that choice to allow user to modify menu entries on the fly :
you can update a menu entry in the WHILE loop without the need to redefine all.
also it provide much more flexibility (see below about toggle feature)

In general, for this kind of lib, I prefer to have more a kind of "oriented object" process => several methods. (even if it's not a class)
IMO, hppl does not provide enough flexibility to create a nice "procedural" oriented process (missing optional function argument).

(11-12-2016 01:36 AM)compsystems Wrote:  3: Please comment on each line, to learn how the event captures
This lib have been made on calc itself, hence not a lot of text,
but yes, good idea, next version will have more comment.
but as it is now, it's not very difficult to follow yet.

(11-12-2016 08:23 AM)StephenG1CMZ Wrote:  An obvious improvement in functionality would be to also handle long-clicks, so the user can call two functions from one button
yes, that's an idea... not for the comming version but one of the next.

(11-12-2016 08:23 AM)StephenG1CMZ Wrote:  Another possibility might be to also handle button events on the main screen, as well as on the bottom row...either by repeating the existing row, or having the user define more buttons.
I already coded something like that : user can have more than 6 entries.
in that case the 6th is "next", by pressing "next" libMenu show you the next 5 entries.

for your info, on version 2, I am working on a toggle feature.
this will allow user to define entries like that
Code:
LibMenu.entry(3,"caption","function()"); // example of usual menu entry
LibMenu.toggle(4,"caption",0); // user can toggle from false(0) to true(1)
...
LibMenu.gettoggle(4); // return the toggle state, 0 or 1

if you have other ideas, you are welcomed.

Regards,
primer.


RE: How Drawmenu work's? - compsystems - 11-12-2016 02:53 PM

(11-12-2016 01:36 AM)compsystems Wrote:  suggestions
1: on the libMenu directory, please write a subroutine to exit the menu
sorry, I don't understand, can you exaplin what you want ?

To exit the menu, you have to press the [on] key, then "Program interrupted" =(
A function is required to exit
entry(6,"exit","tstLibM.exitMenu()");

There is a problem, when the menu is on the terminal view. The menu is not updated
PHP Code:
EXPORT LibMenuTest()
BEGIN
    
print();
    print(
"test menu on terminal view"); freeze;
    
LibMenu.reset();
    
entry(1,"print1","tstLibM.f1()");
    
entry(2,"print2","tstLibM.f2()");
    
entry(3,"print3","tstLibM.f3()");
    
entry(6,"exit","tstLibM.exitMenu()");
    
    
LibMenu.draw();
    WHILE 
DO
        
LibMenu.events();
    
END;
END;

f1()
BEGIN
    
print("expr1: a/b"); wait;
END;

f2()
BEGIN
    
print("expr2: x^2"); wait;
END;

f3()
BEGIN
    
print("expr3: abs(-x)"); wait;
END;


exitMenu()
begin
    
return 0;
end

PHP Code:
callit(F)
BEGIN
  
IF F=="" THEN RETURN; END;
  
draw();
  
EXPR(F);
  
draw();
END



RE: How Drawmenu work's? - primer - 11-12-2016 08:36 PM

(11-12-2016 02:53 PM)compsystems Wrote:  To exit the menu, you have to press the [on] key, then "Program interrupted" =(
ho.. I see what you mean. but it's not to "exit the menu", it's to exit the WHILE loop, wich is not part of the lib itself.
I'm sorry, but it's a misunderstanding of the purpose of LibMenu.
The WHILE loop is on the side of the program developer (you), nothing is implemented in LibMenu for that.

You have to build your own loop, it's up to you to decide how user can quit (on ESC key press or else ?) I can't do that choice for you : it's your program.

There are many way to handle that.
For example :
Code:
local stay:=1;
EXPORT quit()
BEGIN
 stay:=0; // you will quit nicely the WHILE loop
END;

EXPORT MainProgr()
BEGIN
...
LibMenu.entry(6,"exit","quit()");
...
WHILE stay DO
 LibMenu.events();
END;

As it is, LibMenu does not stop program execution, then I can't propose a way to "exit the menu" as you asked.
Why did I make that choice : to let more freedom to people that use LibMenu, their program are not waiting for user interaction, program continue to run, it can be helpfull for a game for example...


(11-12-2016 02:53 PM)compsystems Wrote:  There is a problem, when the menu is on the terminal view. The menu is not updated

It's not a problem of the lib, but a problem of the program that use it.
Your program perform a wait() just after a print() : you are displaying the terminal and stop program execution, what did you expect ? Wink

I provided you in that lib a method to refresh your menu : LibMenu.draw().
Feel feel to place a LibMenu.draw() just before your wait().

Every time you clean the screen, it's up to you to redraw the menu.


RE: How Drawmenu work's? - compsystems - 11-12-2016 09:05 PM

ok Quit function works fine, a delay is required, so the menu does not print n times.

PHP Code:
callit(F)
BEGIN
  
IF F=="" THEN RETURN; END;
  
EXPR(F);
  
draw();
  
wait(0.2);
END

But unfortunately there is not function to return to the terminal view =(, I hope that some developer will incorporate a function to goto the terminal view (terminalView(); ), also it requires a vertical AutoScroll, otherwise the terminal view is not useful After the first screen. Do you agree with this?

please test Menu5 [choose] and menu4 [printScroll] n times
PHP Code:
//PHP for highlight
#pragma mode( separator(.,;) integer(h32) )
local stay;
EXPORT LibMenuTest()
BEGIN
  stay
:=1;
  print();
  print(
"test menu on terminal view"); freeze;
  
LibMenu.reset();
  
entry(1,"print1","tstLibM.f1()");
  
entry(2,"print2","tstLibM.f2()");
  
entry(3,"print3","tstLibM.f3()");
  
entry(4,"printScroll","tstLibM.f4()");
  
entry(5,"choose","tstLibM.f5()");
  
entry(6,"exit","tstLibM.quit()");
  
LibMenu.draw();
  WHILE 
stay DO
   
LibMenu.events();
  
END;
  return 
"Done";
END;

f1()
BEGIN
  
print("expr1: a/b"); LibMenu.draw(); 
END;

f2()
BEGIN
  
print("expr2: x^2"); LibMenu.draw(); 
END;

f3()
BEGIN
  
print("expr3: abs(-x)"); LibMenu.draw();
END;

f4()
BEGIN
  
print("string: 1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz123​4567890abcdefghijklmnopqrstuvwxyz"); LibMenu.draw();
END;

f5()
BEGIN
 MSGBOX
("popup dialog box"); // terminalView();
 
LibMenu.draw();
END;

EXPORT quit()
BEGIN
 stay
:=0// you will quit nicely the WHILE loop
END



RE: How Drawmenu work's? - primer - 11-12-2016 10:04 PM

(11-12-2016 09:05 PM)compsystems Wrote:  But unfortunately there is not function to return to the terminal view =(, I hope that some developer will incorporate a function to goto the terminal view (terminalView(); ), also it requires a vertical AutoScroll, otherwise the terminal view is not useful After the first screen. Do you agree with this?
Whatever I agree or not, it's not my concern about LibMenu. And it's not the original topic anymore...

Ok, when you choose to use terminal in your program, you have to know the limit of it. and to find how to deal with that.
BTW, please note that there is another way to display things on screen : graphics (TEXTOUT), then your program can control scroll.

Ok, lets come back to terminal limitations :
(11-12-2016 09:05 PM)compsystems Wrote:  But unfortunately there is not function to return to the terminal view =(
Yes, there is one : PRINT(""); but it add a new (empty) line.

(11-12-2016 09:05 PM)compsystems Wrote:  also it requires a vertical AutoScroll
When program ends, it allow user to scroll.
But yes, the program cannot control itself the terminal scroll.
As I know that limitation, I can stop spaming the terminal after 12 lines, place a wait and clean the terminal.
Ok, it's far from perfect...

BTW, you can create your own print function that do it for you :
untested :
Code:
local n:=0; // number of printed lines
EXPORT MyPRINT(x) // use that function instead of PRINT
BEGIN
n:=n+1;
PRINT(x);
if n==12 then 
 print"<press any key to continue>";
 wait();
 print(); // clean the terminal
 n:=0;
end;
END;
You place all of that into a new program, name it "compsystemSuperLib",
and voilà, you built a lib that enhance your Terminal experiance Wink


RE: How Drawmenu work's? - compsystems - 11-14-2016 04:03 AM

Thanks Primer

is a good idea to program a real terminal view, Who helps me to port my "real terminal view for hp50" to hpprime language?

More info
http://www.hpmuseum.org/forum/thread-7048.html


RE: How Drawmenu work's? - StephenG1CMZ - 11-14-2016 09:03 AM

(11-14-2016 04:03 AM)compsystems Wrote:  Thanks Primer

is a good idea to program a real terminal view, Who helps me to port my "real terminal view for hp50" to hpprime language?

More info
http://www.hpmuseum.org/forum/thread-7048.html

[Image: TerminalWindow_RPL_HP50_image01.png]

Compsystems, You might this program useful, or help there: Terminal alternative program
http://www.hpmuseum.org/forum/thread-2667.html


RE: How Drawmenu work's? - ggauny@live.fr - 01-25-2017 12:11 PM

Hi,

@ PRIMER, I encounters some problems. LibMenu is into my PRIME but when run : "!", but when I ask VERIFY Prime say : no problem ?

May you explain me what I wrong please ?

Thanks.


RE: How Drawmenu work's? - ggauny@live.fr - 01-25-2017 05:06 PM

Hi,

In this context, I reproduce a part of program that show us writting good
soft boutons with a second level of soft boutons. It is a way to use a "NEXT" "PREV" bouton as on HP 50 for exemple.

Reproduced with permission.

Code:


 EXPORT DTM1()
BEGIN
// DFX Main Menu
// WMWK 2014-09-19

  LOCAL m,m1,mx,my,N→Ja,dd1,dd2,dp1;
  LOCAL dp2, doey;
  LOCAL dhh,dmm,dss,dmm1;
  LOCAL stime, stx, timstr,timstr2;
  LOCAL xhh,xmm,xss;
  LOCAL m,m1,mx,my;
  LOCAL changed, newtime;
  LOCAL chos;

  While Z ≠ 9999 DO
    WHILE MOUSE(1)≥0 DO END;
    RECT();
    TEXTOUT_P("Date & time functions for Hp Prime V 0.99a",60,1,2);
      DRAWMENU("N→J","Δdays","date+","doe","time","exit");
    REPEAT
       m:=MOUSE;
       m1:=m(1);
    UNTIL SIZE(m1)>0;
    mx:=m1(1);
    my:=m1(2);

    IF my≥220 AND my≤239 THEN

      IF mx≥0 AND mx≤51 THEN   // Button 1
        N→Ja:=0;
        INPUT (N→Ja,"Number date to Julian Date number","dd.mmyyyy =", "Enter number date");
        TEXTOUT_P("JDN = ",32,51,3);
        TEXTOUT_P(N→J(N→Ja),89,51,3);
        WAIT(-1);
      END;

      IF mx≥53 AND mx≤104 THEN   // Button 2
        dd1:=0;dd2:=0;
        INPUT ({dd1,dd2}, "Difference between two dates in days",{"1st Date","2nd Date"}, {"dd.mmyyyy =", 

"dd.mmyyyy ="});
        TEXTOUT_P("ΔDAYS: ",5,81,3);
        TEXTOUT_P(N→J(dd2)-N→J(dd1),65,81,3);
        WAIT(-1);
      END;

      IF mx≥106 AND mx≤157 THEN   // Button 3
        dp1:=0;dp2:=0;
        INPUT ({dp1,dp2},"Date+",{"date","xdays"},{"dd.mmyyyy =", "number"});
        TEXTOUT_P("New Date:",1,81,3);
        TEXTOUT_P(CALD((N→J(dp1)+dp2)),80,81,3);
        WAIT(-1);
      END;

      IF mx≥159 AND mx≤210 THEN   // Button 4
        doey:=0;
        INPUT (doey,"Year of Easter= ", "Enter year");
        TEXTOUT_P(DOE(doey),1,161,3);
         // WAIT(-1);
      END;

      IF mx≥212 AND mx≤263 THEN   // Button 5
        //
        // SUB-MENUE +++++++++++++++++++++++++++++++++++++++++++
        //
        // TS TimeSet - setting calculator's time
        // WMWK 2015-01-22   // wolfgang.kuehn@vodafone.de
        // special thanks to:
        //   Thomas Schirmer.  ( 'running time' routine)

        RECT();
        changed:=0; timstr2:=""; 
        TEXTOUT_P("Setting Calculator's Time V 0.99, special thanks to Thomas Schirmer",5,1,1);
        TEXTOUT_P("HH: ",7,200,2,#000000,24,#FFFFFF);
        TEXTOUT_P("MM: ",60,200,2,#000000,24,#FFFFFF);
        TEXTOUT_P("SS: ",120,200,2,#000000,24,#FFFFFF);
        DRAWMENU("- HRS +","- MIN+","- SEK +"," SET "," BYE "); 
        stime:=Time; stx:=STRING(stime);
        IF (IP(stime)<10) THEN stx:="0"+stx; END;
        xhh:=LEFT(stx,2); xmm:=MID(stx,4,2); xss:=MID(stx,7,2);
        // dhh:=0+IP(st1); dmm1:=60*(st1-dhh); dmm:=IP(dmm1); dss:=IP(60*(dmm1-dmm));
        dhh:=EXPR(xhh); dmm:=EXPR(xmm); dss:=EXPR(xss); 
        
        TEXTOUT_P(dhh+"    ",27,200,2,#000000,25,#FFFFFF);
        TEXTOUT_P(dmm+"    ",85,200,2,#000000,25,#FFFFFF);
        TEXTOUT_P(dss+"    ",135,200,2,#000000,25,#FFFFFF);
        
        While Z <= 9999 DO
           WHILE MOUSE(1)>=0 DO END;
           // inner loop
           REPEAT
              stime:=Time; stx:=STRING(stime);
              IF (IP(stime)<10) THEN stx:="0"+stx; END;
              xhh:= LEFT(stx,2); xmm:= MID(stx,4,2); xss:= MID(stx,7,2);
              //timstr:= xhh+ "ⓗ" +xmm + "ⓜ" +xss +"ⓢ"; 
              timstr:= " "+xhh+" ː "+xmm+" ː "+xss +" "; 
        
              IF (timstr <> timstr2) THEN 
                TEXTOUT_P("actual time: "+ timstr,10,100,7,#000000,300,#FFFFFF); 
                timstr2:=timstr; 
                IF (changed=0) THEN 
                    // dhh:=0+IP(st1); dmm1:=60*(st1-dhh); dmm:=IP(dmm1); dss:=IP(60*(dmm1-dmm));
                    dhh=EXPR(xhh); dmm:=EXPR(xmm); dss:=EXPR(xss); 
                    TEXTOUT_P(dhh+"    ",27,200,2,#000000,25,#FFFFFF);
                    TEXTOUT_P(dmm+"    ",85,200,2,#000000,25,#FFFFFF);
                    TEXTOUT_P(dss+"    ",135,200,2,#000000,25,#FFFFFF);
                END; 
              END;
              WAIT(0.05);

              m:=MOUSE;
              m1:=m(1);
           UNTIL SIZE(m1)>0;   // REPEAT
           mx:=m1(1);
           my:=m1(2);

           // query softbuttons  submenu
           IF my>=220 AND my<=239 THEN
             //
             // submenu button 1
             IF mx>=0 AND mx<=19 THEN
               dhh:=dhh-1; changed:=1;
               IF dhh<0 THEN dhh:=23; END;
               TEXTOUT_P(dhh+"    ",27,200,2,#000000,25,#FFFFFF);
             END;
             IF mx>=20 AND mx<=51 THEN
               dhh:=dhh+1; changed:=1;
               IF dhh>23 THEN dhh:=0; END;
               TEXTOUT_P(dhh+"     ",27,200,2,#000000,25,#FFFFFF);
             END;
           
             // submenu button 2
             IF mx>=53 AND mx<=72 THEN
             dmm:=dmm-1; changed:=1;
             IF dmm<0 THEN dmm:=59; END;
             TEXTOUT_P(dmm+"    ",85,200,2,#000000,25,#FFFFFF);
             END;
             IF mx>=72 AND mx<=104 THEN
             dmm:=dmm+1; changed:=1;
             IF dmm>59 THEN dmm:=0; END;
             TEXTOUT_P(dmm+"    ",85,200,2,#000000,25,#FFFFFF);
             END;
           
             // submenu button 3
             IF mx>=106 AND mx<=125 THEN
             dss:=dss-1; changed:=1;
             IF dss<0 THEN dss:=59; END;
             TEXTOUT_P(dss+"    ",135,200,2,#000000,25,#FFFFFF);
             END;
             IF mx>=126 AND mx<=157 THEN
             dss:=dss+1; changed:=1;
             IF dss>59 THEN dss:=0; END;
             TEXTOUT_P(dss+"    ",135,200,2,#000000,25,#FFFFFF);
             END;
           
             // submenu button 4
             IF mx>=159 AND mx<=210 THEN
                newtime:= dhh + (dmm/60) + (dss+0.1)/3600;
                Time:= newtime;
                TEXTOUT_P("set",175,200,2,#000000,25,#FFFFFF);
             END;
           
             // submenu button 5
             IF mx>=212 AND mx<=263 THEN
                DTM();
             END;   //   IF mx
           END;     //   IF my
        END;        //   WHILE Z    
        // END   SUBMENU timeset +++++++++++++++++++++++++++++++++++++++           
           
      END;     //    Button5  ( inner loop)
      //
      IF mx≥265 AND mx≤319 THEN   // Button 6
        KILL;
      END;  //   IF mx

    END;    //   IF my
  END;      //   WHILE Z

END;

Good regards for all.


RE: How Drawmenu work's? - primer - 01-25-2017 11:18 PM

Hi ggauny,
I wanted to modify your program to show how to use with libMenu, but your program can't compile, these functions are missing : N->J(), CALD(), DOE(), and DTM().
to make it compilable, I removed their call, date computation results will not be the expected one.


So, I "converted" your program. simply by moving actions into local functions.
to demonstrate I simply handle first level menu.

You can compare with your program,
you will see than main program is no more a bulk of code, each one are now in function.

Code:

// -- forward decl (2nd menu)
MENU2();
LOCAL stay;

// -- usefull function
wait_and_clear()
BEGIN
     WAIT(-1);
     RECT();
END;

// -- menu functions

EXPORT Button1()
BEGIN
     LOCAL N→Ja:=0;
     INPUT (N→Ja,"Number date to Julian Date number","dd.mmyyyy =", "Enter number date");
     TEXTOUT_P("JDN = ",32,51,3);
     TEXTOUT_P(N→Ja,89,51,3);
     wait_and_clear();
END;


EXPORT Button2()
BEGIN
     LOCAL dd1:=0,dd2:=0;
     INPUT ({dd1,dd2}, "Difference between two dates in days",{"1st Date","2nd Date"}, {"dd.mmyyyy =", "dd.mmyyyy ="});
     TEXTOUT_P("ΔDAYS: ",5,81,3);
     TEXTOUT_P(dd2-dd1,65,81,3);
     wait_and_clear();
END;


EXPORT Button3()
BEGIN
     LOCAL dp1:=0,dp2:=0;
     INPUT ({dp1,dp2},"Date+",{"date","xdays"},{"dd.mmyyyy =", "number"});
     TEXTOUT_P("New Date:",1,81,3);
     TEXTOUT_P(dp2,80,81,3);
     wait_and_clear();
END;


EXPORT Button4()
BEGIN
     LOCAL doey:=0;
     INPUT (doey,"Year of Easter= ", "Enter year");
     TEXTOUT_P(doey,1,161,3);
     wait_and_clear();
END;


EXPORT Button5()
BEGIN
     MENU2();
     //todo refresh with 1st menu when back from 2nd one.
END;

EXPORT Button6()
BEGIN
     stay:=0; // leave
END;


// -- Main program ......................

EXPORT DTM1()
BEGIN
// DFX Main Menu
// WMWK 2014-09-19

  stay:=1;
  LibMenu.reset();
  LibMenu.entry(1, "N→J", "Button1()");
  LibMenu.entry(2, "Δdays", "Button2()");
  LibMenu.entry(3, "date+J", "Button3()");
  LibMenu.entry(4, "doe", "Button4()");
  LibMenu.entry(5, "time", "Button5()");
  LibMenu.entry(6, "exit", "Button6()");
  LibMenu.draw();

  WHILE stay DO
     LibMenu.events();
  END;

END;




MENU2()
BEGIN
 //todo : same mechanism as first menu.    
 //LibMenu.reset()
 //LibMenu.entry(...)

END;
by the way it fixe the problem you had when exiting... as we don't need KILL, there no more message at the end.
but to make it work, download the LibMenu