'=========================================================================== ' Subject: HIGHLIGHT OF CHOICES Date: 02-06-97 (01:13) ' Author: Denis Boyles Code: QB, QBasic, PDS ' Origin: FidoNet QUIK_BAS Echo Packet: MENU.ABC '=========================================================================== '>I would like some help with drop-down menus. How does one program the '>following in Quick BASIC: '>1. When the menu drops down, how do you save the information below '> the menu so that it can be displayed again after you're done with 'You could copy the screen area to a buffer and then restore it later or 'simply clear and re-draw. '>2. How do you program the highlight bar to select choices on the menu? 'Hmm, might this demo I whipped up help, it displays a simple FILE menu 'complete with highlight. Use the up/down keys to move the highlight and press 'enter to `select' the option. When you've had enough, simply select the 'EXIT choice on the menu, hope it helps. 'CHOICES.BAS - Public Domain by Denis Boyles ' ! Microsoft QBASIC v1.1 ' ? a possible menu/highlight demonstration? DECLARE SUB ReadItems () DECLARE SUB DrawMenu (choice%) DECLARE FUNCTION GetChoice% (choice%) DECLARE FUNCTION GetKey$ () DEFINT A-Z CONST NUMITEMS = 6 DIM SHARED items(1 TO NUMITEMS) AS STRING ReadItems choice = 1 COLOR 7, 0 CLS PRINT "Use "; CHR$(24); CHR$(25); " to move, ENTER to select"; PRINT ", choose EXIT to quit." DO choice = GetChoice(choice) LOCATE 3, 1 COLOR 15, 0 PRINT "You picked: "; items(choice) LOOP UNTIL choice = NUMITEMS DATA "New", "Open...", "Save", "Save As...", "Print", "Exit" SUB DrawMenu (choice) FOR ct = 1 TO NUMITEMS LOCATE 9 + ct, 32 IF ct = choice THEN COLOR 15, 1 ELSE COLOR 0, 7 PRINT items(ct) NEXT END SUB FUNCTION GetChoice (choice) DO DrawMenu choice key$ = GetKey$ SELECT CASE key$ CASE CHR$(0) + CHR$(80) choice = choice + 1 IF choice > NUMITEMS THEN choice = 1 CASE CHR$(0) + CHR$(72) choice = choice - 1 IF choice < 1 THEN choice = NUMITEMS END SELECT LOOP UNTIL key$ = CHR$(13) GetChoice = choice END FUNCTION FUNCTION GetKey$ DO key$ = INKEY$ LOOP WHILE key$ = "" GetKey$ = key$ END FUNCTION SUB ReadItems FOR ct = 1 TO NUMITEMS READ items(ct) items(ct) = items(ct) + SPACE$(16 - LEN(items(ct))) NEXT END SUB