home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / ins_msb / 9005 / kbsetup.bas < prev    next >
BASIC Source File  |  1990-05-01  |  2KB  |  102 lines

  1. DEFINT A-Z
  2. DECLARE FUNCTION GetParms% (Parms$())
  3. DECLARE SUB SetKBDRate (KBDelay AS INTEGER,_
  4.                         KBRepeat AS INTEGER)
  5. DECLARE SUB Usage ()
  6.  
  7. 'PROGRAM - KBSETUP.BAS
  8.  
  9. ' Set the desired delay/repeat rate
  10. ' for the keyboard.
  11.  
  12. 'BASIC Version 7.0 users should change the next
  13. 'line to load the QBX.BI file
  14.  
  15. '$INCLUDE: 'QB.BI'
  16.  
  17.   DIM ParamStr$(2)
  18.  
  19.   KBDelay = 0
  20.   KBRepeat = 0
  21.  
  22.   ParamCount = GetParms(ParamStr$())
  23.  
  24.   IF ParamCount = 0 THEN
  25.      Usage
  26.   ELSE
  27.      FOR I = 1 TO ParamCount
  28.         KeyString$ = UCASE$(LEFT$(ParamStr$(I), 1))
  29.         IF KeyString$ >= "A" AND_
  30.            KeyString$ <= "D" THEN
  31.           KBDelay = ASC(KeyString$) - ASC("A")
  32.         ELSE
  33.           KBRepeat = VAL(ParamStr$(I))
  34.           IF (KBRepeat < 0) OR (KBRepeat > 31) THEN
  35.              PRINT "-- Invalid Letter or "; ""
  36.              PRINT " Number Entered -->  "; ""
  37.              PRINT (ParamStr$(I))
  38.              Usage
  39.           END IF
  40.         END IF
  41.       NEXT I
  42.  
  43. '   * Set the keyboard delay/repeat rate *
  44.  
  45.         SetKBDRate KBDelay, KBRepeat
  46.         
  47.      END IF
  48.  
  49. FUNCTION GetParms% (Parms$())
  50. CONST True = -1, False = 0
  51.   Ub = UBOUND(Parms$)
  52.   Cmd$ = COMMAND$
  53.   GetParms = 0
  54.   IF LEN(Cmd$) <> 0 THEN
  55.      Inside = 0
  56.      ParmNbr = 0
  57.      FOR I = 1 TO LEN(Cmd$)
  58.         Ch$ = MID$(Cmd$, I, 1)
  59.         IF Ch$ <> CHR$(9) AND Ch$ <> " " THEN
  60.           IF NOT Inside THEN
  61.              ParmNbr = ParmNbr + 1
  62.              IF ParmNbr > Ub THEN EXIT FUNCTION
  63.              Inside = True
  64.           END IF
  65.           Parms$(ParmNbr) = Parms$(ParmNbr) + Ch$
  66.         ELSE
  67.           Inside = False
  68.         END IF
  69.      NEXT I
  70.   ELSE
  71.      EXIT FUNCTION
  72.   END IF
  73.   GetParms = ParmNbr
  74. END FUNCTION
  75.  
  76. DEFSNG A-Z
  77. SUB SetKBDRate (KBDelay AS INTEGER,_
  78.                 KBRepeat AS INTEGER)
  79.   DIM InRegs AS RegType, OutRegs AS RegType
  80.   InRegs.ax = &H305
  81.   InRegs.bx = KBDelay * 256 + KBRepeat
  82.   CALL Interrupt(&H16, InRegs, OutRegs)
  83. END SUB
  84.  
  85. SUB Usage
  86.      PRINT
  87.      PRINT "KBSETUP Command format: "
  88.      PRINT
  89.      PRINT "KBSETUP  n {A | B | C | D}  "
  90.      PRINT
  91.      PRINT "n  A number from 0 to 31 "
  92.      PRINT "   to set the keyboard repeat rate. "
  93.      PRINT "   0 is the fastest and "
  94.      PRINT "   31 is the slowest. "; ""
  95.      PRINT
  96.      PRINT "A,B,C or D Sets the keyboard "
  97.      PRINT "           delay before repeating "
  98.      PRINT "           to 1/4, 1/2, 3/4 and "
  99.      PRINT "           1 second"
  100. END SUB
  101.  
  102.