rem ................................. running menu:
:menu
%EMTEXDIR%\bin\mnu %EMTEXDIR%\mnu\cfg.mnu %TMP%\@envir.bat %TMP%\@dos.bat %TMP%\@mfbat.bat
call %TMP%\@envir
rem ................................. chose process:
if errorlevel 255 goto syserr
if errorlevel 235 goto spell
if errorlevel 233 goto EXview
if errorlevel 232 goto EXtex
if errorlevel 231 goto EXedit
if errorlevel 169 goto load
if errorlevel 168 goto save
if errorlevel 162 goto resize
if errorlevel 151 goto parmf
if errorlevel 150 goto PickMF
if errorlevel 141 goto cstocs
if errorlevel 131 goto others
if errorlevel 125 goto dosbat
if errorlevel 124 goto archive
if errorlevel 122 goto WORKfile
if errorlevel 121 goto MAINfile
if errorlevel  52 goto metafont
if errorlevel  50 goto PickMFF
if errorlevel  41 goto prints
if errorlevel  38 goto usercom
if errorlevel  36 goto tie
if errorlevel  34 goto specEd
if errorlevel  33 goto view
if errorlevel  32 goto TeX
if errorlevel  31 goto edit
if errorlevel  29 goto quit
if errorlevel  27 goto editor
if errorlevel  26 goto shell
if errorlevel  24 goto clear
goto quit
rem ................................. running Edit -> TeX -> View:
:edit
  %EDIT% %WORKF% %EDITPAR%
  set EDITPAR=
  set MNU=32
  goto menu
:TeX
  set MNU=33
  call %EMTEXDIR%\bin\%FMT%
  call %EMTEXDIR%\bin\texrun %MAINF%
  goto menu
:View
  %EMTEXDIR%\bin\dvidrv %SCR% %SCROPT% %MAIN%
  set MNU=31
  goto menu
:specEd
  %EDIT% %MARK%
  set MNU=32
  goto menu
:editor
  %EDIT% %F3FILE%
  goto menu
rem ................................. Experiment:
:EXedit
  %EDIT% %MAIN%.try %EDITPAR%
  set EDITPAR=
  set MNU=232
  goto menu
:EXtex
  call %EMTEXDIR%\bin\%FMT%
  call %EMTEXDIR%\bin\texrun %MAIN%.try
  set MNU=233
  goto menu
:exView
  %EMTEXDIR%\bin\dvidrv %SCR% %SCROPT% %MAIN%
  set MNU=231
  goto menu
rem ................................. others bats:
:prints
  call %EMTEXDIR%\mnu\prints
  goto menu
:others
  call %EMTEXDIR%\mnu\others
  goto menu
:metafont
  call %EMTEXDIR%\mnu\metafont
  goto menu
rem ................................. change file name:
:MAINfile
  set MNU=122
  set WORK=%MAIN%
  set MARK=MAIN
  if "%MAIN%"=="" goto pickfile
  %EMTEXDIR%\bin\fix %MAIN% %WORK% > %TMP%\@envir.bat
  call %TMP%\@envir.bat
  set MF=%MAIN%
  set PRNFILE=%MAIN%
  goto menu
:WORKfile
  set MNU=31
  set MARK=WORK
  if "%WORK%"==""  goto pickfile
  %EMTEXDIR%\bin\fix %MAINF% %WORK% > %TMP%\@envir.bat
  call %TMP%\@envir.bat
  goto menu
:pickfile
  %EMTEXDIR%\bin\pickfile *.tex /c=set+%MARK%=[n] /p=25;8;15;1;$70;$70;$0e > %TMP%\@file.bat
  call %TMP%\@file
  if %MARK%==MAIN set MAINF=%MAIN%
  if %MARK%==MAIN set WORK=%MAIN%
  %EMTEXDIR%\bin\fix %MAINF% %WORK% > %TMP%\@envir.bat
  call %TMP%\@envir.bat
  if %MARK%==MAIN set MF=%MAIN%
  if %MARK%==MAIN set PRNFILE=%MAIN%
  goto menu
:pickMF
  set MNU=151
  if not '%MF%'==''  goto menu
  %EMTEXDIR%\bin\pickfile *.mf /c=set+MF=[n] /p=25;8;15;1;$70;$70;$0e > %TMP%\@file.bat
  call %TMP%\@file
  goto menu
:pickMFF
  set MNU=52
  if not '%MF%'==''  goto menu
  %EMTEXDIR%\bin\pickfile *.mf /c=set+MF=[n] /p=25;8;15;1;$70;$70;$0e > %TMP%\@file.bat
  call %TMP%\@file
  goto menu
rem ................................. correction of document:
:spell
  if not exist %EMTEXDIR%\cstug\velky.%MARK% goto sorry
  if %MARK%==ces set MARK=C
  if %MARK%==slv set MARK=S
  if %MARK%==ang set MARK=A
  %EMTEXDIR%\cstug\texspell %WORKF% =%MARK% %SPELLOPT%
  set MNU=32
  goto menu
:tie
  %EMTEXDIR%\bin\vlnka %WORKF%
  set MNU=32
  goto menu
:usercom
  %COMSPEC% /c %USERCOM%
  goto menu
:cstocs
  echo CSTOCS2 %MARK% %WORKF%
  %EMTEXDIR%\bin\cstocs2 %MARK% %WORKF%
  if errorlevel 1 %COMSPEC% /c pause
  set MNU=31
  goto menu
rem ................................. Special functions:
:dosbat
  set MNU=25
  @echo on
  @call %TMP%\@dos
  @echo off
  goto menu
:clear
  if not %MAIN%==%WORK% echo delete %WORK%.bak
  if not %MAIN%==%WORK% del %WORK%.bak
  echo delete %MAIN%.bak %MAIN%.log %MAIN%.dvi %MAIN%.aux %MAIN%.lq %MAIN%.hp %MAIN%.fx
  for %%f in (bak log dvi aux lq hp fx) do del %MAIN%.%%f
  goto menu
:shell
  echo Quit the shell to return to TEX-MENU-SYSTEM.
  %SHELL%
  goto menu
:parmf
  set MNU=152
  goto menu
:save
  set > %TMP%\@file.mnu
  echo echo **** CONFIGURATION from file %MARK%.bat **** > %MARK%.bat
  %EMTEXDIR%\bin\dupcent %TMP%\@file.mnu set >> %MARK%.bat
  echo set MNU=31 >> %MARK%.bat
  del %TMP%\@file.mnu
  set mnu=65
  goto menu
:load
  set MNU=66
  call %MARK%
  goto menu
:resize
  call %EMTEXDIR%\mnu\texverze
  set mnu=31
  goto menu
rem ................................. Sorry
:sorry
  %EMTEXDIR%\bin\mnu %EMTEXDIR%\mnu\sorry.mnu
  goto menu
rem ................................. Diskette:
:archive
  if %AR%==from goto fromdisc
  echo copy %D%:%MAINF%
  copy %D%:%MAINF%
  if not %WORKF%==%MAINF% echo copy %D%:%WORKF%
  if not %WORKF%==%MAINF% copy %D%:%WORKF%
  set MNU=31
  goto menu
:fromdisc
  echo copy %MAINF% %D%:
  copy %MAINF% %D%:
  if not %MAINF%==%WORKF% echo copy %WORKF% %D%:
  if not %MAINF%==%WORKF% copy %WORKF% %D%:
  set MNU=31
  goto menu
rem ................................. Final:
:syserr
  echo SORRY - Error in configuration of TeX system.
  echo Please ask the system engineer to solve this problem.
:quit
  del %TMP%\@*.bat
  %KBD% %EMTEXDIR%\bin\kbd /u
  %LASTCOM%

