home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!munnari.oz.au!ariel.ucs.unimelb.EDU.AU!ucsvc.ucs.unimelb.edu.au!lugb!lux!cscmd
- Newsgroups: comp.lang.pascal
- Subject: Re: Stuffing DOS command line
- Message-ID: <1993Jan9.160345.28699@lugb.latrobe.edu.au>
- From: cscmd@lux.latrobe.edu.au (Mitch Davis)
- Date: Sat, 9 Jan 1993 16:03:45 GMT
- Sender: news@lugb.latrobe.edu.au (USENET News System)
- References: <34933@adm.brl.mil>
- Organization: La Trobe University
- Lines: 67
-
- In article <34933@adm.brl.mil> CHARPER%COLGATEU.bitnet@cunyvm.cuny.edu writes:
- >Some years ago I worked with MS-Pascal, and used a method to load a desired
- >string into the DOS command line, so that that command was executed when the
- >application completed.
-
- Hi there Cindy.
-
- I can think of three ways to solve this problem.
-
- One way (the poorest) is to call Int 16h subfunc 5 with the scan
- code of each key you want to simulate. This (on an AT, and up to a max of
- 16 chars) jams the key you want into the keyboard buffer, which then
- gets effectively typed in when the program finishes.
-
- > This was the best way I know of to chain from one program to another.
-
- I really don't know about being the best - it's certainly the easiest,
- but has a number of shortcomings:
-
- o It can be defeated by Ctrl-Break, which clears the buffer.
- o If the user has already pressed some keys, you may run out of room.
- o It's ugly to watch it work.
- o It only works on ATs and higher.
- o etc.
-
- Another option which is used by many menu programs is to have the two
- programs run as part of a batch file:
-
- RUNME.BAT
- @echo off
- rem let's call the first program. It will generate 2nd.bat which has
- rem the name of the second program to run in it.
- first.exe
- rem first made 2nd.bat, and now we run it.
- call 2nd.bat
- echo Done!
-
- program first;
-
- var t:text;
-
- begin
- assign (t,'2nd.bat');
- rewrite (t);
- case random (3) of
- 0:writeln (t,'dothis.exe');
- 1:writeln (t,'dothat.exe');
- 2:writeln (t,'doother.exe');
- end;
- close (t);
- end.
-
- The last way I'll suggest, (and IMHO the best) is to rewrite your
- program in some area so that its memory requirements are in some way
- shortened by 400 bytes. This would give you more than enough memory
- left over to use Ralf Brown's swapping exec unit (called SPWNO413.ZIP)
- to do a proper exec, albeit with MUCH reduced memory requirements.
- (Your main program ends up only taking up 320 bytes, which is a mere nothing!)
-
- >I can't afford the memory to shell the command).
-
- I think you can, and with room to spare if you follow method three.
-
- If you'd like any help with the coding of this, please don't hesitate to
- mail me back, or phone me on +61-3-890-0439 BH. (Australia is GMT+10)
-
- Mitch.
-