option:symbols=" "

!if $wims_read_parm!=sub
  good=!rawmath $(replygood$i)
  replyGood$i=!item 1 of $good
  good=!row 1 of $good
  dd=!rawmath $(reply$i)
!endif

primetrans=
!if ' isin $good$dd
  good=!replace internal ' by djkz in $good
  dd=!replace internal ' by djkz in $dd
  primetrans=yes
!endif
goodcnt=!itemcnt $good
!if $goodcnt>1
  test=
  !for t=1 to $goodcnt
    test=$test($(good[$t])-($dd))
  !next t
  test=!rawmath $test
  good1=[$good]
!else
  test=$good-($dd)
  good1=$good
!endif

!if $wims_read_parm=nocompare
  !if NaN isin $test
    !exit
  !endif
  !exit
!endif

!if % isin $dd
  test=NaN badform
  !exit
!endif
mres=!exec maxima print($good1);\
	print($dd);\
	print(rootscontract(ratsimp(trigreduce(trigsimp($test)))));\
	keepfloat:false;\
	print(rootscontract(ratsimp(trigreduce(trigsimp($test)))));
!if $primetrans=yes
  mres=!replace internal djkz by ' in $mres
!endif
!distribute lines $mres into t1,t2,t3,bidon,t4
t1=!declosing $t1

m_reply$i=$t2
!if $wims_read_parm=nocompare
  !if $t2=$empty or $t3=$empty
    test=NaN
  !endif
  !exit
!endif

!if $t1=$empty
  Test=bad $i
  !exit
!endif
!if $t2=$empty or $t3=$empty
  test=NaN
  !exit
!endif

!if $t3=0 or $t3=0.0 or $t4=0 or $t4=0.0
  diareply$i=good
  !advance freegot
!else
  diareply$i=bad
!endif
