Post Reply 
Sample program for creating and using the DRAWMENU command
04-09-2015, 05:00 PM (This post was last modified: 04-09-2015 05:12 PM by kharpster.)
Post: #1
Sample program for creating and using the DRAWMENU command
Here is a program that I put together to test the DRAWMENU command, it allows you to control the items on the menu using a list. Any menu item left blank will return a value of zero. The program is only to demonstrate the functionality of the DRAWMENU command and how to read the selected item number. Feel free to use the code as you see fit, as long as you do not charge for it or any program that contains my code.

Many thanks to Wes Loewer for the starting point of my code (http://www.hpmuseum.org/cgi-sys/cgiwrap/...ead=253307) !!!


The main program name is: MENUTEST


// Initialize procedures used in project
PUTMENU();
GETMENU();

// Initialize variables used globally in project
mSEL;

EXPORT MENUTEST()
BEGIN
// Initial local variables used within this procedure
LOCAL m,m1,mx,my,mTXT;

// Flush the mouse buffer
WHILE MOUSE(1)≥0 DO END;

// Set the menu text and draw the menu, blank items will return a selected value of zero
mTXT := {"ITEM1","ITEM2","","","","ITEM6"};
PUTMENU(mTXT);

// Wait for mouse input (screen touch)
REPEAT
m := MOUSE;
m1 := m(1);
UNTIL SIZE(m1)>0;

// Convert mouse coordinates to decimal (you can find the arrow using shift 9 on the Prime keyboard)
mx := B→R(m1(1));
my := B→R(m1(2));

// Determine if mouse coordinates are inside of a valid menu item otherwise return a zero
GETMENU(mx,my,mTXT);

// If a non-blank menu item was selected, do something, in this case we just issue a message
IF mSEL > 0 THEN
MSGBOX("Menu item " + mSEL + " was selected");
END;
END;

// ----------------------------------------------
// Draw the menu using the list passed in
// ----------------------------------------------
PUTMENU(mTXT)
BEGIN
DRAWMENU(mTXT(1),mTXT(2),mTXT(3),mTXT(4),mTXT(5),mTXT(6));
END;

// ------------------------------------------------------------------------------------------
// Get the number of the menu item selected (1-6) by checking mouse position
// Menu items with blank text will return a zero
// ------------------------------------------------------------------------------------------
GETMENU(mx,my,mTXT)
BEGIN
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≤210AND 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;
END;
END;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Sample program for creating and using the DRAWMENU command - kharpster - 04-09-2015 05:00 PM



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