' +--------------------------------------------------------------------+ ' | | ' | - L o n g M e n u . 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 LongMenu | ' +--------------------------------------------------------------------+ ' | The SUB LongMenu was written by Don Smith on 08/01/2002. It is | ' | Public Domain FreeWare. LongMenu is a one-column menu with a | ' | block cursor. To move the cursor, use: , , | ' | , , , , , , | ' | , . When the user presses a letter, the block cursor | ' | will jump to the first file beginning with that letter. | ' | | ' | See the SUB LongMenu for details on how to use LongMenu. | ' +--------------------------------------------------------------------+ ' | See the SUBs BoxBoy and SaveRestScrn for details on how to use them| ' +--------------------------------------------------------------------+ ' +--------------------------------------------------------------------+ ' | | ' | Compile: BC: LongMenu.Bas | ' | LINK: LongMenu.Bas | ' | LIB: BCom45.Lib | ' | | ' +--------------------------------------------------------------------+ DECLARE SUB BoxBoy (Title$, ULRow%, ULCol%, LRRow%, LRCol%, TitleRow%, TitleCol%, TitColrFor%, TitColrBak%, BoxColrFor%, BoxColrBak%, BoxStyle%, Shadow%, ShadowColr%, ClearColr%) DECLARE SUB LongMenu (LM$(), ULRowLM%, ULColLM%, LRRowLM%, LRColLM%, LMColrFG%, LMColrBG%, LMHiLiteFG%, LMHiLiteBG%, FKey$, MaxNum%, Selection%, ExitCode%, CurrentRow%) DECLARE SUB SaveRestScrn (ReadLine$(), ReadColr%(), SR.UL.Row%, SR.UL.Col%, SR.LR.Row%, SR.LR.Col%, SaveOrRest%) '==================================================================== ' User enters at command prompt: LongMenu.Exe *.Txt ' or similar parameter. '==================================================================== Exten$ = COMMAND$ begin: Exten$ = RTRIM$(LTRIM$(Exten$)) Exten$ = UCASE$(Exten$) IF LEFT$(Exten$, 2) <> "*." THEN 'incorrect DOS usage - error GOTO errorhandler ELSEIF Exten$ = "" THEN 'blank parameter error GOTO errorhandler END IF make.short.menu: '==================================================================== ' Make a file, $$$$FAKE.SM with short truncated DOS names: '==================================================================== SHELL "dir" + " " + Exten$ + " " + ">" + "$$$$FAKE.SM" OPEN "$$$$FAKE.SM" FOR INPUT AS #8 DO IF EOF(8) THEN EXIT DO END IF LINE INPUT #8, TossOut$ MaxNum% = MaxNum% + 1 LOOP UNTIL EOF(8) CLOSE 8 IF MaxNum% < 6 THEN GOTO errorhandler END IF OPEN "$$$$FAKE.SM" FOR INPUT AS #1 FOR GetRid% = 1 TO 5 LINE INPUT #1, TossOut$ NEXT REDIM LM$(MaxNum%) SMNum% = 0 FOR InputShortM% = 1 TO MaxNum% - 6 IF EOF(1) THEN EXIT FOR END IF LINE INPUT #1, SMenu$ IF LEFT$(SMenu$, 8) <> "$$$$FAKE" AND MID$(SMenu$, 14, 1) <> "<" AND LEFT$(SMenu$, 1) <> "." AND LEFT$(SMenu$, 2) <> " " THEN SMenu$ = LEFT$(SMenu$, 12) SMenu$ = RTRIM$(LTRIM$(SMenu$)) SMNum% = SMNum% + 1 LM$(SMNum%) = SMenu$ LM$(SMNum%) = RTRIM$(LTRIM$(LM$(SMNum%))) FOR DaSpc% = 1 TO 12 DaSpc$ = MID$(LM$(SMNum%), DaSpc%, 1) IF DaSpc$ = " " THEN LM$(SMNum%) = LEFT$(LM$(SMNum%), DaSpc% - 1) + "." + RTRIM$(LTRIM$(RIGHT$(LM$(SMNum%), 3))) EXIT FOR END IF NEXT END IF NEXT CLOSE #1 KILL "$$$$FAKE.SM" FOR dodobird% = 1 TO LineNum% IF LM$(dodobird%) <> "" THEN LineUp% = LineUp% + 1 END IF NEXT COLOR 15, 1: CLS '==================================================================== ' Make Top Box - Outside: '==================================================================== Title$ = "": ULRow% = 1: ULCol% = 10: LRRow% = 5: LRCol% = 67 TitleRow% = 1: TitleCol% = 1: TitColrFor% = 1: TitColrBak% = 1 BoxColrFor% = 15: BoxColrBak% = 1: BoxStyle% = 1: Shadow% = 0 ShadowColr% = 8: ClearColr% = 1000 CALL BoxBoy(Title$, ULRow%, ULCol%, LRRow%, LRCol%, TitleRow%, TitleCol%, TitColrFor%, TitColrBak%, BoxColrFor%, BoxColrBak%, BoxStyle%, Shadow%, ShadowColr%, ClearColr%) '==================================================================== ' Make Top Box - Inside: '==================================================================== Title$ = "": ULRow% = 2: ULCol% = 15: LRRow% = 4: LRCol% = 62 TitleRow% = 1: TitleCol% = 1: TitColrFor% = 1: TitColrBak% = 1 BoxColrFor% = 15: BoxColrBak% = 1: BoxStyle% = 2: Shadow% = 0 ShadowColr% = 8: ClearColr% = 1000 CALL BoxBoy(Title$, ULRow%, ULCol%, LRRow%, LRCol%, TitleRow%, TitleCol%, TitColrFor%, TitColrBak%, BoxColrFor%, BoxColrBak%, BoxStyle%, Shadow%, ShadowColr%, ClearColr%) COLOR 11, 1 LOCATE 3, 20: PRINT "L o n g M e n u D e m o P r o g r a m" '==================================================================== ' Make Left Box: '==================================================================== Title$ = "": ULRow% = 6: ULCol% = 2: LRRow% = 24: LRCol% = 56 TitleRow% = 1: TitleCol% = 1: TitColrFor% = 1: TitColrBak% = 1 BoxColrFor% = 15: BoxColrBak% = 1: BoxStyle% = 1: Shadow% = 0 ShadowColr% = 8: ClearColr% = 1000 CALL BoxBoy(Title$, ULRow%, ULCol%, LRRow%, LRCol%, TitleRow%, TitleCol%, TitColrFor%, TitColrBak%, BoxColrFor%, BoxColrBak%, BoxStyle%, Shadow%, ShadowColr%, ClearColr%) '==================================================================== ' Make Middle of Left Box: '==================================================================== Title$ = "MOVE:": ULRow% = 12: ULCol% = 11: LRRow% = 23: LRCol% = 48 TitleRow% = 13: TitleCol% = 28: TitColrFor% = 14: TitColrBak% = 1 BoxColrFor% = 15: BoxColrBak% = 1: BoxStyle% = 2: Shadow% = 0 ShadowColr% = 8: ClearColr% = 1000 CALL BoxBoy(Title$, ULRow%, ULCol%, LRRow%, LRCol%, TitleRow%, TitleCol%, TitColrFor%, TitColrBak%, BoxColrFor%, BoxColrBak%, BoxStyle%, Shadow%, ShadowColr%, ClearColr%) '==================================================================== ' Print Program Info: '==================================================================== COLOR 15, 1 LOCATE 7, 7: PRINT "The SUB LongMenu is a one-column menu. As" LOCATE 8, 7: PRINT "demonstrated here, the menu items are programs" LOCATE 9, 7: PRINT "on the current directory, but the menu items" LOCATE 10, 7: PRINT "may be anything the QuickBASIC programmer wishes" LOCATE 11, 7: PRINT "them to be." LOCATE 15, 18: PRINT "1. <" + CHR$(25) + "> or <" + CHR$(24) + ">" LOCATE 16, 18: PRINT "2. or " + "<" + CHR$(26) + ">"; LOCATE 17, 18: PRINT "3. or " + "<" + CHR$(27) + ">"; LOCATE 18, 18: PRINT "4. or " LOCATE 19, 18: PRINT "5. View File"; LOCATE 20, 18: PRINT "6. Help"; LOCATE 21, 18: PRINT "7. Press First Letter Of Item"; LOCATE 22, 18: PRINT "8. Exit"; '==================================================================== ' Make Right Box: '==================================================================== Title$ = "": ULRow% = 6: ULCol% = 60: LRRow% = 24: LRCol% = 76 TitleRow% = 1: TitleCol% = 1: TitColrFor% = 1: TitColrBak% = 1 BoxColrFor% = 15: BoxColrBak% = 1: BoxStyle% = 1: Shadow% = 0 ShadowColr% = 8: ClearColr% = 1000 CALL BoxBoy(Title$, ULRow%, ULCol%, LRRow%, LRCol%, TitleRow%, TitleCol%, TitColrFor%, TitColrBak%, BoxColrFor%, BoxColrBak%, BoxStyle%, Shadow%, ShadowColr%, ClearColr%) 'LineNum% = LineUp% ULRowLM% = 7 ULColLM% = 64 LRRowLM% = 23 LRColLM% = 77 LMColrFG% = 15 LMColrBG% = 1 LMHiLiteFG% = 15 LMHiLiteBG% = 0 CurrentRow% = ULRowLM% FKey$ = "150" Selection% = 1 MaxNum% = SMNum% begin.menu: '==================================================================== ' Start SUB LongMenu here: '==================================================================== CALL LongMenu(LM$(), ULRowLM%, ULColLM%, LRRowLM%, LRColLM%, LMColrFG%, LMColrBG%, LMHiLiteFG%, LMHiLiteBG%, FKey$, MaxNum%, Selection%, ExitCode%, CurrentRow%) LM$(Selection%) = RTRIM$(LTRIM$(LM$(Selection%))) IF ExitCode% = 27 THEN ' COLOR 7, 0: CLS : LOCATE 1, 1, 1, 6, 7: END ' ELSEIF ExitCode% = 1 OR ExitCode% = 5 OR ExitCode% = 10 OR ExitCode% = 13 THEN GOSUB save.screen COLOR 15, 0: CLS FOR MkScrn = 2 TO 23 COLOR 9, 1 LOCATE MkScrn, 3 PRINT STRING$(76, CHR$(21)); NEXT Title$ = "AND THE RESULTS ARE Í": ULRow% = 7: ULCol% = 15: LRRow% = 15: LRCol% = 65 TitleRow% = 8: TitleCol% = 23: TitColrFor% = 1: TitColrBak% = 7 BoxColrFor% = 0: BoxColrBak% = 7: BoxStyle% = 1: Shadow% = 1 ShadowColr% = 8: ClearColr% = 1000 CALL BoxBoy(Title$, ULRow%, ULCol%, LRRow%, LRCol%, TitleRow%, TitleCol%, TitColrFor%, TitColrBak%, BoxColrFor%, BoxColrBak%, BoxStyle%, Shadow%, ShadowColr%, ClearColr%) LOCATE 8, 43: COLOR 15, 7: PRINT CHR$(205); CHR$(16) COLOR 0, 7 LOCATE 10, 23: PRINT "ExitCode% Was" + STR$(ExitCode%) + "." IF ExitCode% = 1 OR ExitCode% = 5 OR ExitCode% = 10 THEN LOCATE 12, 23, 0 PRINT " Was Pressed." ELSEIF ExitCode% = 13 THEN LOCATE 12, 23, 0 PRINT "Selection #" + RTRIM$(LTRIM$(STR$(Selection%))); PRINT ", " + CHR$(34) + RTRIM$(LTRIM$(LM$(Selection%))); PRINT CHR$(34) + " Was Pressed." END IF LOCATE 14, 23, 0: PRINT "" DO: LOOP WHILE INKEY$ = "" GOSUB restore.screen GOTO begin.menu ELSE GOTO begin.menu END IF save.screen: '==================================================================== ' Save 25X80 Screen Using SUB SaveRestScrn: '==================================================================== REDIM ReadLine$(25) REDIM ReadColr%(25, 80) SR.UL.Row% = 1 SR.UL.Col% = 1 SR.LR.Row% = 25 SR.LR.Col% = 80 SaveOrRest% = 1 CALL SaveRestScrn(ReadLine$(), ReadColr%(), SR.UL.Row%, SR.UL.Col%, SR.LR.Row%, SR.LR.Col%, SaveOrRest%) RETURN restore.screen: '==================================================================== ' Restore 25X80 Screen Using SUB SaveRestScrn: '==================================================================== SR.UL.Row% = 1 SR.UL.Col% = 1 SR.LR.Row% = 25 SR.LR.Col% = 80 SaveOrRest% = 2 CALL SaveRestScrn(ReadLine$(), ReadColr%(), SR.UL.Row%, SR.UL.Col%, SR.LR.Row%, SR.LR.Col%, SaveOrRest%) ERASE ReadLine$: ERASE ReadColr% RETURN errorhandler: '==================================================================== ' Command Line Parameter DOS error comes here: '==================================================================== CALL BoxBoy("<<>>", 2, 9, 16, 71, 3, 35, 12, 0, 15, 0, 1, 0, 8, 0) COLOR 15, 0 LOCATE 5, 19: PRINT "Either no parameter was entered on the command" LOCATE 6, 19: PRINT "line, the parameter was entered incorrectly, or" LOCATE 7, 19: PRINT "there were no matching files found." COLOR 11, 0 LOCATE 9, 29: PRINT "Example: LongMenu *.TXT" COLOR 15, 0 LOCATE 11, 19: PRINT "To view all the files on the current directory," LOCATE 12, 19: PRINT "type Í" COLOR 11, 0 LOCATE 13, 39: PRINT "LongMenu *.* " LOCATE 15, 31: COLOR 14, 0: PRINT "Press Any Key To Exit"; DO: LOOP WHILE INKEY$ = "" COLOR 7, 0: CLS : LOCATE , , 1, 6, 7 END SUB BoxBoy (Title$, ULRow%, ULCol%, LRRow%, LRCol%, TitleRow%, TitleCol%, TitColrFor%, TitColrBak%, BoxColrFor%, BoxColrBak%, BoxStyle%, Shadow%, ShadowColr%, ClearColr%) '+---------------------------------------------------------------------+ '| SUB BoxBoy | '+---------------------------------------------------------------------+ '| SUB written by Don Smith on March 25, 2002. Declared Public | '| Domain FreeWare. Other programmers may use this SUB without | '| naming me as the author. Don's EMail: smithdonb@earthlink.net | '| | '| This SUB only saves the underlying screen to repaint with a shadow. | '| So recommend using the SUB SaveRestScrn to save/restore screen. | '| Please read: SUB SaveRestScrn. | '+-------------+-------------------------------------------------------+ '| Title$ | The title of the menu. To make a box without a title,| '| | use: Title$ = "". When there is no Title, the cross | '| | bar is not deployed. | '|-------------+-------------------------------------------------------| '| ULRow% | The upper left row to place the box. | '|-------------+-------------------------------------------------------| '| ULCol% | The upper left column to place the box. | '|-------------+-------------------------------------------------------| '| LRRow% | The lower right row to place the box. | '|-------------+-------------------------------------------------------| '| LRCol% | The lower right column to place the box. | '|-------------+----------------------------------+--------------------| '| TitleRow% | The row to place the title. | If there is to be | '|-------------+----------------------------------| NO title, these 4 | '| TitleCol% | The column to place the title. | values will be | '|-------------+----------------------------------| ignored. If that | '| TitColrFor% | The foreground color of the title| is the case, these | '|-------------+----------------------------------| values may be | '| TitColrBak% | The background color of the title| omitted. | '|-------------+----------------------------------+--------------------| '| BoxColrFor% | The foreground color of the box itself. | '|-------------+-------------------------------------------------------| '| BoxColrBak% | The back ground color of the box. | '+-------------+-------------------------------------------------------+ '| Style% | Style% equals 1 - Single line around box | '| | Style% equals 2 - Double line around box | '+-------------+-------------------------------------------------------+ '| Shadow% | If Shadow% equals 0, there will be no shadow . | '| | If Shadow% equals 1, there will be a right shadow. | '| | If Shadow% equals 2, there will be a left shadow | '| +-------------------------------------------------------+ '| | NOTE #1: | '| | ------- | '| | When a shadow is used, the underlying text will | '| | be saved and printed with COLOR 8, 0 (very dim). | | '| | This causes the shadow to look like a real shadow. | '| | | '| | NOTE #2: | '| | ------- | '| | If the first four values of BoxBoy are 1, 1, 25, 89, | '| | in other words a full screen, please set Shadow% = 0 | '| | otherwise an error will result (no room for shadow). | '+-------------+-------------------------------------------------------+ '| ShadeColr% | The foreground color of the shadow. Usually | '| | this color is 8 or 7 (Normally 8). | | '+-------------+-------------------------------------------------------+ '| ClearColr% | What color (0-7) to clear screen before making box. | '| | To disable this feature, use ClearColr% = 1000 | '| | | '| | COLOR VALUES: | '| | ---------------------------------- | '| | 0 is black 4 is red | '| | 1 is blue 5 is purple | '| | 2 is green 6 is orange | '| | 3 is light blue 7 is light white | '| | | '+-------------+-------------------------------------------------------+ IF ClearColr% <> 1000 THEN COLOR , ClearColr%: CLS END IF IF ULCol% <= 1 THEN ULCol% = 1 END IF IF LRCol% = 80 THEN LRCol% = 77 END IF make.box: IF BoxStyle% = 1 THEN 'Single Line ULCorner$ = CHR$(218) URCorner$ = CHR$(191) HorLine$ = CHR$(196) LeftSide$ = CHR$(195) RightSide$ = CHR$(180) VertLine$ = CHR$(179) LLCorner$ = CHR$(192) LRCorner$ = CHR$(217) ELSEIF BoxStyle% = 2 THEN 'Double Line ULCorner$ = CHR$(201) URCorner$ = CHR$(187) HorLine$ = CHR$(205) LeftSide$ = CHR$(199) RightSide$ = CHR$(182) VertLine$ = CHR$(186) LLCorner$ = CHR$(200) LRCorner$ = CHR$(188) END IF IF Shadow% = 1 THEN REDIM ReadLine$(25) FOR ViewIt% = ULRow% + 1 TO LRRow% + 1 FOR Horizon% = ULCol% + 2 TO LRCol% + 5 ReadLine$(ViewIt%) = ReadLine$(ViewIt%) + CHR$(SCREEN(ViewIt%, Horizon%)) NEXT NEXT COLOR ShadowColr%, 0 FOR Scratch% = ULRow% + 1 TO LRRow% + 1 LOCATE Scratch%, ULCol% + 2 PRINT ReadLine$(Scratch%); NEXT ELSEIF Shadow% = 2 THEN REDIM ReadLine$(25) FOR ViewIt% = ULRow% + 1 TO LRRow% + 1 FOR Horizon% = ULCol% - 2 TO LRCol% + 1 ReadLine$(ViewIt%) = ReadLine$(ViewIt%) + CHR$(SCREEN(ViewIt%, Horizon%)) NEXT NEXT COLOR ShadowColr%, 0 FOR Scratch% = ULRow% + 1 TO LRRow% + 1 LOCATE Scratch%, ULCol% - 2 PRINT ReadLine$(Scratch%); NEXT END IF Title.Length% = LEN(Title$) COLOR BoxColrFor%, BoxColrBak% 'ÚÄÄÄ¿ or ÉÍÍÍ» LOCATE ULRow%, ULCol% PRINT " " + ULCorner$ + STRING$(LRCol% - ULCol%, HorLine$) + URCorner$ + " "; '³ ³ or º º LOCATE ULRow% + 1, ULCol% PRINT " " + VertLine$ + SPACE$(LRCol% - ULCol%) + VertLine$ + " "; IF Title$ <> "" THEN 'ÃÄÄÄ´ or ÇÄÄĶ 'made cross bar if there is a title LOCATE ULRow% + 2, ULCol% PRINT " " + LeftSide$ + STRING$(LRCol% - ULCol%, 196) + RightSide$ + " "; ELSEIF Title$ = "" THEN LOCATE ULRow% + 2, ULCol% PRINT " " + VertLine$ + SPACE$(LRCol% - ULCol%) + VertLine$ + " "; END IF '³ ³ or º º FOR Print.Box% = 1 TO (LRRow% - ULRow%) - 3 LOCATE ULRow% + Print.Box% + 2, ULCol% PRINT " " + VertLine$ + SPACE$(LRCol% - ULCol%) + VertLine$ + " "; NEXT 'ÀÄÄÄÙ or ÈÍÍͼ LOCATE LRRow%, ULCol%, 0 PRINT " " + LLCorner$ + STRING$(LRCol% - ULCol%, HorLine$) + LRCorner$ + " "; IF Title$ <> "" THEN LOCATE TitleRow%, TitleCol% COLOR TitColrFor%, TitColrBak% PRINT Title$; END IF END SUB SUB LongMenu (LM$(), ULRowLM%, ULColLM%, LRRowLM%, LRColLM%, LMColrFG%, LMColrBG%, LMHiLiteFG%, LMHiLiteBG%, FKey$, MaxNum%, Selection%, ExitCode%, CurrentRow%) ' +--------------------------------------------------------------------+ ' | SUB LongMenu | ' +--------------------------------------------------------------------+ ' | The SUB LongMenu was written by Don Smith on 08/01/2002. It is | ' | Public Domain FreeWare. LongMenu is a one-column menu with a | ' | block cursor. To move the cursor, use: , , | ' | , , , , , , | ' | or . SUB is 169 lines long not counting REM (') lines. | ' +--------------+-----------------------------------------------------+ ' | LM$() | These are menu items which should be REDIMed in | ' | | the main program. | ' +--------------+-----------------------------------------------------+ ' | ULRowLM% | (U)Upper (L)left (R)row to place (L)long (M)menu. | ' +--------------+-----------------------------------------------------+ ' | ULColLM% | (U)Upper (L)left (C)column to place (L)long (M)menu.| ' +--------------+-----------------------------------------------------+ ' | LRRowLM% | (L)Lower (R)right (R)row to place (L)long (M)menu. | ' +--------------+-----------------------------------------------------+ ' | LRColLM% | (L)Lower (R)right (C)column to place (L)long (M)menu| ' +--------------+-----------------------------------------------------+ ' | LMColrFG% | (L)Long (M)menu (F)fore (G)ground color. | ' +--------------+-----------------------------------------------------+ ' | LMColrBG% | (L)Long (M)menu (B)back (G)ground color. | ' +--------------+-----------------------------------------------------+ ' | LMHiLiteFG% | (L)Long (M)menu Hilite (F)fore (G)ground color. | ' +--------------+-----------------------------------------------------+ ' | LMHiLiteBG% | (L)Long (M)menu Hilite (B)back (G)ground color. | ' +--------------+-----------------------------------------------------+ ' | FKey$ | FKey$ is set to reflect to keys. | ' | | ExitCode% is set by programs as follows: | ' | | is ExitCode% = 1 TO is ExitCode% = 10 | ' | | | ' | | Example how to set in main program: | ' | | ---------------------------------- | ' | | Example: FKey$ = "150". This means that | ' | | and are "turned on" such that if the user | ' | | presses one of these keys, the program will | ' | | exit with the appropriate ExitCode% number. By | ' | | the way, the "0" in FKey$ = "150" is used for | ' | | , and if is pressed, the SUB will exit | ' | | with ExitCode% = 10. Also read ExitCode% below. | ' +--------------+-----------------------------------------------------+ ' | MaxNum% | The maximum number of menu items. | ' +--------------+-----------------------------------------------------+ ' | Selection% | The selection which the cursor is resting on. | ' | | In main program, set Selection% = 1 | ' +--------------+-----------------------------------------------------+ ' | CurrentRow% | The current row the cursor is resting on. | ' | | In main program, set CurrentRow% = ULRowLM% | ' +--------------+-----------------------------------------------------+ ' | ExitCode% | The ExitCode% is a unique number set by the | ' | | programmer. The SUB LongMenu will exit the SUB on | ' | | three occasions, when the user presses: , | ' | | , , , or . In the main program | ' | | just below the SUB, you must write the code to take | ' | | care of these key presses. The ExitCode% may be | ' | | any number the programmer wishes. In most cases, | ' | | I prefer to use the same number as the unique | ' | | number set by the CVI command. Below find | ' | | the double DO:LOOP and Hit% = CVI(Hit$ + CHR$(0)) | ' | | | ' | | do.loop: | ' | | DO | ' | | DO | ' | | Hit$ = INKEY$ | ' | | LOOP UNTIL LEN(Hit$) > 0 | ' | | Hit% = CVI(Hit$ + CHR$(0)) | ' | | - - - - - - - - | ' | | (more code here) | ' | | - - - - - - - - | ' | | LOOP | ' | | | ' | | This double DO:LOOP sets up the special CVI | ' | | numbers; if fact, just about any key or key | ' | | combination may be trapped using the CVI code. | ' | | See KEYCODE.BAS program below. | ' | | | ' | | For the key numbers, I prefer to use | ' | | ExitCode% 1-10; this is easier than using hugh | ' | | CVI numbers like 15103 . | ' | | | ' | | I like to use the double DO:LOOP (see above), | ' | | followed by a series of IFs and ELSEIFs. | ' | | If you would like to use a special key, like | ' | | Q (4096) for example, the attached | ' | | KEYCODE.BAS will give you the CVI numbers you | ' | | need for your program. In this case Q | ' | | would be set up like this: | ' | | | ' | | (This is inside the SUB) | ' | | DO | ' | | DO | ' | | Hit$ = INKEY$ | ' | | LOOP UNTIL LEN(Hit$) > 0 | ' | | Hit% = CVI(Hit$ + CHR$(0)) | ' | | IF Hit% = 27 THEN ' | ' | | ExitCode% = 27 | ' | | ELSEIF Hit% = 4096 THEN ' Q | ' | | ExitCode% = 4096 | ' | | END IF | ' | | LOOP | ' | | | ' | | Once the SUB is exited, the code would look | ' | | something like this: | ' | | | ' | | CALL LongMenu(- - - - -stuff goes here- - - - -) | ' | | | ' | | IF ExitCode% = 27 THEN ' | ' | | LOCATE , , 1, 6, 7: END | ' | | ELSEIF ExitCode% = 4096 THEN ' Q | ' | | COLOR 15, 2: CLS | ' | | PRINT "Help Screen" | ' | | DO: LOOP WHILE INKEY$ = "" | ' | | END IF | ' | | | ' | | The CVI numbers used in the SUB LongMenu are: | ' | | -------------------------------------------- | ' | | Hit% = 18176 | ' | | Hit% = 20224 | ' | | Hit% = 20480 | ' | | Hit% = 20736 | ' | | Hit% = 19712 | ' | | Hit% = 18432 | ' | | Hit% = 18688 | ' | | Hit% = 19200 | ' | | Hit% = 65-90 Letters To | ' | | Hit% = 48-57 Numbers <0> To <9> | ' | | | ' | | Use KEYCODE.BAS program below to find the CVI | ' | | code for keys you need for your program. | ' | | | ' +--------------+-----------------------------------------------------+ ' | Use KEYCODE.BAS below to find out what the CVI numbers will be | ' | for keys you wish to trap. | ' +--------------------------------------------------------------------+ ' | ' KeyCode.Bas - By Don Smith. FreeWare and Public Domain Program. | ' | ' | ' | ' +-------------------------------------------------------------+ | ' | ' | Note: To reach the extended ASCII characters 127 to 255, | | ' | ' | press down on the key, and while pressed down, | | ' | ' | type in the number on your keypad, not the numbers | | ' | ' | above then keys. | | ' | ' +-------------------------------------------------------------+ | ' | | ' | COLOR 15, 1: CLS | ' | Top1$ = "Press a key and the KeyCode% value will be displayed." | ' | Top2$ = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" | ' | Top3$ = "(Press To Quit" | ' | COLOR 15, 1 | ' | LOCATE 2, 15: PRINT Top1$ | ' | LOCATE 3, 15: PRINT Top2$ | ' | COLOR 11, 1 | ' | LOCATE 4, 30, 0: PRINT Top3$ | ' | PRINT : PRINT | ' | COLOR 14, 1 | ' | DO | ' | DO | ' | Hit$ = INKEY$ | ' | IF Hit$ = CHR$(27) THEN | ' | PRINT | ' | LOCATE , 10: COLOR 15, 1: PRINT STRING$(62, "-"); | ' | PRINT | ' | LOCATE , 34: COLOR 11, 1: PRINT "Program Ends"; | ' | PRINT : PRINT | ' | END | ' | END IF | ' | LOOP UNTIL Hit$ <> "" | ' | Hit% = CVI(Hit$ + CHR$(0)) | ' | Key$ = STR$(Hit%) | ' | IF Hit% < 256 THEN | ' | LOCATE , 32, 0 | ' | PRINT Hit$ + SPACE$(9) + "= " + Key$ | ' | ELSEIF Hit% > 255 THEN | ' | LOCATE , 21, 0 | ' | PRINT "Extended Key" + SPACE$(9) + "= " + Key$; "" | ' | END IF | ' | LOOP | ' +--------------------------------------------------------------------+ SetPage% = LRRowLM% - ULRowLM% + 1 IF Selection% = 1 THEN Foxy% = 0 ELSEIF Selection% > 1 THEN Foxy% = Selection% - (CurrentRow% - ULRowLM%) - 1 END IF subtop: COLOR LMColrFG%, LMColrBG% FOR BringItems% = ULRowLM% TO LRRowLM% Foxy% = Foxy% + 1 LOCATE BringItems%, ULColLM%, 0 PRINT SPACE$(LRColLM% - ULColLM% + 1) IF Foxy% <= MaxNum% THEN LOCATE BringItems%, ULColLM% PRINT LM$(Foxy%) END IF NEXT Foxy% = Foxy% - (LRRowLM% - ULRowLM%) - 1 LOCATE CurrentRow%, ULColLM%, 0 COLOR LMHiLiteFG%, LMHiLiteBG% PRINT LM$(Selection%) do.loop: DO DO Hit$ = INKEY$ LOOP UNTIL LEN(Hit$) > 0 Hit% = CVI(Hit$ + CHR$(0)) LOCATE CurrentRow%, ULColLM%, 0 COLOR LMColrFG%, LMColrBG% PRINT LM$(Selection%) IF Hit% = 27 THEN ' ExitCode% = 27 EXIT SUB ELSEIF Hit% = 13 THEN ' ExitCode% = 13 EXIT SUB ELSEIF Hit% = 18176 THEN ' Selection% = 1 Foxy% = 0 CurrentRow% = ULRowLM% GOTO subtop ELSEIF Hit% = 20224 THEN ' Selection% = MaxNum% GOSUB end.james ELSEIF Hit% = 20480 THEN ' IF Selection% = MaxNum% THEN GOTO subtop END IF Selection% = Selection% + 1 SetCurrSel% = Selection% IF CurrentRow% > LRRowLM% - 1 THEN CurrentRow% = LRRowLM% Foxy% = Foxy% + 1 GOTO subtop END IF IF CurrentRow% <= LRRowLM% AND Selection% <= MaxNum% THEN CurrentRow% = CurrentRow% + 1 ELSEIF Selection% > MaxNum% THEN Selection% = MaxNum% END IF ELSEIF Hit% = 20736 OR Hit% = 19712 THEN ' Foxy% = Selection% + (LRRowLM% - CurrentRow%) SetCurrSel% = Selection% TempRow% = CurrentRow% Selection% = Selection% + SetPage% IF Selection% >= MaxNum% THEN Selection% = MaxNum% CurrentRow% = TempRow% + (MaxNum% - SetCurrSel%) IF CurrentRow% > LRRowLM% THEN CurrentRow% = LRRowLM% END IF Foxy% = Selection% - SetPage% + (LRRowLM% - CurrentRow%) GOTO subtop GOTO do.loop END IF GOTO subtop ELSEIF Hit% = 18432 THEN ' Selection% = Selection% - 1 IF CurrentRow% > ULRowLM% THEN CurrentRow% = CurrentRow% - 1 ELSEIF CurrentRow% = ULRowLM% THEN CurrentRow% = ULRowLM% IF Selection% >= 1 THEN Foxy% = Foxy% - 1 GOTO subtop ELSE Selection% = 1 END IF END IF ELSEIF Hit% = 18688 OR Hit% = 19200 THEN ' Selection% = Selection% - SetPage% Foxy% = Selection% - SetPage% + (LRRowLM% - CurrentRow%) IF Selection% < 1 THEN Selection% = 1 Foxy% = 0 CurrentRow% = ULRowLM% GOTO subtop END IF IF Foxy% < 0 THEN Selection% = 1 CurrentRow% = ULRowLM% Foxy% = 0 END IF GOTO subtop 'PRESS: Letters A - Z (or a - z), Numbers 0 - 9, ' Exclamation , or Underline <_>. ELSEIF Hit% > 64 AND Hit% < 91 OR Hit% > 96 AND Hit% < 123 OR Hit% > 47 AND Hit% < 58 OR Hit% = 33 OR Hit% = 95 THEN IF Hit% > 96 AND Hit% < 123 THEN Hit% = Hit% - 32 END IF FOR XYZ% = 1 TO MaxNum% Letr$ = LEFT$(LM$(XYZ%), 1) IF XYZ% = MaxNum% AND ASC(Letr$) <> Hit% THEN GOTO subtop ELSEIF ASC(Letr$) = Hit% THEN EXIT FOR END IF NEXT TryLetters% = TryLetters% + 1 FOR ZZZ% = TryLetters% TO MaxNum% FindLetr$ = LEFT$(LM$(ZZZ%), 1) IF ASC(FindLetr$) = Hit% THEN Selection% = ZZZ% TryLetters% = ZZZ% CurrentRow% = ULRowLM% Foxy% = Selection% - 1 IF ZZZ% = MaxNum% THEN Selection% = MaxNum% TryLetters% = 0 END IF GOTO subtop END IF IF ZZZ% = MaxNum% THEN ZZZ% = 0 END IF NEXT ELSEIF Hit% > 15103 AND Hit% < 17409 THEN 'F1 - F10 IdentKey$ = STR$(((Hit% - 15104) \ 256) + 1) IdentKey$ = LTRIM$(RTRIM$(IdentKey$)) IF IdentKey$ = "10" THEN IdentKey$ = "0" END IF IF INSTR(FKey$, IdentKey$) > 0 THEN IF IdentKey$ = "0" THEN ExitCode% = 10 EXIT SUB ELSE ExitCode% = VAL(IdentKey$) EXIT SUB END IF END IF END IF LOCATE CurrentRow%, ULColLM%, 0 COLOR LMHiLiteFG%, LMHiLiteBG% PRINT LM$(Selection%) LOOP end.james: CurrentRow% = LRRowLM% Selection% = MaxNum% Foxy% = MaxNum% - (LRRowLM% - ULRowLM%) - 1 GOTO subtop RETURN END SUB SUB SaveRestScrn (ReadLine$(), ReadColr%(), SR.UL.Row%, SR.UL.Col%, SR.LR.Row%, SR.LR.Col%, SaveOrRest%) '+----------------------------------------------------------------------+ '| SUB written by Don Smith on 03/25/02 - Public Domain FreeWare. | '| No need to name Don as the author. EMail: smithdonb@earthlink.net | '+----------------------------------------------------------------------+ '+----------------------------------------------------------------------+ '| PROGRAM SETS NUMBERS 1 AND 2 -> | '+------------------+---------------------------------------------------+ '| (1) ReadLine$() | Program self reads data at each Row and Column | '+------------------+---------------------------------------------------+ '| (2) ReadColr%() | Program self reads color at each Row and Column | '+------------------+---------------------------------------------------+ '+----------------------------------------------------------------------+ '| THE PROGRAMMER MUST SET NUMBERS 3 TO 9 -> | '+----------------------------------------------------------------------+ '| (Note: The "SR" below means "Save" Or "Restore") | '+------------------+---------------------------------------------------+ '| (3) SR.UL.Row% | Screen to save or restore at upper left row. | '| (4) SR.UL.Col% | Screen to save or restore at upper left column. | '| (5) SR.LR.Row% | Screen to save or restore at lower right row. | '| (6) SR.LR.Col% | Screen to save or restore at lower right column.| '| +---------------------------------------------------+ '| | SPECIAL CAUTION: | '| | --------------- | '| | When you call the SUB to restore the underlying | '| | screen, use MUST use the same row and column | '| | numbers as you used when you first called the | '| | SUB to save the screen. | '+------------------+---------------------------------------------------+ '| (7) SaveOrRest% | SaveOrRest% = 1 (1 means save the screen) | '| | SaveOrRest% = 2 (2 means restore the screen) | '+------------------+----------+----------------------------------------+ '| (8) REDIM ReadLine$(25) | The REDIM for ReadLine$ and ReadColr% | '| REDIM ReadColr%(25, 80) | must be placed in the main program | '| | before calling the SUB. The 25 and 80 | '| | reflects a screen of 25 lines and 80 | '| | columns. You may use smaller amounts | '| | of memory if you do not need all 25 | '| | lines and 80 columns. | '+-----------------------------+----------------------------------------+ '| (9) ERASE ReadLine$ | Reclaim memory after calling the SUB | '| ERASE ReadColr% | to restore the screen. Use REDIM and | '| | ERASE in main program please! | '+-----------------------------+----------------------------------------+ IF SR.LR.Col% > 80 THEN SR.LR.Col% = 80 END IF IF SR.LR.Row% > 25 THEN SR.LR.Row% = 25 END IF IF SaveOrRest% = 1 THEN GOSUB save.da.screen ELSEIF SaveOrRest% = 2 THEN GOSUB restore.da.screen END IF EXIT SUB save.da.screen: FOR ViewIt% = SR.UL.Row% TO SR.LR.Row% FOR Horizon% = SR.UL.Col% TO SR.LR.Col% ReadLine$(ViewIt%) = ReadLine$(ViewIt%) + CHR$(SCREEN(ViewIt%, Horizon%)) ReadColr%(ViewIt%, Horizon%) = SCREEN(ViewIt%, Horizon%, 1) NEXT NEXT RETURN restore.da.screen: FOR FindRow% = SR.UL.Row% TO SR.LR.Row% FOR ScrnCol% = SR.UL.Col% TO SR.LR.Col% LOCATE FindRow%, ScrnCol%, 0 OneColr% = ReadColr%(FindRow%, ScrnCol%) FGScrnColr% = OneColr% MOD 16 BGScrnColr% = OneColr% \ 16 COLOR FGScrnColr%, BGScrnColr% PRINT MID$(ReadLine$(FindRow%), ScrnCol% - (SR.UL.Col% - 1)); NEXT NEXT RETURN END SUB