home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / msdos / programm / 8717 < prev    next >
Encoding:
Text File  |  1992-08-22  |  1.7 KB  |  36 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!gatech!taco!dspascha
  3. From: dspascha@eos.ncsu.edu (DAVID SCOTT PASCHAL)
  4. Subject: Re: How can you set an environment variable in a program?
  5. Message-ID: <1992Aug22.200123.25418@ncsu.edu>
  6. Originator: dspascha@c00083-100lez.eos.ncsu.edu
  7. Keywords: variable, C
  8. Lines: 21
  9. Sender: news@ncsu.edu (USENET News System)
  10. Reply-To: dspascha@eos.ncsu.edu (DAVID SCOTT PASCHAL)
  11. Organization: North Carolina State University, Project Eos
  12. References:  <1345@rand.mel.cocam.oz.au>
  13. Date: Sat, 22 Aug 1992 20:01:23 GMT
  14.  
  15.  
  16. Hi.  There is an MS-DOS function call (I think 5Ah or 5Bh, but I'm not sure,
  17. since I don't have my docs handy right now) that creates and opens a file with
  18. a unique name -- you pass it a file attribute (usually zero) and the path where
  19. you want to create the file, and if the function is successful, MS-DOS appends
  20. the filename to the end of the path string you passed it so you can delete it
  21. when you're done.  Passing that string to the other program is another problem,
  22. though.  When you use the SET command in a DOS shell, only that process'
  23. environment is modified -- the parent's is not.  So all <shell "set a=b"> does
  24. is give your hard disk or whatever a little exercise.  :-)  However, it is
  25. possible to modify other processes' environments yourself (but this can get
  26. pretty tricky).
  27.  
  28. Why don't you run program2 from within program1?  That way, you don't have to
  29. worry about passing the temp filename back to the calling batch file; instead,
  30. you just set up the file redirection yourself (there are some MS-DOS function
  31. calls to do this, but again, since I don't have my manuals with me at the
  32. moment, I can't tell you which ones), execute program2, and delete the tempfile.
  33.  
  34. Tschuess,
  35. David Paschal
  36.