NppExec compiling multiple languages
Hey there! I write mainly in cpp, java and python, so I made various script to compile/run/interpret my files. On their own they work as expected but I’m running out of hotkeys, so I wanted to wrap them all in only two scripts, calling the right commands by reading the extension of the file, like this:
if $(EXT_PART) == ".py" (
) else (
echo unrecognized extension
When run this, a bracket is printed
)and then I get the following error
; starting child process: ")"
CreateProcess() failed with error code 2:
The system cannot find the file specified.
On its own
py $(FILE_NAME)works nicely, so the problem shouldn’t be there.
the error itself points to the closing round bracket not being a program which can be executed.
My knowledge may be a little be outdated about the latest features of nppexec but from what
I remember the if syntax is
if condition goto label
Checkout the doc and manual which comes with the plugin.
Prompted by your observation I did some tests and, as far as I can tell, NppExec’s console only runs the last line of a command, hence the unrecognized bracket.
A script launched after pressing F6 does execute all the lines but only one after the other, so any kind of multiline command doesn’t work.
I solved the problem with a somewhat artless bodge, calling
launch.bat $(NAME_PART) $(EXT_PART)from my script, that runs this external script, saved somewhere reached by the environmental variables:
@ECHO OFF SETLOCAL SET filename=%1 SET extension=%2 if %extension%==.py goto :python if %extension%==.cpp goto :cpp if %extension%==.java goto :java goto :error :python py %filename%%extension% goto :end :cpp %filename%.exe goto :end :java java %filename% goto :end :error echo Unrecognized extension :end ENDLOCAL
And this is
compile.batif anyone is interested, called with the same arguments:
@ECHO OFF SETLOCAL SET filename=%1 SET extension=%2 if %extension%==.py goto :python if %extension%==.cpp goto :cpp if %extension%==.java goto :java goto :error :python echo Python is interpreted goto :end :cpp g++ -o %filename% %filename%%extension% goto :end :java javac %filename%%extension% goto :end :error echo Unrecognized extension :end ENDLOCAL
Pietro, I had something different in mind.
Copy the following into nppexec dialog and run it on a python script,
then you should see the full file path output, when running on txt file
only a statement is shown. No need for an addition batch file.
if $(EXT_PART) == .py goto python if $(EXT_PART) == .txt goto whatever goto end :python echo run full file path:$(FULL_CURRENT_PATH) goto end :whatever echo some text file :end echo "END"