@echo off
set FULL_FILENAME=%~1
set FILENAME=%~n1
set DIRNAME=%~dp1
set FILE_EXT=%~x1
echo Full File Name: %FULL_FILENAME%
echo File Name: %FILENAME%
echo File Directory: %DIRNAME%
echo File Extension: %FILE_EXT%
set CC_BIN=gcc
set CPP_BIN=g++
set GHC_BIN=ghc
set SCALA_BIN=scalac.bat
set CC_EXT=.c
set CPP_EXT=.c++
set GHC_EXT=.hs
set SCALA_EXT=.scala
REM set CPP_OPTIONS=-std=c++11
set CPP_OPTIONS=
IF /I %FILE_EXT% == %CPP_EXT% GOTO __CPPCOMPILE
IF /I %FILE_EXT% == %CC_EXT% GOTO __CCOMPILE
IF /I %FILE_EXT% == %GHC_EXT% GOTO __HSKCOMPILE
IF /I %FILE_EXT% == %SCALA_EXT% GOTO __SCALACOMPILE
GOTO END
:__CCOMPILE
echo --- Compiling C Program ... ---
call %CC_BIN% %FULL_FILENAME% -o %FILENAME%.exe & IF ERRORLEVEL 1 (echo. && echo "ERROR - Compilation Error - Please Fix !!!" ) ELSE echo "Compilation success !!!"
GOTO END
:__CPPCOMPILE
echo --- Compiling C++ Program ... ---
call %CPP_BIN% %FULL_FILENAME% -o %FILENAME%.exe %CPP_OPTIONS% & IF ERRORLEVEL 1 (echo. && echo "ERROR - Compilation Error - Please Fix !!!" ) ELSE echo "Compilation success !!!"
GOTO END
:__HSKCOMPILE
echo --- Compiling Haskell Program ... ---
call %GHC_BIN% --make %FULL_FILENAME% -o %FILENAME%.exe & IF ERRORLEVEL 1 (echo. && echo "ERROR - Compilation Error - Please Fix !!!" ) ELSE echo "Compilation success !!!"
GOTO END
:__SCALACOMPILE
echo --- Compiling Scala Program ... ---
call %SCALA_BIN% %FULL_FILENAME% & IF ERRORLEVEL 1 (echo. && echo "ERROR - Compilation Error - Please Fix !!!" ) ELSE echo "Compilation success !!!"
GOTO END
:END
Execute Batch File
@echo off
set FULL_FILENAME=%~1
set FILENAME=%~n1
set DIRNAME=%~dp1
set FILE_EXT=%~x1
echo ++++++++++++++++++++++++++++++++++++++++
echo Executing %FULL_FILENAME% ...
echo ++++++++++++++++++++++++++++++++++++++++
set CC_BIN=gcc
set CPP_BIN=g++
set GHC_BIN=ghc
set RUBY_BIN=C:\Ruby21\bin\ruby.exe
set PYTHON_BIN=C:\Python27\python.exe
set SCALA_BIN=scala.bat
set CC_EXT=.c
set CPP_EXT=.c++
set GHC_EXT=.hs
set PY_EXT=.py
set RUBY_EXT=.rb
set SCALA_EXT=.scala
IF /I %FILE_EXT% == %CPP_EXT% GOTO __CPPEXEC
IF /I %FILE_EXT% == %CC_EXT% GOTO __CEXEC
IF /I %FILE_EXT% == %GHC_EXT% GOTO __HSKEXEC
IF /I %FILE_EXT% == %PY_EXT% GOTO __PYTHONEXEC
IF /I %FILE_EXT% == %RUBY_EXT% GOTO __RUBYEXEC
IF /I %FILE_EXT% == %SCALA_EXT% GOTO __SCALAEXEC
GOTO END
:__CEXEC
call %FILENAME%.exe
GOTO END
:__CPPEXEC
call %FILENAME%.exe
GOTO END
:__HSKEXEC
call %FILENAME%.exe
GOTO END
:__PYTHONEXEC
call %PYTHON_BIN% %FULL_FILENAME%
GOTO END
:__RUBYEXEC
call %RUBY_BIN% %FULL_FILENAME%
GOTO END
:__SCALAEXEC
call %SCALA_BIN% %FILENAME%
GOTO END
:END
echo ++++++++++++++++++++++++++++++++++++++++
echo Execution - Completed !!!
pause