SUB IdealMenu (IMenu$(), Choice, Row, Col, FG, BG, SD, NumOrLetr, ExitCode) STATIC ' +--------------------------------------------------------------------+ ' | - S U B I d e a l M e n u - | ' | | ' | Public Domain - FreeWare | ' +--------------------------------------------------------------------+ ' | Author: Donald B. "Don" Smith | ' | Email : smithdonb@earthlink.net | ' | Date: 04/22/2002 | ' +--------------------------------------------------------------------+ ' | - ABOUT THE AUTHOR - | ' +--------------------------------------------------------------------+ ' | | ' | Hello. My name is Don Smith and I am a thirty-year retired teacher | ' | of Math/History/Spanish residing in Orange County, California. I | ' | am also a former six-year Sergeant of Marines. Who-Rah! On certain | ' | forums I am known as MarineDon. My email is:smithdonb@earthlink.net| ' | | ' +--------------------------------------------------------------------+ ' | - COPYING AND DISTIBUTING - | ' +--------------------------------------------------------------------+ ' | Since this code is public domain and freeware, anyone may freely | ' | copy and distribute it. If you use the QuickBasic code in one of | ' | your own programs, you do not have to cite my name as the author, | ' | and you may even change its name. | ' +--------------------------------------------------------------------+ ' +--------------------------------------------------------------------+ ' | IdealMenu is an extremely small, easy-to-use menu. With all | ' | comment lines removed, and all follow on code testing removed, | ' | this menu is 2.2 kb in size. | ' | | ' | - Don Smith | ' | EMail: smithdonb@earthlink.net | ' | 04-22-2002 | ' | | ' +--------------------------------------------------------------------+ ' +-----------+--------------------------------------------------------+ ' | IMenu$() | The menu items must be REDIMed in the main program | ' +-----------+--------------------------------------------------------+ ' | Choice | The Choice always gets reported as a number. If | ' | | the NumOrLetr = 2, and letters are being used, then | ' | | D = 4, for example. If you wish to reenter the | ' | | menu with the last Choice hi-lited, then in the | ' | | main program, place Choice = 1 BEFORE begin: | ' +-----------+--------------------------------------------------------+ ' | Row | Row to begin menu | ' +-----------+--------------------------------------------------------+ ' | Col | Col to begin menu | ' +-----------+--------------------------------------------------------+ ' | FG | Foreground color of menu | ' +-----------+--------------------------------------------------------+ ' | BG | Back ground color of menu | ' +-----------+--------------------------------------------------------+ ' | SD | SD = 1 use single spacing. SD = 2 use double spacing | ' +-----------+--------------------------------------------------------+ ' | NumOrLetr | NumOrLetr = 1 use numbers in menu. | ' | | NumOrLetr = 2 use letters in menu. | ' | | NumOrLetr = 3 use neither numbers nor letters. | ' | | Instead, only use: | ' | | and press | ' +-----------+--------------------------------------------------------+ ' +-----------+---------------------------------------------------------+ ' | F Keys | See below how to insert keys in program. | ' | | +-----------------------------------------------+ | ' | | | Keys per Cvi Code | | ' | | +-----------------------------------------------+ | ' | | | = 15104 = 16128 = 16896 | | ' | | | = 15360 = 16384 = 17152 | | ' | | | = 15616 = 16640 = 17408 | | ' | | | = 15872 Add 256 each time. | | ' | | +-----------------------------------------------+ | ' | | Extended keys other than keys may be used. | ' | | Example: R is 4864. | ' | | | ' | | Write or cut out the short program that follows to find | ' | | out other CVI numbers you will need. | ' +-----------+---------------------------------------------------------+ ' | 'CviCode.Bas | ' | COLOR 15, 1: CLS | ' | LOCATE 3, 22: PRINT "- C V I C o d e P r o g r a m -" | ' | LOCATE 5, 22: PRINT "Press a key or combination of keys." | ' | LOCATE 6, 24, 0: PRINT "Press Or To Exit." | ' | PRINT : PRINT | ' | LOCATE , 30 | ' | DO | ' | DO | ' | T$ = INKEY$ | ' | LOOP UNTIL LEN(T$) > 0 | ' | T = CVI(T$ + CHR$(0)) | ' | IF T > 256 THEN | ' | LOCATE , 24, 0: PRINT "Extended Key" + " = " + STR$(T) | ' | ELSE | ' | LOCATE , 35, 0: PRINT T$ + " = " + STR$(T) | ' | END IF | ' | IF T = 27 OR T = 13 THEN | ' | COLOR 7, 0: CLS : LOCATE 1, 1, 1, 6, 7: END | ' | END IF | ' | LOOP | ' +---------------------------------------------------------------------+ ' | Other CVI code numbers: | ' | ~~~~~~~~~~~~~~~~~~~~~~ | ' | = 24064 = 24064 | ' | = 24320 = 24320 | ' | Add 256 each time Add 256 each time | ' | | ' | = 21504 = 1 | ' | = 21760 = 2 | ' | Add 256 each time (Z> = 26 Add 1 each time | ' +---------------------------------------------------------------------+ MaxNum = UBOUND(IMenu$) FOR XYZ = 1 TO MaxNum LOCATE Row + (XYZ * SD) - SD, Col, 0 PRINT IMenu$(XYZ); NEXT IF SD = 0 THEN SD = 1 DO DisPlayFG = 15: DisPlayBG = 0 'HiLite color GOSUB Display DO Hit$ = INKEY$ Hit$ = UCASE$(Hit$) LOOP UNTIL LEN(Hit$) > 0 Hit% = CVI(Hit$ + CHR$(0)) 'CVI code numbers! IF Hit% = 13 THEN ' EXIT SUB ELSEIF Hit% = 27 THEN ' ExitCode = 27 EXIT SUB END IF DisPlayFG = FG: DisPlayBG = BG 'regular color GOSUB Display Hit$ = UCASE$(X$) IF NumOrLetr <> 3 THEN IF NumOrLetr = 2 THEN 'press a letter IF Hit% > 64 AND Hit% < 64 + MaxNum + 1 THEN 'A = 65 & Z = 90 Choice = Hit% - 64 'Convert to number EXIT SUB END IF ELSEIF NumOrLetr = 1 THEN IF Hit% > 48 AND Hit% < 48 + MaxNum + 1 THEN 'press a number Choice = Hit% - 48 '0 = 48. 9 = 57 EXIT SUB END IF END IF END IF IF Hit% = 18432 THEN ' Choice = Choice - 1 IF Choice < 1 THEN Choice = MaxNum ELSEIF Hit% = 20480 THEN ' Choice = Choice + 1 IF Choice > MaxNum THEN Choice = 1 ELSEIF Hit% = 15104 THEN ' See note above ExitCode = 1 ' on Keys. EXIT SUB END IF LOOP Display: COLOR DisPlayFG, DisPlayBG LOCATE Row + (Choice * SD) - SD, Col - 1, 0 PRINT " " + IMenu$(Choice) + " "; RETURN END SUB