set MNU=41
if errorlevel 48 goto pickPRN
if errorlevel 47 goto PickCNF
if errorlevel 46 goto editCNF
if errorlevel 45 goto reset
set OPT=@%CNF%.cnf
if "%CNF%"=="" set OPT=//
set MARK=%PORT%
if errorlevel 43 set MARK=%PRNFILE%.%EXT%
if errorlevel 42 goto print
if errorlevel 41 goto preview

:reset
  if not "%MYPRINT%"=="" call %MYPRINT%
  if     "%MYPRINT%"=="" call %EMTEXDIR%\mnu\tiskarny
  goto end

:preview
  echo dvidrv %VCOM% %OPT% %MAIN%
  dvidrv %VCOM% %OPT% %MAIN%
  goto end

:print
if %EXT%==ps  goto dvips
  if %OPT%==// type %EMTEXDIR%\mnu\messprn.txt
  echo dvidrv %PCOM% %OPT% %MAIN% %MARK%
  dvidrv %PCOM% %OPT% %MAIN% %MARK%
  goto end

:dvips
  if not exist %EMTEXDIR%\data\dvips\config.ps goto bsorry
  set OPT=
  if "%MARK%"=="%PORT%" set OPT=-o%PORT%
  echo dvidrv %PCOM% %OPT% %MAIN%
  dvidrv %PCOM% %OPT% %MAIN%
  goto end

:pickCNF
  set MNU=46
  if not '%CNF%'==''  goto end
  %EMTEXDIR%\bin\pickfile *.cnf /c=set+CNF=[n] /p=25;8;15;1;$70;$70;$0e > %TMP%\@file.bat
  call %TMP%\@file
  goto end

:editCNF
  if "%CNF%"=="" echo nejprve vyznacte nazev konfiguracniho souboru (bez pripony cnf)
  if "%CNF%"=="" goto end
  type %EMTEXDIR%\mnu\messprn.txt
  echo zm ‡knˆte jakoukoli kl vesu pro vstup do editoru ...
  %COMSPEC% /c pause > nul
  %EDIT% %CNF%.cnf
  set MNU=41
  goto end

:pickPRN
  set MNU=43
  if not '%PRNFILE%'==''  goto end
  %EMTEXDIR%\bin\pickfile *.%EXT% /c=set+PRNFILE=[n] /p=25;8;15;1;$70;$70;$0e > %TMP%\@file.bat
  call %TMP%\@file
  goto end

:bsorry
  set MNU=49
:sorry
  %EMTEXDIR%\bin\mnu %EMTEXDIR%\mnu\sorry.mnu
  set MNU=41
:end
