@echo off
rem	Batch file for handling Nec-2 in/output files.
rem
	echo Args: %1, %2, %3
	set nec2d=%3.exe
rem
        if "%1" == "cop" goto cop
        if "%1" == "som" goto som
        if "%1" == "ren" goto ren
        goto gen
:som
rem	Call SOMNEC engine and generate 'arg2' ground-parameter file.
rem
	echo.
	echo Generating new %2 ground file...
	cd exe
	somnec2d < som2d.tmp
	echo.
	type som2d.tmp
	cd ..
	copy exe\som2d.nec %2
	goto gen
:cop
rem	Copy 'arg2' SOMNEC ground-parameter file to som2d.nec to be used.
rem
	echo.
	echo Using existing %2 ground file.
	copy %2 exe\som2d.nec
	goto gen
:gen
rem	Call NEC2 engine with nec2d.tmp input file and optional som2d.nec ground file
rem
	echo.
	echo Generating new NEC output file, please wait...
	echo.   
	cd exe
	type nec2d.tmp
	%nec2d% < nec2d.tmp
	cd ..
	echo.
	echo Ready...
	echo.
	if "%4" == "pause" pause
	exit
:ren
rem	Delete *.npl and Rename *.nou to *.out
rem
	cd out
	if exist %2.npl del %2.npl
	if exist %3 del %3
	rename %2.nou %3
	cd ..
	exit
