!if middle notitemof $special
 error=no_allow
 !exit
!endif
!if $parm1>$pointcnt or $parm2>$pointcnt
 error=out_range
 !exit
!endif
pari_out=!exec pari got=add_middle($parm1,$parm2); print(got);\
	print(incipl(got));\
	print(incipc(got));\
	print(goalcheck(1,got))
!if error iswordof $pari_out
 error=!word 2 of $pari_out
 !exit
!endif
!distribute lines $pari_out into pout,inci,inci2,goalcheck
inci=!nospace $inci
inci2=!nospace $inci2
!distribute items $pout into x,y
!if $y=$empty
 error=pari_fail
 !exit
!endif

!if $step<$stepcnt
 !read proc/triminci
!endif
points=!line 1 to $pointcnt of $points
hidepoint=!char 1 to $pointcnt of $hidepoint
steplist=!line 1 to $step of $steplist
!if $inci!=$empty
 ii=!replace , by ,l $ in l $inci
!endif
!if $inci2!=$empty
 i2=!replace , by ,c $ in c $inci2
 ii=!append item $i2 to $ii
!endif
!for i in $inci
 l=!line $i of $inciline
 l=!append item $[$pointcnt+1] to $l
 inciline=!replace line number $i by $l in $inciline
!next i
!for i in $inci2
 l=!line $i of $incicircle
 l=!append item $[$pointcnt+1] to $l
 incicircle=!replace line number $i by $l in $incicircle
!next i
points=!append line $x,$y,$point_color to $points
incipoint=!append line $ii to $incipoint
hidepoint=$hidepoint+
!advance pointcnt
steplist=!append line middle,$pointcnt,$parm1,$parm2 to $steplist
!advance step

!if $goalcheck>0
 goalready=!replace item number $goalcheck by $step in $goalready
!endif

