Calling batch file to setup command environment variables

Help with setting up and configuring custom user tools in UltraEdit (based on command line input)

Calling batch file to setup command environment variables

Postby zman » Mon Mar 27, 2006 6:49 pm

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?
User avatar
zman
Newbie
 
Posts: 3
Joined: Mon Mar 27, 2006 12:00 am

Re: Calling batch file to setup command environment variables

Postby Mofi » Tue Mar 28, 2006 6:47 am

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.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4064
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Calling batch file to setup command environment variable

Postby zman » Wed Apr 05, 2006 5:09 am

Thanks Mofi, Works Great!
User avatar
zman
Newbie
 
Posts: 3
Joined: Mon Mar 27, 2006 12:00 am


Return to Custom User Tools/Tool Configuration