home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / pascal / 5186 < prev    next >
Encoding:
Internet Message Format  |  1992-09-03  |  1.9 KB

  1. Path: sparky!uunet!news.univie.ac.at!apap4.pap.univie.ac.at!roesel
  2. From: roesel@apap4.pap.univie.ac.at
  3. Newsgroups: comp.lang.pascal
  4. Subject: Re: can't get EXEC to work
  5. Message-ID: <1992Sep2.182522.19@apap4>
  6. Date: 2 Sep 92 18:25:22 GMT
  7. References: <la5469INNgd2@langtry.cs.utexas.edu>
  8. Organization: Vienna University Computer Center
  9. Lines: 51
  10.  
  11. In article <la5469INNgd2@langtry.cs.utexas.edu>, joel@cs.utexas.edu (Joel Daniel Just) writes:
  12. > I am having trouble getting the EXEC command to work in Turbo Pascal v5.0 on
  13. > the PC.  Here is an example program:
  14. > PROGRAM TEST;
  15. > USES DOS;
  16. > BEGIN
  17. >    EXEC('dir','');
  18. >    WRITELN('DONE')
  19. > END.
  20. > When I run this program, 'DONE' is printed, and nothing else happens.  The
  21. > EXEC command doesn't seem to be executed, no matter what I put in between the
  22. > two sets of quotes in the EXEC call.  Even if I put garbage between the
  23. > quotes, I don't get an error.  I just get 'DONE' and that's it.
  24. > Any suggestions?
  25.  
  26.  
  27. If you do not change the memory settings, Turbo Pascal uses all memory for 
  28. the heap. In this case there is no space to load a program with EXEC. 
  29. Therefore you must alter the memory settings, e.g. with the compiler directive
  30. {$M}. If you do not need the heap, you can write {$M 16384,0,0}. 
  31.  
  32. If you want to exec an internal command like DIR, then write
  33.     exec('c:\dos\command.com','/c dir');  
  34. or even better
  35.     exec(getenv('comspec'),'/c dir');  
  36.  
  37.  
  38. program example; { for exec }
  39. uses dos;
  40.  
  41. {$M 16384,0,0}             
  42.  
  43. begin
  44.  swapvectors;
  45. { exec('bsp.exe',''); }               {  an external command }
  46.  exec(getenv('comspec'),'/c dir');   { an internal command }
  47.  swapvectors;
  48.  writeln(doserror);    { doserror = 0, if all is right }
  49. end.
  50.  
  51.  
  52. I hope, this will help you
  53.  
  54.         Martin
  55.  
  56. ------------------------------------------------------------------------------
  57. Martin Roesel, Institute of Solid State Physics, University of Vienna, Austria
  58. roesel@apap1.pap.univie.ac.at
  59.