home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / library / qb_pds / quicksub / key.asc < prev    next >
Encoding:
Text File  |  1986-06-12  |  1.5 KB  |  66 lines

  1. ' KEY.ASC -- MSDOS QuickBASIC test program for the GETKEY.SUB subroutines
  2.  
  3. '   Compile syntax: BASCOM KEY.ASC /D; |  LINK KEY;
  4.     
  5.     PRINT "GETKEY.SUB test . . ."
  6.     GOSUB GETKEY.PRESS
  7.     CLS
  8.     PRINT "Well, GETKEY.PRESS seems to work"
  9.     PRINT
  10.     TEMP$ = ""
  11.  
  12.     PRINT "Type in a short string "
  13.     LINE INPUT "of mixed-case characters: ";IN$
  14.  
  15.     ' Loop to convert a string to all CAPS
  16.     FOR I = 1 TO LEN(IN$)
  17.         Q$= MID$(IN$,I)
  18.         GOSUB GETKEY.CAPS
  19.         TEMP$ = TEMP$ + Q$
  20.     NEXT
  21.  
  22.     PRINT
  23.     PRINT "Here's your string in all CAPS:"
  24.     PRINT
  25.     PRINT TAB (40 - LEN(TEMP$)/2) TEMP$
  26.     GOSUB GETKEY.PRESS
  27.  
  28.     LOCATE 16,10
  29.     PRINT "In this last test, press any key"
  30.  
  31. LOOP:
  32.     LOCATE 18,1
  33.         PRINT " Press <ESC> to exit this test and the program"
  34.     PRINT "Press a key . ."
  35.  
  36.     ' You can mix line numbers with line names
  37. 1    Q$ = INKEY$
  38.     IF Q$ = ""                            _
  39.        THEN 1
  40.  
  41.     ' Get the extended key code & ASCII code of the key just pressed
  42.     GOSUB GETKEY.CODE
  43.     PRINT "ASCII key code is";K.CODE
  44.     PRINT " Extended code is";E.CODE
  45.     PRINT "     Character is ";CHR$(K.CODE)
  46.     DLY = 2                    ' 2 seconds delay
  47.     GOSUB DELAY
  48.     CLS
  49.  
  50.     WHILE INKEY$ <> ""            ' Clear the keyboard buffer
  51.     WEND
  52.  
  53.     IF K.CODE = 27                            _
  54.        AND E.CODE = 0                        _
  55.            THEN GOTO LOOP.XIT                    _
  56.            ELSE GOTO LOOP
  57.  
  58. LOOP.XIT:
  59.     COLOR 14 , 3 , 8            'My normal screen colors
  60.     CLS                    ' change to your preference
  61.     SYSTEM
  62.  
  63.     REM    $INCLUDE: 'GETKEY.SUB'
  64.     REM    $INCLUDE: 'DELAY.SUB'
  65. ' >>>>> Physical EOF
  66.