home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / msdos / programm / 8800 < prev    next >
Encoding:
Internet Message Format  |  1992-08-25  |  1.6 KB

  1. Path: sparky!uunet!utoday!jaflrn!jaf
  2. From: Jon Freivald <jaf@jaflrn.UUCP>
  3. Newsgroups: comp.os.msdos.programmer
  4. Subject: Re: How can you set an environment variable in a program?
  5. Keywords: variable, C
  6. Message-ID: <7923PB2w164w@jaflrn.UUCP>
  7. Date: Tue, 25 Aug 92 18:13:29 EDT
  8. References: <690@aardvark.Rain.COM>
  9. Organization: The Wizzard's Cave, East Meadow, NY
  10. Lines: 36
  11.  
  12. tyrant@Aardvark.Rain.COM (Rex Goode) writes:
  13.  
  14. > dmh@superb (Daniel Hermans) writes:
  15. > >hi,
  16. > >i am using turbo c v2.0 to generate a temporary file name,
  17. > >place some data in the temporary file and then close the file. the temp
  18. > >file is then to be used on the command line of another program. both
  19. > >programs are called within a batch file something like:
  20. > >@echo off
  21. > >program1
  22. > >program2 < %tempfile%
  23. > >   system("set tempfile=tmpx.$$$");
  24. > >i tried using system(command) as above but the variable is not set when the
  25. > >program exits probably because system starts a new command.com shell each
  26. > >time
  27. > Absolutely right about the new command.com, with its own environment. That
  28. > is what happens when you use system(). Try setenv(),
  29. > setenv("TEMPFILE=TMPX.$$$);
  30.  
  31. OK, I don't have TC 2.0, but I do have TC++ 1.0 & 2.0 -- no such critter
  32. as "setenv()" and "putenv()" only changes the environment for the
  33. current process -- as soon as you exit, the variable is gone...
  34.  
  35. Jon
  36.  
  37. =============================================================================
  38.            Jon Freivald ( jaflrn!jaf@uunet.UU.NET )
  39.      Nothing is impossible for the man who doesn't have to do it.
  40. =============================================================================
  41.