@echo off
if not exist \Emu\Hercules\Hercules.exe goto EmulatorFail

set BuildFile=%1
set BuildPath=%2
if exist \utils\SelectedBuildFile.bat call \utils\SelectedBuildFile.bat 

call \Emu\ServerStart.bat

cd %BuildPath%
if not %BuildPath:~0,1%==%CD:~0,1% goto InvalidPath






type %BuildFile% | \Emu\Hercules\mvs\ncat --send-only -w1 127.0.0.1 3505

\utils\sleep 2

echo.
rem \utils\tail --lines 200 \Emu\Hercules\mvs\prt00e.txt
copy \Emu\Hercules\mvs\prt00e.txt \Emu\Hercules\mvs\prt00e.txt2 >nul
\utils\CS_Herc370Tailer.exe \Emu\Hercules\mvs\prt00e.txt2 \Bld370\listing.txt

echo.
rem \utils\tail --lines 20 \Emu\Hercules\mvs\mvslog.txt
copy \Emu\Hercules\mvs\mvslog.txt \Emu\Hercules\mvs\mvslog.txt2 >nul
\utils\CS_Herc370Tailer.exe \Emu\Hercules\mvs\mvslog.txt2 \Bld370\console.txt console
goto Abandon


:InvalidPath
echo Error: ASM file must be on same drive as devtools 
echo File: %BuildPath%\%BuildFile% 
echo Devtools Drive: %CD:~0,1% 
goto Abandon


:EmulatorFail
echo Error: Can't find \Emu\Hercules\Hercules.exe
:Abandon
if "%3"=="nopause" exit
pause

