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

  1. Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!swrinde!mips!mips!munnari.oz.au!deakin.OZ.AU!rand!superb!dmh
  2. From: dmh@superb (Daniel Hermans)
  3. Newsgroups: comp.os.msdos.programmer
  4. Subject: How can you set an environment variable in a program?
  5. Summary: can you set an env variable?
  6. Keywords: variable, C
  7. Message-ID: <1345@rand.mel.cocam.oz.au>
  8. Date: 22 Aug 92 03:07:06 GMT
  9. Sender: usenet@rand.mel.cocam.oz.au
  10. Lines: 38
  11. X-Newsreader: Tin 1.1 PL4
  12.  
  13. hi,
  14. i am using turbo c v2.0 to generate a temporary file name,
  15. place some data in the temporary file and then close the file. the temp
  16. file is then to be used on the command line of another program. both
  17. programs are called within a batch file something like:
  18.  
  19. @echo off
  20.  
  21. program1
  22. program2 < %tempfile%
  23.  
  24. i need a way to tell the batch file the name of the tempfile that has been
  25. created, so that it can be used by the second program on it's command line.
  26.  
  27. the only way i can see to do this would be to set an environment variable
  28. to the temp file name within program 1 for use by program 2:
  29. program1:
  30.    generate temp file
  31.    write to temp file
  32.    close temp file
  33.    system("set tempfile=tmpx.$$$");
  34.  
  35. program2:
  36.    use tmpx.$$$ for whatever.
  37.  
  38. the name also needs to be unique so that multiple network users can create
  39. their own temp files when they all start in the same directory. i am
  40. using mktemp to generate the temp file name.
  41.  
  42. i tried using system(command) as above but the variable is not set when the
  43. program exits probably because system starts a new command.com shell each
  44. time
  45.  
  46. any ideas ?
  47.  
  48. --
  49. Daniel Hermans (dmh@superb.mel.cocam.oz.au)
  50. Co-Cam Computer Group, Melbourne, OZ (Phone : (613) 412-3341)
  51.