REM $STATIC DEFINT A-Z SUB HorizMenu (MenuItem$(), Row%(), Col%(), MaxItems%, Items%, TempItems%, SpotColr%, TopFGColr%, TopBGColr%, TopHiLiteFG%, TopHiLiteBG%, TypeOfKey$, Hit%) ' +------------------------------------------------------------------+ ' | SUB HorizMenu | ' +------------------------------------------------------------------+ ' | Not counting REM (') lines, SUB HorizMenu has 65 lines. | ' +------------------------------------------------------------------+ ' | HorizMen.Bas written by Don Smith on 10/01/2002; HorizMen.Bas is | ' | Public Domain FreeWare. HorizMen.Bas will present a horizontal | ' | menu and hi-light the horizontal menu items as the | ' | or keys are pressed. The row and column are given | ' | as part of the set up. There is no need to name Don as | ' | the author. | ' +------------------------------------------------------------------+ ' | | ' | EMail: smithdonb@earthlink.net | ' | | ' +------------+-----------------------------------------------------+ ' | MenuItem$()| Menu items to display horizontally. These menu | ' | | items, together with the row/column need to be | ' | | REDIMmed in the main module: | ' | | | ' | | Example -->>> REDIM Row%(MaxItems%) | ' | | REDIM Col%(MaxItems%) | ' | | REDIM Item$(MaxItems%) | ' | | | ' | | Please be aware that the first letter of each | ' | | menu item will be hi-lighted with SpotColr%. | ' | | It would be best to list menu items which have | ' | | different first letters so that, in the case | ' | | that a letter is pressed, there will only one | ' | | letter to consider. | ' +------------+------------------------------+----------------------+-+ ' | Row%() | Row of menu item. Each menu | Row% & Col% Example: | ' | | item needs row and column.->| ------------------- | ' +------------+----------------------------+-+ Row%(1) = 1 | ' | Col%() | Colunn of menu item. Each | Col%(1) = 5 | ' | | menu item needs row/column | MenuItem$(1) = " File "| ' +------------+------------------------------+ | ' | MaxItems% | Total number of menu items | Row%(2) = 1 | ' +------------+------------------------------+ Col%(2) = 16 | ' | Items% | The menu item selected. | MenuItem$(2) = " Text "| ' +------------+------------------------------+----------------------+-+ ' | TempItems% | Temporary menu item. SUB needs this to convey | ' | | a previous menu item. | ' +------------+-----------------------------------------------------+ ' | SpotColr% | The foreground color with which to hi-light | ' | | letters/numbers so designated by TypeOfKey$. | ' | | This SpotColr% will function both for the | ' | | regular menu color, and when the menu item is | ' | | hi-lighted. If the regular menu color is | ' | | COLOR 0, 7 and the SpotColr% is 15, then the | ' | | first letter of the menu item will be COLOR 15, 7. | ' +------------+-----------------------------------------------------+ ' | TopFGColr% | Foreground color of menu item (0-15). | ' +------------+-----------------------------------------------------+ ' | TopBGColr% | Background color of menu item (1-7). | ' +------------+-----------------------------------------------------+ ' | TopHiLiteFG% | Foreground color of hi-lighted menu item (0-15).| ' +------------+-----------------------------------------------------+ ' | TopHiLiteBG% | Background color of hi-lighted menu item (0-7). | ' +------------+-----------------------------------------------------+ ' | TypeOfKey$ | Numbers or letters that the SUB will respond to. | ' | | Example: TypeOfKey$ = "FEVSR" The SUB will | ' | | jump to the correct menu item upon pressing | ' | | "F-E-V-S-R". Also, the appropriate TypeOfKey$ | ' | | letter will be hi-lighted; these TypeOfKey$ | ' | | letters should be the first letter of each | ' | | menu item. Refer to MenuItem$ above. | ' | | . . . . . . . . . . . . . . . . | ' | | If TypeOfKey$ = "" then, when a key "F-E-V-S-R" | ' | | is pressed, nothing will happen. | ' +------------+-----------------------------------------------------+ ' | Hit% | The CVI number of a key pressed. If the key | ' | | pressed is an ASCII key, then CVI will report the | ' | | ASCII number. If the key pressed is an extended | ' | | key like , the number will be a unique CVI | ' | | number. The HorizMenu SUB will exit if , a | ' | | , a or is pressed. The | ' | | or must have been so stipulated | ' | | in TypeOfLetrs$. If another letter/number not so | ' | | stipulated is pressed, it will be ignored. The | ' | | Hit% number or Items% number may be used upon | ' | | exiting the SUB. | ' | | | ' | | +---------------------------------+ | ' | | | CVI Number | | ' | | +----------------+----------------+ | ' | | | Key Pressed: | ASCII Number: | | ' | | +----------------+----------------+ | ' | | | .........|....27 | | ' | | | .......|....13 | | ' | | | Numbers 0-9...|....48 - 57 | | ' | | | Letters A-Z...|....65 - 90 | | ' | | | Letters a-z...|....97 - 122 | | ' | | +----------------+----------------+ | ' | | | ' | | Since the above Hit% 0-9 numbers are ASCII | ' | | numbers, to change them to regular numericals, | ' | | use: | ' | | MenNum% = ASC(CHR$(Hit%)) | ' | | | ' | | Extended CVI numbers: | ' | | -------------------- | ' | | Hit% = 15104 is the key. | ' | | Hit% = 17408 is the key | ' | | | ' | | To find other values for Hit%, like , | ' | | refer to KeyCode.Bas just below. This short | ' | | program allows QuickBASIC programmers the ability | ' | | to trap every key on the keyboard. The basic | ' | | ingredient is the CVI command. To use this | ' | | command, make 2 DO/LOOPs and a series of IF, | ' | | ELSEIF and END IFs. Example -> | ' | | | ' | | DO | ' | | DO | ' | | Hit$ = INKEY$ | ' | | LOOP UNTIL LEN(Hit$) > 0 | ' | | Hit% = CVI(Hit$ + CHR$(0)) '<- CVI made here! | ' | | IF Hit% = 27 THEN ' pressed | ' | | END | ' | | ELSEIF Hit% = 13 THEN ' pressed | ' | | GOSUB date.info | ' | | ELSEIF Hit% = 15104 THEN ' pressed | ' | | GOSUB F1.Info | ' | | END IF | ' | | LOOP | ' +------------+-----------------------------------------------------+ ' +--------------------------------------------------------------------+ ' | 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. | ' | ' Date: 09/01/2002. | ' | ' +-------------------------------------------------------------+ | ' | ' | 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 14, 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 | ' | | ' +--------------------------------------------------------------------+ TempItems% = Items% FOR Items% = 1 TO MaxItems% GOSUB paint.regular NEXT Items% = TempItems% DO GOSUB paint.hi.lite DO Hit$ = INKEY$ LOOP UNTIL LEN(Hit$) > 0 Hit% = CVI(Hit$ + CHR$(0)) GOSUB paint.regular IF Hit% = 27 THEN ' ExitCode% = 27 EXIT SUB ELSEIF Hit% > 47 AND Hit% < 123 THEN '0-9 & A-Z TypeOfKey$ = UCASE$(TypeOfKey$) IF TypeOfKey$ <> "" THEN Burst% = INSTR(TypeOfKey$, RTRIM$(LTRIM$(UCASE$(CHR$(Hit%))))) Hit% = Burst% + 48 TempItems% = Items% GOSUB paint.regular EXIT SUB END IF ELSEIF Hit% = 13 OR Hit% = 20480 THEN ' Hit% = Items% + 48 TempItems% = Items% GOSUB paint.hi.lite EXIT SUB ELSEIF Hit% = 19200 THEN ' Items% = Items% - 1 IF Items% < 1 THEN Items% = MaxItems% END IF ELSEIF Hit% = 19712 OR Hit% = 9 THEN ' / Items% = Items% + 1 IF Items% > MaxItems% THEN Items% = 1 END IF ELSEIF Hit% = 15104 THEN ' Hit% = 1 EXIT SUB ELSEIF Hit% = 17408 THEN ' Hit% = 10 EXIT SUB END IF LOOP paint.hi.lite: COLOR TopHiLiteFG%, TopHiLiteBG% SpotColrBG% = TopHiLiteBG% GOSUB paint.menu.items RETURN paint.regular: COLOR TopFGColr%, TopBGColr% SpotColrBG% = TopBGColr% GOSUB paint.menu.items RETURN paint.menu.items: LOCATE Row%(Items%), Col%(Items%), 0 PRINT MenuItem$(Items%); FrstLetr$ = LEFT$(RTRIM$(LTRIM$(MenuItem$(Items%))), 1) COLOR SpotColr%, SpotColrBG% LOCATE Row%(Items%), Col%(Items%) + 1, 0 PRINT FrstLetr$; RETURN END SUB