Post Reply 
LibMenu : a simple toolbox for easy menu handling
11-17-2016, 04:54 PM (This post was last modified: 11-17-2016 05:02 PM by compsystems.)
Post: #2
RE: LibMenu : a simple toolbox for easy menu handling
Hello, some questions and others

1: I Remove some apparently unnecessary EXPORT
2: The local variables p,t,ar (if they are in lowercase) of the function entryMenu(p,t,ar) must be defined as local in the header (Why?)
3: The variable STAY is not working, when a subfunction f1() is called stay->0, why?

LIBRARY FILE:
PHP Code:
//FILE:=LibMenu;
#pragma mode( separator(.,;) integer(h32) )
// LibMenu  "simple" v 1.0 primer october 2016

local m,a// menu entries and actions
local p,t,ar;

// start to reset.
resetMenu()
begin
 m
:={"","","","","",""};
 
a:={"","","","","",""};
end;

// to draw menu entries
draw()
begin
 drawmenu
(m(1),m(2),m(3),m(4),m(5),m(6))
end;

// to register menu etries
export entryMenu(p,t,ar)
begin
 m
(p):=t;
 
a(p):=ar;
end;

callitMenu(f)
begin
 
if f=="" then return; end;
 
expr(f);
 
draw();
end;

// to manage events, trigger actions
eventsMenu()
begin
 local e
;
 if 
mouse(1)<200 then return; end;
 
e:=1+floor(mouse(2)/53);
 
callitMenu(a(e));
end

TEST FILE
PHP Code:
//FILE:=LibMenuTest;
#pragma mode( separator(.,;) integer(h32) )

local stay:=1;
export LibMenuTest()
begin
 stay
:=1;
 print(
"stay:="+stay); wait(0.5);
 
LibMenu.resetMenu();
 
entryMenu(1,"menu1","tstLibM.f1()");
 
entryMenu(2,"menu2","tstLibM.f2()");
 
entryMenu(4,"menu4","tstLibM.f4()");
 
entryMenu(6,"exit","tstLibM.quitMenu()");

 
LibMenu.draw(); //;
 
while stay==DO
   
LibMenu.eventsMenu();
 
end;
 print(
"stay:="+stay); wait(0.5);
 return 
"Done";
end;

f1()
begin
  msgbox
("1st menu " "stay:=" stay);
  
//print("stay:="+stay); wait(0.5);
end;

f2()
begin
  msgbox
("2st menu " "stay:=" stay);
  
//print("stay:="+stay); wait(0.5);
end;

f4()
begin
  msgbox
("4 menu " "stay:=" stay);
  
//print("stay:="+stay); wait(0.5);
end;

quitMenu()
begin
 stay
:=0// you will quit nicely the WHILE loop
// print("stay:="+stay); wait(0.5);
end
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: LibMenu : a simple toolbox for easy menu handling - compsystems - 11-17-2016 04:54 PM



User(s) browsing this thread: 1 Guest(s)