' +---------------------------------------------------------------------+ ' | | ' | SUB RoyalMenu | ' | | ' | Public Domain - FreeWare | ' | Written by Don Smith. Email: smithdonb@earthlink.net | ' +---------------------------------------------------------------------+ ' | See SUB RoyalMenu for details | ' +---------------------------------------------------------------------+ ' +---------------------------------------------------------------------+ ' | - 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. | ' +---------------------------------------------------------------------+ ' +---------------------------------------------------------------------+ ' | | ' | Compile: BC: BBmenuQB.Bas | ' | LINK: BBmenuQB.Bas | ' | LIB: BCom45.Lib | ' | | ' +---------------------------------------------------------------------+ DECLARE SUB RoyalMenu (M$(), Row%, Col%, SpotLetrs$, SpotColr%, FKeys$, FGColr%, BGColr%, HiLiteFG%, HiLiteBG%, MaxItems%, Selection%, ExitCode%) Selection% = 1 Row% = 2 loopdeloop: COLOR 15, 1: CLS SpotLetrs$ = "PSR-++SREN" SpotColr% = 12 FKeys$ = "150" FGColr% = 15 BGColr% = 1 HiLiteFG% = 15 HiLiteBG% = 0 Col% = 26 MaxItems% = 10 LenLine% = 20 REDIM M$(MaxItems% + 1) M$(1) = "1. Print" M$(2) = "2. Change Printer Settings" M$(3) = "3. ReType File Name" M$(4) = "-" M$(5) = "4. Four" M$(6) = "5. Five" M$(7) = "6. Six" M$(8) = "R. Seven" M$(9) = "8. Eight" M$(10) = "9. Nine" CALL RoyalMenu(M$(), Row%, Col%, SpotLetrs$, SpotColr%, FKeys$, FGColr%, BGColr%, HiLiteFG%, HiLiteBG%, MaxItems%, Selection%, ExitCode%) what.choice: COLOR FGColr%, BGColr%: CLS LOCATE 8, 25, 0 PRINT "Your selection was:" + STR$(Selection%); LOCATE 10, 25, 0 PRINT "The ASCII key pressed was: " + STR$(ExitCode%); LOCATE 12, 25 PRINT "The menu item was: "; LOCATE 12, 45: COLOR 15, 4 PRINT " " + M$(Selection%) + " "; IF ExitCode% = 1 OR ExitCode% = 5 OR ExitCode% = 10 THEN ' LOCATE 14, 25, 0: COLOR 14, 1 PRINT "You press the key!"; ELSEIF ExitCode% = 27 THEN LOCATE 16, 25, 0 COLOR 11, 1 PRINT "You pressed "; END END IF LOCATE 18, 25, 0: COLOR 11, 1 PRINT ""; DO: LOOP WHILE INKEY$ = "" GOTO loopdeloop SUB RoyalMenu (M$(), Row%, Col%, SpotLetrs$, SpotColr%, FKeys$, FGColr%, BGColr%, HiLiteFG%, HiLiteBG%, MaxItems%, Selection%, ExitCode%) ' +---------------------------------------------------------------------+ ' | | ' | SUB RoyalMenu | ' | | ' | Public Domain - FreeWare | ' | Written by Don Smith. Email: smithdonb@earthlink.net | ' +--------------+------------------------------------------------------+ ' | M$() | REDIM M$(MaxItem% + 1). REDIM in main program. | ' +--------------+------------------------------------------------------+ ' | Row% | Row to place menu. Set Row% = 1 in main program | ' | | to always hi-light the first item. To allow the | ' | | menu to reenter on last hi-lighted item, place | ' | | Row% above the loop. | ' +--------------+------------------------------------------------------+ ' | Col% | The column to place menu. | ' +--------------+------------------------------------------------------+ ' | SpotLetrs$ | A string that stipulates which letters in a menu | ' | | menu to hi-light with the SpotColr% (see next). | ' | | | ' | | Example: SpotLetrs$ = "BrT-++US-x" | ' | | ---------------------------------- | ' | | A dash (-) indicates a line to skip. | ' | | A plus (+) indicates to NOT hi-light | ' | | a menu item. | ' +--------------+------------------------------------------------------+ ' | SpotColr% | The color (0-15) to hi-light a menu letter | ' | | which has been set by SpotLetrs$. | ' +--------------+------------------------------------------------------+ ' | FKeys$ | Indicates which keys to turn "on". | ' | | | ' | | Example: FKeys$ = "150" This set up will turn | ' | | "on" . The "0" of "150" | ' | | means . | ' +--------------+------------------------------------------------------+ ' | FGColr% | The fore ground menu color. | ' +--------------+------------------------------------------------------+ ' | BGColr% | The background menu color. | ' +--------------+------------------------------------------------------+ ' | HiLiteFG% | The fore ground hi light color. | ' +--------------+------------------------------------------------------+ ' | HiLiteBG% | The background hi light color. | ' +--------------+------------------------------------------------------+ ' | MaxItems% | The number of menu items. | ' +--------------+------------------------------------------------------+ ' | Selection% | The Selection is always given as a number. | ' | | IMPORTANT. PLEASE READ -> Every menu item is counted| ' | | as a number, including horizontal lines, so take | ' | | that into consideration when trapping once the | ' | | SUB exits. All selections are counted as a number, | ' | | even letters. Letter E for example would be | ' | | Selection% = 5. If there were a horizontal line | ' | | above E, then Selection% = 6. | ' +--------------+------------------------------------------------------+ ' | ExitCode% | ExitCode% is the last key pressed. is | ' | | ExitCode% = 27 and is ExitCode% = 13. | ' | | If an key were pressed, then ExitCode% should | ' | | be renamed as ExitCode% = 1 for , and | ' | | ExitCode% = 10 for . | ' +--------------+------------------------------------------------------+ LetrOrNum% = 0 SpotLetrs$ = UCASE$(SpotLetrs$) IF Selection% = 0 THEN Selection% = 1 FindRow% = Row% MaxLen% = 0 NumOpts% = UBOUND(M$) IF Selection% = 0 OR Selection% > NumOpts% THEN Selection% = 1 END IF FOR A% = 1 TO NumOpts% B% = LEN(M$(A%)) IF B% > MaxLen% THEN MaxLen% = B% END IF NEXT MaxLen% = MaxLen% + 2 FOR A% = 1 TO NumOpts% COLOR FGColr%, BGColr% F% = Row% + A% - 1 LOCATE F%, Col%, 0 IF M$(A%) = "-" THEN PRINT STRING$(MaxLen%, 196); ELSE PRINT " "; M$(A%); TAB(Col% + MaxLen%); IF LEN(SpotLetrs$) > 0 THEN A$ = MID$(SpotLetrs$, A%, 1) B% = INSTR(UCASE$(M$(A%)), A$) IF B% THEN COLOR SpotColr%, BGColr% LOCATE F%, Col% + B%, 0 PRINT MID$(M$(A%), B%, 1); END IF END IF END IF NEXT DO LOCATE Row% + Selection% - 1, Col%, 0 COLOR HiLiteFG%, HiLiteBG%, 0 PRINT " " + M$(Selection%) + " "; IF LEN(SpotLetrs$) > 0 THEN A$ = MID$(SpotLetrs$, Selection%, 1) B% = INSTR(UCASE$(M$(Selection%)), A$) IF B% THEN COLOR SpotColr%, HiLightBG% LOCATE Row% + Selection% - 1, Col% + B%, 0 PRINT MID$(M$(Selection%), B%, 1); END IF END IF DO K$ = INKEY$ LOOP UNTIL LEN(K$) > 0 K% = CVI(K$ + CHR$(0)) IF K% = 13 THEN ExitCode% = 13 EXIT SUB ELSEIF K% = 27 THEN 'Press and exit ExitCode% = 27 EXIT SUB 'K% = 27 K% = 122 is last letter, or "z". ELSEIF K% > 27 AND K% < 123 THEN IF K$ <> "-" THEN LetrOrNum% = INSTR(SpotLetrs$, UCASE$(K$)) IF LetrOrNum% <> 0 THEN Selection% = LetrOrNum% ExitCode% = K% EXIT SUB END IF END IF ELSEIF K% = 20480 THEN ' GOSUB up.or.down ELSEIF K% = 18432 THEN ' GOSUB up.or.down ELSEIF K% > 15103 AND K% < 17409 THEN 'F1 - F10 IdentKey$ = STR$(((K% - 15104) \ 256) + 1) IdentKey$ = LTRIM$(RTRIM$(IdentKey$)) IF IdentKey$ = "10" THEN IdentKey$ = "0" END IF IF INSTR(FKeys$, IdentKey$) > 0 THEN IF IdentKey$ = "0" THEN ExitCode% = 10 EXIT SUB ELSE ExitCode% = VAL(IdentKey$) EXIT SUB END IF END IF END IF IF K% > 0 AND K% <> 45 AND K% <> 43 THEN Letter% = INSTR(SpotLetrs$, UCASE$(K$)) END IF LOOP UNTIL Letter% up.or.down: LOCATE Row% + Selection% - 1, Col%, 0 COLOR FGColr%, BGColr% PRINT " " + M$(Selection%) + " "; IF LEN(SpotLetrs$) > 0 THEN A$ = MID$(SpotLetrs$, Selection%, 1) B% = INSTR(UCASE$(M$(Selection%)), A$) IF B% THEN COLOR SpotColr%, BGColr% LOCATE Row% + Selection% - 1, Col% + B%, 0 PRINT MID$(M$(Selection%), B%, 1); END IF END IF IF K% = 18432 THEN ' Selection% = Selection% - 1 IF Selection% = 0 THEN Selection% = MaxItems% IF M$(Selection%) = "-" THEN Selection% = Selection% - 1 END IF ELSEIF K% = 20480 THEN ' Selection% = Selection% + 1 IF Selection% > MaxItems% THEN Selection% = 1 IF M$(Selection%) = "-" THEN Selection% = Selection% + 1 END IF ELSE Selection% = LetrOrNum% END IF RETURN END SUB