home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / h / htmix20.zip / MISC.ZIP / SETKEY.PAS < prev    next >
Pascal/Delphi Source File  |  1992-07-11  |  4KB  |  112 lines

  1. program SetKey;
  2. {┌──────────────────────────────── INFO ────────────────────────────────────┐}
  3. {│ File    : SETKEY.PAS                                                     │}
  4. {│ Author  : Harald Thunem                                                  │}
  5. {│ Purpose : Set keyboard typematic rate and delay.                         │}
  6. {│ Updated : July 10 1992                                                   │}
  7. {└──────────────────────────────────────────────────────────────────────────┘}
  8.  
  9. {────────────────────────── Compiler directives ─────────────────────────────}
  10. {$A+   Word align data                                                       }
  11. {$B-   Short-circuit Boolean expression evaluation                           }
  12. {$E-   Disable linking with 8087-emulating run-time library                  }
  13. {$G+   Enable 80286 code generation                                          }
  14. {$R-   Disable generation of range-checking code                             }
  15. {$S-   Disable generation of stack-overflow checking code                    }
  16. {$V-   String variable checking                                              }
  17. {$X-   Disable Turbo Pascal's extended syntax                                }
  18. {$N+   80x87 code generation                                                 }
  19. {$D-   Disable generation of debug information                               }
  20. {────────────────────────────────────────────────────────────────────────────}
  21.  
  22. uses Dos;
  23.  
  24. var Sub1,
  25.     Sub2,
  26.     s1,s2: string;
  27.     Delay,
  28.     Rate : byte;
  29.  
  30.  
  31. function UpcaseStr(s: string): string;
  32. var i: byte;
  33. begin
  34.   for i := 1 to Length(s) do
  35.     s[i] := Upcase(s[i]);
  36.   UpcaseStr := s;
  37. end;
  38.  
  39. function StrToInt(s: string): byte;
  40. var v,code: integer;
  41. begin
  42.   Val(s,v,code);
  43.   if code=0 then
  44.     StrToInt := v
  45.   else StrToInt := $00;
  46. end;
  47.  
  48.  
  49. procedure SetRate(Delay,Rate: byte);
  50. var  Regs: registers;
  51. begin
  52.   FillChar(Regs,SizeOf(Regs),$00);
  53.   Regs.AH := $03;
  54.   Regs.AL := $05;
  55.   Regs.BH := Delay;
  56.   Regs.BL := Rate;
  57.   Intr($16,Regs);
  58. end;
  59.  
  60.  
  61. procedure Info;
  62. begin
  63.   WriteLn('Program : SETKEY 1.0');
  64.   WriteLn('Author  : Harald Thunem');
  65.   WriteLn('Purpose : Set the keyboard typematic rate and delay');
  66.   WriteLn('Updated : July 10 1992');
  67.   WriteLn('Usage   : SETKEY [D=x R=y] [/fastkey]');
  68.   WriteLn;
  69.   WriteLn('  SetKey sets the typematic rate and delay for the keyboard. The delay D');
  70.   WriteLn('  is given as an integer x in the range [0-3], corresponding to a delay of');
  71.   WriteLn('  250-1000 microseconds. The typematic rate R is given as an integer y');
  72.   WriteLn('  in the range [0-31], corresponding to a rate of 30.0 - 2.0 characters');
  73.   WriteLn('  per second. A shortcut to get the shortest delay and fastest typematic');
  74.   WriteLn('  rate, is to give the parameter /fastkey.');
  75.   WriteLn;
  76.   WriteLn('  Ex.  SETKEY D=0 R=0 {which equals SETKEY /fastkey}');
  77.   WriteLn;
  78.   Halt(1);
  79. end;
  80.  
  81.  
  82. begin
  83.   Delay := $00;
  84.   Rate  := $00;
  85.   WriteLn('SetKey 1.0                                                   Written by H.Thunem');
  86.   if ParamCount=0 then
  87.     Info;
  88.   s1 := UpcaseStr(ParamStr(1));
  89.   if ParamCount>1 then
  90.     s2 := UpcaseStr(ParamStr(2));
  91.   if s1='/FASTKEY' then
  92.   begin
  93.     Delay := $00;
  94.     Rate  := $00;
  95.   end
  96.   else
  97.   begin
  98.     if Pos('/',s1)>0 then
  99.       Delete(s1,Pos('/',s1),1);
  100.     if Pos('/',s2)>0 then
  101.       Delete(s2,Pos('/',s2),1);
  102.     Sub1 := Copy(s1,3,Length(s1)-2);
  103.     Sub2 := Copy(s2,3,Length(s2)-2);
  104.     if s1[1]='D' then Delay:=StrToInt(Sub1);
  105.     if s1[1]='R' then Rate:=StrToInt(Sub1);
  106.     if s2[1]='D' then Delay:=StrToInt(Sub2);
  107.     if s2[1]='R' then Rate:=StrToInt(Sub2);
  108.     if Delay>3 then Delay:=3;
  109.     if Rate>31 then Rate:=31;
  110.   end;
  111.   SetRate(Delay,Rate);
  112. end.