by Mofi » Fri Nov 12, 2010 8:42 am
Replace the command line of the tool for example by
C:\ecl\macros\ue_eclipse.bat "%f"
and create in the directoy C:\ecl\macros\ a text file named ue_eclipse.bat containing the following 3 lines:
@echo off
title UEDOS %~1
C:\ecl\macros\eclrun.exe eclipse "%~1"
Nothing else to change.
Why using %~1 instead of just %1 ?
Well, %f is replaced by UltraEdit with the full long name of the active file. A long name can contain a space character and therefore double quotes must be used. But the double quotes are not removed by Windows and there is no command line interpreting code as in applications (the "stub" code executed before calling main function) which removes the double quotes from the argument string. Therefore the first parameter (argument 1) of the batch file can be with or without double quotes depending how a user or application called the batch file. That's not good for the commands in the batch file. Some commands do not work and result in batch exits when a file name with double quotes is passed. For example the following simple line to initialize an environment variable with the first parameter string fails if the parameter is enclosed in double quotes:
set FileName=%1
Therefore it is better to use inside the batch file always double quotes for file name variables and throw them away from the parameter. Using %~1 results in using the passed first parameter always without double quotes, independent how the batch file was called, with or without double quotes around the first parameter.
And in the window title you likely don't want to see the double quotes. I prefer always to use environment variables for batch file parameters to easily know on reading the batch file what should be passed by the caller. So I would use for this little batch file following commands:
@echo off
set EclipseFile=%~1
title UEDOS %EclipseFile%
C:\ecl\macros\eclrun.exe eclipse "%EclipseFile%"
set EclipseFile=
The last line is not really needed here because the environment variables memory copied from system environment variables memory on start of the batch file and modified within the batch file is automatically destroyed on exit of the batch file. But I always delete all environment variables used in my batch files in case of calling this batch file ever from another batch file which also needs environment variables. The environment variable memory buffer is quite limited to some KB and I have seen many larger batch jobs fail because of "out of environment variable buffer".