Hi Wang,
Today, I’m going through some unanswered emails.
It’s often hard to see what’s wrong with code, because the code is full of redundancies. Perhaps you can explain again slowly:
c.SetAttrib "temp",temp ‘what does this line do, where does temp come from?
if temp=1 And Game.RESP="f" then
var = c.getAttrib ("varA") ‘NOTE: var isn’t particularly descriptive
temp = 1 ‘NOTE: this line is tautological
total = total + var
‘no goto here??
else ‘NOTE: this linecan be deleted
end if
if temp=1 And Game.RESP="j" then
var = c.getAttrib ("varB")
temp = 2
total = total + var -0.2
goto LabelshiftB ‘where is this label? Also: goto statements can create difficult spaghetti
else ‘NOTE: this line can be deleted
end if
if temp=2 And Game.RESP="j" then
var = c.getAttrib ("varB")
temp = 2 ‘NOTE: this line is tautological
total = total + var
goto LabelstayB
else ‘NOTE: to delete
end if
if temp=2 And Game.RESP="f" then
var = c.getAttrib ("varA")
temp = 1
total = total + var -0.2
goto LabelshiftA
else ‘do delete
end if
c.SetAttrib "total", total ‘given the above code, these lines are skipped (unless the LabelshiftA is before this?
c.SetAttrib "var", var
Let’s clear that up a bit more:
if temp=1 then
if Game.RESP="f" then
var = c.getAttrib ("varA")
total = total + var
‘still no goto statement here!
else
var = c.getAttrib ("varB")
temp = 2
total = total + var -0.2
goto LabelshiftB
end if ‘temp=1
else ‘if temp=2
if Game.RESP=”f” then ‘I switched this one up, since the order was strange
var = c.getAttrib ("varA")
temp = 1
total = total + var -0.2
goto LabelshiftA
else
var = c.getAttrib ("varB")
total = total + var
goto LabelstayB
end if ‘temp = 2
end if
c.SetAttrib "total", total
c.SetAttrib "var", var
And more:
if temp=1 then
if Game.RESP="f" then
total = total + cdouble(c.getAttrib ("varA"))
‘still no goto statement here!
else
temp = 2
total = total-0.2+cdouble(c.getAttrib ("varB"))
goto LabelshiftB
end if ‘temp=1
else ‘if temp=2
if Game.RESP=”f” then ‘I switched this one up, since the order was strange
temp = 1
total = total-0.2+cdouble(c.getAttrib ("varA"))
goto LabelshiftA
else
total = total +cdouble(c.getAttrib ("varB"))
goto LabelstayB
end if ‘temp = 2
end if
Anyway, so we continue, in small steps – I’m sure the dedicated coder will be able to remove more than half of the above, for there’s quite a bit of redundancy. However, it’s getting late, and I assume you’ve already fixed whatever was the problem.
Best,
Michiel
--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+u...@googlegroups.com.
To post to this group, send email to e-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/be65f5c9-6232-4770-8b99-f4c76017e322%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.