SUB SDMenu (M$(), Row%, TopRow%, Col%, Num%, MaxItems%, RegFGColr%, RegBGColr%, HiLiteColrFG%, HiLiteColrBG%, SD%, Choice%) ' +---------------------------------------------------------------------+ ' | - S U B S D M e n u - | ' | | ' | Public Domain - FreeWare | ' +---------------------------------------------------------------------+ ' | Author: Donald B. "Don" Smith | ' | Email : smithdonb@earthlink.net | ' | Date: 03/25/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. | ' +---------------------------------------------------------------------+ ' +--------------+------------------------------------------------------+ ' | 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