Calling batch file to setup command environment variables

Calling batch file to setup command environment variables

2
NewbieNewbie
2

    Mar 27, 2006#1

    I run several different Fortran compilers on the same machine. Depending on which project I am working on, I need to initialize several environment variables before calling a pre-compiler. To do this on a command prompt I use the /k switch and then pass in the path to the batch file (for Intel Fortran 7.0 it is ifcvars.bat). Then I launch my pre-compiler from the command line.

    So here is what I need to do:

    - launch a command prompt
    - call ifcvars.bat
    - call fscan "%f"

    Is it possible to do this from Uedit?

    6,687587
    Grand MasterGrand Master
    6,687587

      Mar 28, 2006#2

      Yes, with a user tool. But you should do everything with a single batch file. Then you don't need to open a command prompt with /k and run the batch files manually. Example:

      You have a batch file named "CompileFortran.bat" which has 2 parameters. The first one is the name of the file which should be compiled and the second one is the compiler which should be used. So the command line in the user tool of UltraEdit looks for example as follows:

      CompileFortran.bat "%f" Intel7

      The batch file CompileFortran.bat looks at follows:

      @echo off
      if not exist "%1" goto FileNotExist
      if "%2"=="Intel7" goto Intel7
      if "%2"=="Fortran2" goto Fortran2
      if "%2"=="Fortran3" goto Fortran3
      echo "%2" is not specified or an unknown parameter!!!
      goto EndBatch

      :FileNotExist
      echo File "%1" does not exist!!!
      goto EndBatch

      :Intel7
      call ifcvars.bat
      call fscan "%1"
      goto EndBatch

      :Fortran2
      rem call whatever needed for Fortran compiler 2
      goto EndBatch

      :Fortran3
      rem call whatever needed for Fortran compiler 3
      goto EndBatch

      :EndBatch
      pause

      --------------------- end of batch file

      Remove the pause command at the end of the batch file if you capture the output with UltraEdit.
      Best regards from an UC/UE/UES for Windows user from Austria

      2
      NewbieNewbie
      2

        Re: Calling batch file to setup command environment variable

        Apr 05, 2006#3

        Thanks Mofi, Works Great!