!if midper notitemof $special
 error=no_allow
 !exit
!endif
!if $parm1>$pointcnt or $parm2>$pointcnt
 error=out_range
 !exit
!endif
pari_out=!exec pari got=add_midper($parm1,$parm2); print(got);\
	print(incilp(got));\
	print(goalcheck(2,vecextract(got,"5..7")));
!if error iswordof $pari_out
 error=!word 2 of $pari_out
 !exit
!endif
!distribute lines $pari_out into pout,inci,goalcheck
inci=!nospace $inci
!distribute items $pout into x1,y1,x2,y2,a,b,c
!if $c=$empty
 error=pari_fail
 !exit
!endif

!if $step<$stepcnt
 !read proc/triminci
!endif
lines=!line 1 to $linecnt of $lines
lines=!append line $x1,$y1,$x2,$y2,2,$[$linecnt%$color_total+1] to $lines
lineid=!line 1 to $linecnt of $lineid
lineid=!append line $a,$b,$c to $lineid
hideline=!char 1 to $linecnt of $hideline
hideline=$hideline+
inciline=!append line $ $inci to $inciline
!advance linecnt
!for i in $inci
 l=!line $i of $incipoint
 l=!append item l $linecnt to $l
 incipoint=!replace line number $i by $l in $incipoint
!next i
steplist=!line 1 to $step of $steplist
steplist=!append line midper,$linecnt,$parm1,$parm2 to $steplist
!advance step

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

