@echo on
gosub parse
gosub init

rem ------- main -------

:main

set maxlines=0
for %sub in (*.nam) do  (
   iff %@lines[%sub] GT %maxlines% then
      set maxlines=%@lines[%sub]
   endiff
)

alias parn `%@word[%1,%1&]`
alias subn `%@line[%@lower[parn %1].nam,1]`

set lin=0
:loop
   set name1=%@line[
 
   \pac\bc\cpp -P- -D%name1%=%sub1% -D%name2%=%sub2% -D%name3%=%sub3% -D%name4%=%sub4% -D%name5%=%sub5% %1 > animate.par
   fractint %fractopts% batch=yes
   set lin=%@eval[1+%lin%]
   if %lin% GT %maxlines%  goto endloop
goto loop
:endloop

:endmain
unalias parn
unalias subn
gosub done
goto end

rem ------- init -------

:init
:endinit
return

rem ------- parse ------

:parse
for %nn in (1 2 3 4 5 6 7 8 9) do  (
   set par=%@word[%nn,%1&]
   iff !%par%==!  then
      set params=%nn
      goto endparse
   else
      set colon=%@index[%par%,:]
      set name=%@substr[%par%,0,%colon%]
      echo %@substr[%par%,%@eval[1+%colon%]] > %name%.nam
      unset colon
      unset name
   endiff
)
unset par
:endparse
return

rem ------- done -------

del *.nam
return

rem ------- end --------

:end
