home *** CD-ROM | disk | FTP | other *** search
- {Turbo/PC&MSDOS/IBMs & comps - Chain to ANY pgm or DOS Command/KBD stuff rtn.}
-
- The following program contains a keyboard buffer stuffing routine (KBDStuff)
- that allows a Turbo program to chain to another program and/or DOS command.
- The effect is the same as if the user had typed in the string of characters
- passed to KBDStuff. It's based on code posted by Barry Nance in
- basic/crosscode #39 and on a quick & dirty posted by Jim Keohane in
- assembler/cpu8088 #143. - Jim
-
- Program TChain;
-
- {
- Copyright (c) 1986 Barry R. Nance
- Turbo version and other modifications by Jim Keohane
- }
-
- Type AnyString=String[255];
-
- var s:anystring;
-
- Procedure KBDStuff(Keys:Anystring);
-
- {empties keyboard buffer then stuffs the contents of Keys into buffer}
- {does nothing if keyboard buffer is not large enough to hold all!!!}
- {has to be expanded inorder to stuff function keys or Alt combos, etc.}
-
- Var Buffer_Head:integer absolute $40:$1a;
- Buffer_Tail:integer absolute $40:$1c;
- Buffer_Start:integer absolute $40:$80;
- Buffer_End:integer absolute $40:$82;
- i:integer;
- Begin
- If (Buffer_End-Buffer_Start-2) div 2 > Length(Keys) then
- {if keyboard buffer is big enough!}
- begin
- Buffer_Head:=Buffer_Start;
- Buffer_Tail:=Buffer_Head+2*Length(Keys);
- For I:=1 to Length(Keys) Do
- MemW[$40:Buffer_Start+2*I-2] := Ord(Keys[I]);
- End
- End;
-
- Begin
- write('Enter next program to run or a dos command...');readln(s);
- KBDStuff(s+#13);
- {KBDStuff should be the last thing you do in your pgm before exit}
- end.
-