home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / bix / chain.pas < prev    next >
Pascal/Delphi Source File  |  1986-08-04  |  2KB  |  48 lines

  1. {Turbo/PC&MSDOS/IBMs & comps - Chain to ANY pgm or DOS Command/KBD stuff rtn.}
  2.  
  3. The following program contains a keyboard buffer stuffing routine (KBDStuff)
  4. that allows a Turbo program to chain to another program and/or DOS command.
  5. The effect is the same as if the user had typed in the string of characters
  6. passed to KBDStuff. It's based on code posted by Barry Nance in
  7. basic/crosscode #39 and on a quick & dirty posted by Jim Keohane in
  8. assembler/cpu8088 #143.     - Jim
  9.  
  10. Program TChain;
  11.  
  12.       {
  13.       Copyright (c) 1986 Barry R. Nance
  14.       Turbo version and other modifications by Jim Keohane
  15.       }
  16.  
  17. Type AnyString=String[255];
  18.  
  19. var s:anystring;
  20.  
  21. Procedure KBDStuff(Keys:Anystring);
  22.  
  23. {empties keyboard buffer then stuffs the contents of Keys into buffer}
  24. {does nothing if keyboard buffer is not large enough to hold all!!!}
  25. {has to be expanded inorder to stuff function keys or Alt combos, etc.}
  26.  
  27. Var Buffer_Head:integer absolute $40:$1a;
  28.     Buffer_Tail:integer absolute $40:$1c;
  29.     Buffer_Start:integer absolute $40:$80;
  30.     Buffer_End:integer absolute $40:$82;
  31.     i:integer;
  32. Begin
  33.  If (Buffer_End-Buffer_Start-2) div 2 > Length(Keys) then
  34.   {if keyboard buffer is big enough!}
  35.   begin
  36.    Buffer_Head:=Buffer_Start;
  37.    Buffer_Tail:=Buffer_Head+2*Length(Keys);
  38.    For I:=1 to Length(Keys) Do
  39.      MemW[$40:Buffer_Start+2*I-2] := Ord(Keys[I]);
  40.   End
  41. End;
  42.  
  43. Begin
  44. write('Enter next program to run or a dos command...');readln(s);
  45. KBDStuff(s+#13);
  46. {KBDStuff should be the last thing you do in your pgm before exit}
  47. end.
  48.