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