' +---------------------------------------------------------------------+ ' | | ' | - S D m e n u Q B . 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. | ' +---------------------------------------------------------------------+ ' +---------------------------------------------------------------------+ ' | SDMenu.BAS The SD signifies a menu which may be single or double;| ' | that is to say a single spaced or double spaced menu. This version | ' | requires no special library. | ' | The SUB SDmenuQB is a Public Domain FreeWare program written by | ' | Don Smith.Date: 03/21/2002 EMail: smithdonb@earthlink.net | ' +---------------------------------------------------------------------+ ' | This menu will start at the last position it held. Notice that | ' | Row% is before loopdeloop. The last menu item is set to exit menu | ' | To turn off, REM 2 lines that begin: IF Choice = MaxItems% THEN | ' +---------------------------------------------------------------------+ ' +---------------------------------------------------------------------+ ' | | ' | Compile: BC: BBmenuQB.Bas | ' | LINK: BBmenuQB.Bas | ' | LIB: BCom45.Lib | ' | | ' +---------------------------------------------------------------------+ DECLARE SUB SDMenu (M$(), Row%, TopRow%, Col%, Num%, MaxItems%, RegFGColr%, RegBGColr%, HiLiteColrFG%, HiLiteColrBG%, SD%, Choice%) DECLARE SUB OneLine (LineRow%, LineCol%, LineFG%, LineBG%, Style%, LenStr%) DECLARE SUB TinyBox (ULRow, ULCol, LRRow, LRCol, BoxFGColr, BoxBGColr, SingOrDoub) Row% = 2 loopdeloop: COLOR 15, 1: CLS '-------------------Setup for SUB TinyBox--------------- ULRow = 1: ULCol = 20: LRRow = 25: 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(23, 20, 15, 1, 4, 40) '-------------------Setup for SUB SDMenu----------------- TopRow% = 2: Col% = 29: MaxItems% = 7: RegFGColr% = 15 RegBGColr% = 1: HiLiteColrFG% = 15: HiLiteColrBG% = 0: SD% = 2 REDIM M$(MaxItems% + 1) M$(1) = "1. Private Letters" M$(2) = "2. MS Word" M$(3) = "3. Utilities" M$(4) = "4. Address Book" M$(5) = "5. Graphics" M$(6) = "6. Calendar/Appointments" M$(7) = "7. Exit Menu" LOCATE 2, 23: PRINT "Move: <> <>. Press # or Any Key"; LOCATE 24, 28: PRINT "Press <7> or To Exit"; COLOR 11, 1 LOCATE 24, 35: PRINT "7"; : LOCATE 24, 42: PRINT "Esc"; CALL SDMenu(M$(), Row%, TopRow%, Col%, Num%, MaxItems%, RegFGColr%, RegBGColr%, HiLiteColrFG%, HiLiteColrBG%, SD%, Choice%) what.choice: '+-------------------------------------+ '| When using this part, you will need | '| to use a series of ELSEIFs. Example:| '| ELSEIF Choice = 1 then | '| GOTO choice.one | '| ELSEIF Choice = 2 then | '| GOTO choice.tow | '| END IF (etc.) | '+-------------------------------------+ 'Remove next 2 lines if last menu choice is not to exit IF Choice% = MaxItems% THEN COLOR 7, 0: CLS : LOCATE 1, 1, 1, 6, 7: END ELSEIF Choice% > 0 AND Choice% < MaxItems% + 1 THEN 'See message above for info. GOSUB display.choice Num% = Choice% Row% = TopRow% + Choice% + (Choice% * SD% - SD%) - 1 GOTO loopdeloop ELSEIF Choice% = 101 OR Choice% = 102 THEN ' GOSUB display.choice 'Use high numbers to identify GOTO loopdeloop 'other keys, since menu END IF 'choices will never be so high. display.choice: COLOR 15, 2: CLS IF Choice% < 100 THEN LOCATE 10, 26: COLOR RegFGColr%, RegBGColr% + 1 PRINT "Choice Was Number" + STR$(Choice%); ELSEIF Choice% = 101 THEN LOCATE 10, 26: COLOR RegFGColr%, RegBGColr% + 1 PRINT "Choice Was "; ELSEIF Choice% = 102 THEN LOCATE 10, 26: COLOR RegFGColr%, RegBGColr% + 1 PRINT "Choice Was "; END IF LOCATE 13, 25: COLOR 15, 4 PRINT ""; DO: LOOP WHILE INKEY$ = "" Row% = Row% - SD% RETURN 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 SDMenu (M$(), Row%, TopRow%, Col%, Num%, MaxItems%, RegFGColr%, RegBGColr%, HiLiteColrFG%, HiLiteColrBG%, SD%, Choice%) ' +--------------+------------------------------------------------------+ ' | 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, do not | ' | | set the Row%. | ' | | | ' +--------------+------------------------------------------------------+ ' | TopRow% | TopRow% is same as Row%, except Row% will change. | ' +--------------+------------------------------------------------------+ ' | Col% | The column to place menu. | ' +--------------+------------------------------------------------------+ ' | Num% | Do not set Num%. Let the SUB do that. | ' +--------------+------------------------------------------------------+ ' | MaxItems% | The number of menu items. | ' +--------------+------------------------------------------------------+ ' | RegFGColr% | Regular foreground color. | ' +--------------+------------------------------------------------------+ ' | RegBGColr% | Regular background color. | ' +--------------+------------------------------------------------------+ ' | HiLiteColrFG%| Foreground hi-light color. | ' +--------------+------------------------------------------------------+ ' | HiLiteColrBG%| Background hi-light color. | ' +--------------+------------------------------------------------------+ ' | SD% | SD% = 0 (single spaced) SD% = 1 (double-spaced) | ' | | SD% = 2 (triple-spaced) | ' +--------------+------------------------------------------------------+ ' | Choice% | Let Sub set Choice%. Do not set it with a number. | ' | | When the SUB exits the Choice% will be set to the | ' | | correct menu item choice. | ' +--------------+------------------------------------------------------+ IF Choice% = 0 THEN Num% = 1 END IF FOR xyz% = 1 TO MaxItems% LOCATE TopRow% - 1 + xyz% + (xyz% * SD%), Col% + 1, 0 COLOR RegFGColr%, RegBGColr% PRINT M$(xyz%); NEXT Row% = Row% + SD% LOCATE Row%, Col% COLOR HiLiteColrFG%, HiLiteColrBG% PRINT " " + M$(Num%) + " "; DO DO K$ = INKEY$ LOOP UNTIL LEN(K$) > 0 K% = CVI(K$ + CHR$(0)) IF K% = 13 THEN Choice% = Num% EXIT SUB ELSEIF K% = 27 THEN 'Press and exit COLOR 7, 0: CLS : LOCATE 1, 1, 1, 6, 7: END '+----------------------[ Next Six Lines]---------------------------+ '| If more than 10 items, only first 10 will work (Press 0 for 10) | '| If more than 10 items, use and | '| If not more than 10, adjust the numbers to fit. 0 - 9: (48 - 57) | '| Example of 5 items: ELSEIF K% > 48 and K% < 54 THEN (#1-5)(49-53)| '+------------------------------------------------------------+ ELSEIF K% > 47 AND K% < (MaxItems% + 48 + 1) THEN Choice% = K% - 48 IF Choice% = 0 THEN Choice% = 10 EXIT SUB ' ELSEIF K% = 20480 THEN LOCATE Row%, Col%: COLOR RegFGColr%, RegBGColr% PRINT " " + M$(Num%) + " "; Num% = Num% + 1 Row% = Row% + 1 + SD% IF Row% >= TopRow% + MaxItems% + (MaxItems% * SD%) THEN Row% = TopRow% + SD% Num% = 1 END IF LOCATE Row%, Col%: COLOR HiLiteColrFG%, HiLiteColrBG% PRINT " " + M$(Num%) + " "; ELSEIF K% = 18432 THEN ' LOCATE Row%, Col%: COLOR RegFGColr%, RegBGColr% PRINT " " + M$(Num%) + " "; Num% = Num% - 1 Row% = Row% - 1 - SD% IF Row% <= TopRow% - 1 THEN Row% = TopRow% + MaxItems% + (MaxItems% * SD%) - 1 Num% = MaxItems% END IF LOCATE Row%, Col%: COLOR HiLiteColrFG%, HiLiteColrBG% PRINT " " + M$(Num%) + " "; ELSEIF K% = 15104 THEN ' ' To use other keys, use the numbers below: ' = 15104. = 15360. = 15616. = 15872. ' = 16128. = 16384. = 16640. = 16896. ' = 17152. = 17408. Choice% = 101 EXIT SUB ELSEIF K% = 17408 THEN ' Choice% = 102 EXIT SUB END IF LOOP 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