Here is an example using WAIT to handle menus...I'm using the common PUTMENU and GETMENU functions...
First, here are the PUTMENU and GETMENU functions...
Code:
// DEFINE MENU
EXPORT PUTMENU(mTXT)
BEGIN
DRAWMENU(mTXT(1),mTXT(2),mTXT(3),mTXT(4),mTXT(5),mTXT(6));
END;
// SETS mSEL GLOBAL VIA MENU SELECT
EXPORT GETMENU(mx,my,mTXT)
BEGIN
LOCAL mSEL;
mSEL:=0;
IF my≥220 AND my≤239 THEN
CASE
IF mx≥0 AND mx≤51 AND mTXT(1)>"" THEN
mSEL:=1;
END;
IF mx≥53 AND mx≤104 AND mTXT(2)>"" THEN
mSEL:=2;
END;
IF mx≥106 AND mx≤157 AND mTXT(3)>"" THEN
mSEL:=3;
END;
IF mx≥159 AND mx≤210 AND mTXT(4)>"" THEN
mSEL:=4;
END;
IF mx≥212 AND mx≤263 AND mTXT(5)>"" THEN
mSEL:=5;
END;
IF mx≥265 AND mx≤319 AND mTXT(6)>"" THEN
mSEL:=6;
END;
END; // CASE
END; // IF MENU
RETURN mSEL;
END; // BEGIN
And here is the example using these and WAIT to implement a simple test. This example is called by MBase(4,5,6).
The menu has HEX, which outputs the first input number to the terminal, OCT, which outputs the second input number to the terminal, DEC, which prints the 3rd input number, BIN which clears the terminal and EXIT which exits the program.
Note that I check for the event type to be a 3 or a 7 (Click or Long Click).
Code:
EXPORT MBase(A,B,C)
BEGIN
LOCAL men,m,m1,mx,my,s;
// initialize
WHILE MOUSE(1)≥0 DO END;
men:={"","HEX","OCT","DEC","BIN","EXIT"};
REPEAT // MAIN LOOP
PUTMENU(men);
REPEAT // WAIT FOR A MOUSE CLICK
m:=WAIT(−1);
UNTIL (m(1)==3 OR m(1)==7);
mx:=m(2); my:=m(3);
s:=GETMENU(mx,my,men);
CASE
IF (s==2) THEN s:=0; PRINT(A); END;
IF (s==3) THEN s:=0; PRINT(B); END;
IF (s==4) THEN s:=0; PRINT(C); END;
DEFAULT
PRINT();
PRINT("");
END;
UNTIL (s==6); // REPEAT...
END; // BEGIN