home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / pascal / 7998 < prev    next >
Encoding:
Internet Message Format  |  1993-01-09  |  2.6 KB

  1. Path: sparky!uunet!munnari.oz.au!ariel.ucs.unimelb.EDU.AU!ucsvc.ucs.unimelb.edu.au!lugb!lux!cscmd
  2. Newsgroups: comp.lang.pascal
  3. Subject: Re: Stuffing DOS command line
  4. Message-ID: <1993Jan9.160345.28699@lugb.latrobe.edu.au>
  5. From: cscmd@lux.latrobe.edu.au (Mitch Davis)
  6. Date: Sat, 9 Jan 1993 16:03:45 GMT
  7. Sender: news@lugb.latrobe.edu.au (USENET News System)
  8. References: <34933@adm.brl.mil>
  9. Organization: La Trobe University
  10. Lines: 67
  11.  
  12. In article <34933@adm.brl.mil> CHARPER%COLGATEU.bitnet@cunyvm.cuny.edu writes:
  13. >Some years ago I worked with MS-Pascal, and used a method to load a desired
  14. >string into the DOS command line, so that that command was executed when the
  15. >application completed.
  16.  
  17. Hi there Cindy.
  18.  
  19. I can think of three ways to solve this problem.
  20.  
  21. One way (the poorest) is to call Int 16h subfunc 5 with the scan
  22. code of each key you want to simulate.  This (on an AT, and up to a max of
  23. 16 chars) jams the key you want into the keyboard buffer, which then
  24. gets effectively typed in when the program finishes.
  25.  
  26. >  This was the best way I know of to chain from one program to another.
  27.  
  28. I really don't know about being the best - it's certainly the easiest,
  29. but has a number of shortcomings:
  30.  
  31.  o It can be defeated by Ctrl-Break, which clears the buffer.
  32.  o If the user has already pressed some keys, you may run out of room.
  33.  o It's ugly to watch it work.
  34.  o It only works on ATs and higher.
  35.  o etc.
  36.  
  37. Another option which is used by many menu programs is to have the two
  38. programs run as part of a batch file:
  39.  
  40. RUNME.BAT
  41. @echo off
  42. rem let's call the first program.  It will generate 2nd.bat which has
  43. rem the name of the second program to run in it.
  44. first.exe
  45. rem first made 2nd.bat, and now we run it.
  46. call 2nd.bat
  47. echo Done!
  48.  
  49. program first;
  50.  
  51. var t:text;
  52.  
  53. begin
  54.   assign (t,'2nd.bat');
  55.   rewrite (t);
  56.   case random (3) of
  57.     0:writeln (t,'dothis.exe');
  58.     1:writeln (t,'dothat.exe');
  59.     2:writeln (t,'doother.exe');
  60.   end;
  61.   close (t);
  62. end.
  63.  
  64. The last way I'll suggest, (and IMHO the best) is to rewrite your
  65. program in some area so that its memory requirements are in some way 
  66. shortened by 400 bytes.  This would give you more than enough memory 
  67. left over to use Ralf Brown's swapping exec unit (called SPWNO413.ZIP) 
  68. to do a proper exec, albeit with MUCH reduced memory requirements.  
  69. (Your main program ends up only taking up 320 bytes, which is a mere nothing!)
  70.  
  71. >I can't afford the memory to shell the command).
  72.  
  73. I think you can, and with room to spare if you follow method three.
  74.  
  75. If you'd like any help with the coding of this, please don't hesitate to
  76. mail me back, or phone me on +61-3-890-0439 BH.  (Australia is GMT+10)
  77.  
  78. Mitch.
  79.