home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / progjour / 1991 / 01 / menukey.prg < prev    next >
Text File  |  1990-06-04  |  3KB  |  86 lines

  1. *** MENUKEY.PRG
  2. *   Author:     M. Steven Baker
  3.  
  4. private m_row,m_col
  5.  
  6. notfound = .T.
  7. DO WHILE notfound
  8.     IF (remenu)
  9.         @ 23,0 CLEAR to 24,79     && clear menubar area
  10.         @ 23,3 SAY menuline
  11.         IF (menusel <1 .OR. menusel > menu_max)
  12.             menusel = 1
  13.         ENDIF
  14.         SET COLOR TO N/W
  15.         @ 23,VAL(SUBSTR(menubar(menusel),1,2)) ;
  16.             SAY SUBSTR(menubar(menusel),3,LEN(menubar(menusel))-2)
  17.         SET COLOR TO W/N
  18.         @ 24,3 SAY menuhelp(menusel)
  19.     ENDIF
  20.  
  21.     badkey = .T.
  22.     DO WHILE (badkey)
  23.         choice = 0
  24.         DO WHILE (choice = 0)
  25.             choice = inkey()
  26.         ENDDO
  27.  
  28.         m_row = row()             && save cursor position
  29.         m_col =col()
  30.         @ 0,60 CLEAR to 0,78      && clear error line at top
  31.         @ m_row,m_col SAY ""      && restore cursor position
  32.         IF (choice >32 .AND. choice <127)   && an ASCII char?
  33.             choice = UPPER(CHR(choice))
  34.             m = 1
  35.             DO WHILE (m <= menu_max .AND. badkey)
  36.                 IF ( SUBSTR(menuchoice,m,1) = choice)
  37.                     notfound = .F.
  38.                     badkey = .F.
  39.                     menusel = m
  40.                 ELSE
  41.                     m = m+1
  42.                 ENDIF
  43.             ENDDO
  44.         ELSE
  45.             badkey = .F.
  46.             DO CASE
  47.                 CASE choice = 4      && right arrow
  48.                     IF (menusel < menu_max )
  49.                         menusel = menusel +1
  50.                     ELSE
  51.                         menusel = 1
  52.                     ENDIF
  53.                     choice = SUBSTR(menuchoice,menusel,1)
  54.                 CASE choice = 19    && left arrow
  55.                     IF (menusel = 1)
  56.                         menusel = menu_max
  57.                     ELSE
  58.                         menusel = menusel - 1
  59.                     ENDIF
  60.                     choice = SUBSTR(menuchoice,menusel,1)
  61.                 CASE choice = 13    && return
  62.                     choice = SUBSTR(menuchoice,menusel,1)
  63.                     notfound = .F.
  64.                 CASE choice = 32      && space bar - advance right
  65.                     IF (menusel < menu_max )
  66.                         menusel = menusel +1
  67.                     ELSE
  68.                         menusel = 1
  69.                     ENDIF
  70.                     choice = SUBSTR(menuchoice,menusel,1)
  71.                 CASE choice = 9      && tab key - advance right
  72.                     IF (menusel < menu_max )
  73.                         menusel = menusel +1
  74.                     ELSE
  75.                         menusel = 1
  76.                     ENDIF
  77.                     choice = SUBSTR(menuchoice,menusel,1)
  78.                 OTHERWISE
  79.                     badkey = .T.
  80.                     notfound = .T.
  81.             ENDCASE
  82.         ENDIF
  83.     ENDDO     && do while(badkey)
  84. ENDDO   && while notfound
  85. RETURN
  86.