' +---------------------------------------------------------------------+ ' | | ' | - I d e a l M e n . B a s - | ' | | ' | | ' | Public Domain - FreeWare | ' +---------------------------------------------------------------------+ ' +---------------------------------------------------------------------+ ' | - 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. | ' +---------------------------------------------------------------------+ ' +---------------------------------------------------------------------+ ' | SUB 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. Public domain and freeware. | ' | | ' | - Don Smith | ' | EMail: smithdonb@earthlink.net | ' | 04-22-2002 | ' | | ' +---------------------------------------------------------------------+ ' +---------------------------------------------------------------------+ ' | | ' | Compile: BC: BBmenuQB.Bas | ' | LINK: BBmenuQB.Bas | ' | LIB: BCom45.Lib | ' | | ' +---------------------------------------------------------------------+ DEFINT A-Z DECLARE SUB IdealMenu (IMenu$(), Choice, Row, Col, FG, BG, SD, NumOrLetr, ExitCode) DECLARE SUB OneLine (LineRow%, LineCol%, LineFG%, LineBG%, Style%, LenStr%) DECLARE SUB TinyBox (ULRow, ULCol, LRRow, LRCol, BoxFGColr, BoxBGColr, SingOrDoub) Choice = 1 'Choice is placed before "begin:" begin: COLOR 15, 1: CLS REDIM M$(7) M$(1) = "1. One" M$(2) = "2. Two" M$(3) = "3. Three" M$(4) = "4. Four" M$(5) = "5. Five" M$(6) = "6. Six" M$(7) = "7. Seven" '-------------Setup for SUB TinyBox---------------- ULRow = 1: ULCol = 20: LRRow = 21: LRCol = 60 BoxFGColr = 15: BoxBGColr = 1: SingOrDoub = 2 CALL TinyBox(ULRow, ULCol, LRRow, LRCol, BoxFGColr, BoxBGColr, SingOrDoub) '-------------Setup for SUB OneLine---------------- LineRow% = 3: LineCol% = 20: LineFG% = 15 LineBG% = 1: Style% = 4: LenStr% = 40 CALL OneLine(LineRow%, LineCol%, LineFG%, LineBG%, Style%, LenStr%) CALL OneLine(19, 20, 15, 1, 4, 40) '-------------Setup for SUB IdealMenu--------------- Row = 5: Col = 34: FG = 15: BG = 1: SD = 2: NumOrLetr = 1: ExitCode = 0 LOCATE 2, 25: PRINT "Press A Number, <> <>, or " LOCATE 20, 31: PRINT "Press To Exit"; LOCATE 20, 38: COLOR 11, 0: PRINT "Esc"; : COLOR 15, 1 CALL IdealMenu(M$(), Choice, Row, Col, FG, BG, SD, NumOrLetr, ExitCode) IF ExitCode = 27 THEN GOTO leave COLOR 15, 2: CLS IF ExitCode > 0 AND ExitCode < 11 THEN LOCATE 7, 25, 0 PRINT "You Pressed " END IF LOCATE 10, 25, 0 PRINT "The Selection Was " + CHR$(34) + RTRIM$(LTRIM$(STR$(Choice))) + CHR$(34) LOCATE 13, 25, 0 PRINT "The Menu Item Was: " LOCATE 13, 45, 0: COLOR 15, 4 PRINT " " + M$(Choice) + " " LOCATE 18, 15, 0: COLOR 15, 2 PRINT "Press To Continue, Or Press To Exit" COLOR 14, 2 LOCATE 18, 22, 0: PRINT "Enter" LOCATE 18, 52, 0: PRINT "Esc" DO DO R$ = INKEY$ LOOP UNTIL LEN(R$) IF R$ = CHR$(27) THEN GOTO leave ELSEIF R$ = CHR$(13) THEN GOTO begin END IF LOOP WHILE INKEY$ = "" leave: COLOR 7, 0: CLS : LOCATE 1, 1, 1, 6, 7: END SUB IdealMenu (IMenu$(), Choice, Row, Col, FG, BG, SD, NumOrLetr, ExitCode) STATIC ' +--------------------------------------------------------------------+ ' | 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 SUB OneLine (LineRow%, LineCol%, LineFG%, LineBG%, Style%, LenStr%) ' +-------------------------------------------------------------------+ ' | SUB OneLine | ' +-------------------------------------------------------------------+ ' | Not counting REM (') lines, SUB OneLine has 12 lines. | ' +-------------------------------------------------------------------+ ' | SUB OneLine will place one line on screen. There are 4 types | ' | of lines to choose from. See Style% below. | ' +---------------+---------------------------------------------------+ ' | LineRow% | Row to place line. | ' +---------------+---------------------------------------------------+ ' | LineCol% | Column to place line. | ' +---------------+---------------------------------------------------+ ' | LineFG% | Foreground color of line. | ' +---------------+---------------------------------------------------+ ' | LineBG% | Background color of line. | ' +---------------+---------------------------------------------------+ ' | Style% | Style% = 1 ÃÄÄÄ´ | ' | +---------------------------------------------------+ ' | | Style% = 2 ÆÍÍ͵ | ' | +---------------------------------------------------+ ' | | Style% = 3 ÌÍÍ͹ | ' | +---------------------------------------------------+ ' | | Style% = 4 ÇÄÄĶ | ' +---------------+---------------------------------------------------+ ' | LenStr% | Length of string (line). | ' +-------------------------------------------------------------------+ IF Style% = 1 THEN 'ÃÄÄÄ´ SingLine$ = CHR$(195) + STRING$(LenStr%, CHR$(196)) + CHR$(180) ELSEIF Style% = 2 THEN 'ÆÍÍ͵ SingLine$ = CHR$(198) + STRING$(LenStr%, CHR$(205)) + CHR$(181) ELSEIF Style% = 3 THEN 'ÌÍÍ͹ SingLine$ = CHR$(204) + STRING$(LenStr%, CHR$(205)) + CHR$(185) ELSEIF Style% = 4 THEN 'ÇÄÄĶ SingLine$ = CHR$(199) + STRING$(LenStr%, CHR$(196)) + CHR$(182) END IF LOCATE LineRow%, LineCol% COLOR LineFG%, LineBG% PRINT SingLine$; END SUB SUB TinyBox (ULRow, ULCol, LRRow, LRCol, BoxFGColr, BoxBGColr, SingOrDoub) ' +----------------------------------------------------------------------+ ' | SUB TinyBox | ' +----------------------------------------------------------------------+ ' | ULRow = Upper Left Row. ULCol = Upper Left Column. | ' | LRRow = Lower Right Row. LRCol = Lower Right Column. | ' | BoxFGColr = The Foreground Color The Box. | ' | BoxBGColr = The Back Ground Color Of The Box. | ' | SingOrDoub = 1 (Single Line Box). SingOrDoub = 2 (Double Line Box). | ' +----------------------------------------------------------------------+ COLOR BoxFGColr, BoxBGColr IF SingOrDoub = 1 THEN LOCATE ULRow, ULCol PRINT CHR$(218) + STRING$(LRCol - ULCol, CHR$(196)) + CHR$(191); FOR BoxY = ULRow + 1 TO LRRow - 1 LOCATE BoxY, ULCol PRINT CHR$(179) + STRING$(LRCol - ULCol, " ") + CHR$(179); NEXT LOCATE LRRow, ULCol PRINT CHR$(192) + STRING$(LRCol - ULCol, CHR$(196)) + CHR$(217); ELSEIF SingOrDoub = 2 THEN LOCATE ULRow, ULCol PRINT CHR$(201) + STRING$(LRCol - ULCol, CHR$(205)) + CHR$(187); FOR BoxY = ULRow + 1 TO LRRow - 1 LOCATE BoxY, ULCol PRINT CHR$(186) + STRING$(LRCol - ULCol, " ") + CHR$(186); NEXT LOCATE LRRow, ULCol PRINT CHR$(200) + STRING$(LRCol - ULCol, CHR$(205)) + CHR$(188); END IF END SUB