AMigaOS supports menus which are accessible via the Screen Title bar at the top of the screen. Menus can have multiple headers e.g. File, Edit, Icons, Windows, Options etc and under each header have sub-items such as Open, Save, Save As, Close, Quit. Sub items can been ticked, have images and keyboard shortcuts assigned as well. To use Menus you need to use the Menu statement, and then attached them to a Window.
The format for the Menu statemen is as follows:
MENU menu-id, item-id, state [,title [,command-key]]
It has the following arguments:
menu-id = Number from 1 to 10
item-id = Number for iem from 0 to 19 where 0 is the top level of menu, 1-19 is a sub-item.
state = 0 for disabled, 1 for enabled and 2 is enabled and check marked.
title = Text to be displayed for the menu or menu item.
command-key = Shortcut key for the menu item.
MENU(n) = Returns information about the most recently selected menu item.
0 = Menu number, 1 = Menu item number, 2 = Menu subitem number.
MENU CLEAR or MENU RESET - Clears all menus for the current window.
MENU ON | OFF | STOP - Enables, disables or suspends menu event trapping.
MENU WAIT - Suspends program and waits for any menu activity.
ON MENU statement - States what statement to run when a menu event occurs.
WINDOW 1, "My Window", (20,20)-(220,170), 31 REM Top level menu (menu 1) MENU 1, 0 ,1,"File"
REM Sub items of menu 1 MENU 1, 1, 1, "Open" MENU 1, 2, 1, "Save" MENU 1, 3, 1, "Print" MENU 1, 4, 1, "Quit" REM Enable event trapping ON MENU GOSUB HandleMenu MENU ON done = -1 REM Main loop. Wait for a menu event WHILE done = -1 MENU WAIT WEND MENU CLEAR WINDOW CLOSE 1 END HandleMenu: IF MENU(0) = 1 THEN IF MENU(1) = 1 THEN REM Open a file ELSEIF MENU(1) = 2 THEN REM Save a file ELSEIF MENU(1) = 3 THEN REM Print a file ELSEIF MENU(1) = 4 THEN done = 0 ENDIF ENDIF RETURN