home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / MAGAZINE / MISC / ITPMAR90.ZIP / KBSETUP.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1990-02-22  |  1.9 KB  |  76 lines

  1. {***********************************************
  2. * KBSETUP - set the desired delay/repeat rate  *
  3. * for the keyboard.                            *
  4. ***********************************************}
  5.  
  6. USES
  7.     Dos;
  8.  
  9. PROCEDURE Usage;
  10.   BEGIN
  11.     WriteLn;
  12.     WriteLn('KBSETUP Command format:');
  13.     WriteLn;
  14.     WriteLn('KBSETUP  n {A | B | C | D} ');
  15.     WriteLn;
  16.     Write  ('n            A number from 0 to 31');
  17.     WriteLn(' to set the keyboard repeat rate.');
  18.     Write  ('             0 is the fastest and');
  19.     WriteLn(' 31 is the slowest.');
  20.     WriteLn;
  21.     Write  ('A,B,C or D   Sets the keyboard');
  22.     WriteLn(' delay before repeating');
  23.     Write  ('             to 1/4, 1/2, 3/4 and');
  24.     WriteLn(' 1 second.');
  25.     Halt(1);
  26.   END;
  27.  
  28. VAR
  29.   KBDelay, KBRepeat, I : byte;
  30.   Code                 : integer;
  31.   Regs                 : Registers;
  32.   KeyString            : string[1];
  33.  
  34. BEGIN
  35.  
  36.   KBDelay := 0;
  37.   KBRepeat := 0;
  38.  
  39.   IF ParamCount = 0 THEN
  40.     Usage
  41.   ELSE
  42.     BEGIN
  43.       FOR I := 1 TO ParamCount DO
  44.         BEGIN
  45.           KeyString := ParamStr(I);
  46.         IF UpCase(KeyString[1]) in ['A'..'D'] THEN
  47.           KBDelay := Ord(UpCase(KeyString[1]))
  48.                        - Ord('A')
  49.         ELSE
  50.           BEGIN
  51.              {$R-}
  52.             Val(ParamStr(I),KBRepeat,Code);
  53.              {$R+}
  54.             IF (Code <> 0) or (KBRepeat < 0) or
  55.                (KBRepeat > 31) THEN
  56.               BEGIN
  57.                 Write('-- Invalid Letter or');
  58.                 Write(' Number Entered --> ');
  59.                 WriteLn(ParamStr(I));
  60.                 Usage
  61.               END
  62.           END
  63.         END;
  64.  
  65.     { Set the keyboard delay/repeat rate }
  66.  
  67.       WITH Regs DO
  68.         BEGIN
  69.           AX := $0305;
  70.           BH := KBDelay;
  71.           BL := KBRepeat;
  72.           Intr($16,Regs)
  73.         END
  74.     END {of the IF/THEN/ELSE instruction}
  75. END.
  76.