bewerking=bewerking1.proc
!if $taal=nl
    nivo_title=Het aftrekken van breuken.
    somtekst1=Trek de volgende breuken van elkaar af<br>\
    en vereenvoudig de uitkomst zo ver mogelijk:<br>
!else
    nivo_title=Subtraction of Fractions.
    somtekst1=Calculate and fill in the blancs.<br>\
    Don't forget to reduce the outcome:<br>
!endif

!if $negatief=0
    lijst_a=!shuffle 1,2,3,4,5,6,7,8
    lijst_b=!shuffle 4,5,6,7,8,9,10
    lijst_c=!shuffle 2,3,4,5,6,7,8
    lijst_d=!shuffle 6,7,8,9,10,11,12
    pm=1
    mp=1
!else
    lijst_a=!shuffle 1,2,3,4,5,6,-1,-2,-3,-4,-5,-6
    lijst_b=!shuffle 6,7,8,9,10,11,12
    lijst_c=!shuffle 2,3,4,-2,-3,-4,-6
    lijst_d=!shuffle 6,7,8,9,10,11,12
    pm=!randitem 1,-1
    mp=!randitem 1,-1
!endif

R=$graad
totaal=$empty

!for n=1 to $aantal_sommen
	!if $graad=0
	    R=$n
	!endif
	!if $R=1
	    a=$n
	    b=!item $n of $lijst_b
	    d=$b
	    c=!item $n of $lijst_c
	!endif    
	!if $R=2
	    b=!item $n of $lijst_b
	    d=!randitem $[2*$b],$[3*$b]
	    a=!item $n of $lijst_a
	    c=!item $n of $lijst_c
	!endif    
	!if $R=3
	    a=!item $n of $lijst_a
	    b=!item $n of $lijst_b
	    c=!item $n of $lijst_c
	    d=!item $n of $lijst_d
	!endif      
	!if $R>3
	    b=!item $n of $lijst_b
	    a=!item $n of $lijst_a
	    b=$[$pm*$b]
	    c=!item $n of $lijst_c
	    d=!item $n of $lijst_d
	    d=$[$mp*$d]
	!endif      
        AA=$a/$b
        BB=$c/$d
	!if $negatief=0
    	    !if $[$AA] > $[$BB]
		som$n=$AA-$BB
    		totaal=!append line (($AA)-($BB)) to $totaal
		totaal=!append line printtex(($AA)-($BB)) to $totaal
		opgave$n=\frac{$a}{$b}-\frac{$c}{$d}
	    !else
		som$n=$BB-$AA
		totaal=!append line (($BB)-($AA)) to $totaal
		totaal=!append line printtex(($BB)-($AA)) to $totaal
		opgave$n=\frac{$c}{$d} - \frac{$a}{$b}
	    !endif
	!else
	    som$n=$AA-$BB
    	    totaal=!append line (($AA)-($BB)) to $totaal
	    totaal=!append line printtex(($AA)-($BB)) to $totaal
	    opgave$n=\frac{$a}{$b}-\frac{$c}{$d}
	!endif
!next n
totaal=!exec pari $totaal
i=1
!for n=1 to $aantal_sommen
    GOED$n=!line $i of $totaal
    goed$n=!line $[$i+1] of $totaal
    i=$[$i+2]	 
!next n
