New Math

Judy Perry jperryl at ecs.fullerton.edu
Fri Jan 10 21:49:01 EST 2003


First, an update about the irregularly-shaped buttons issue.  Apparently,
if one simply uses a GIF with transparency, the transparent areas do not
respond to mouse events.  This is my experience.  Am I correct about this?

Second:  I have some funny math going on.  It's the same States Quiz.  I'm
trying to have the stack keep a running track of the number of correct
answers, the number of attempts, and then divide the former by the latter
and multiply by 100 for an accuracy percentage.  For simple math, such as
3 successes out of 4 tries, the correct percentage (75) is given.
However, for other results, it's not:

2/3 = 6667
5/6 = 3333
6/7 = 4286
7/8 = 87.5
8/9 = 8889
10/11 = 9091


Here's the script:


on mouseUp
  global theState, theScore, theMClick, theTries, theAverage
  if theMClick = 0 then
    answer "Please click on the 'Play' button!"
    exit mouseUp
  end if

  if theState = 7 then
    answer "Correct.  This is the State of Utah."
    add 1 to theScore
    put theScore into field "Score"
    put 0 into theMClick
    put empty into fld "Instructions"
    send mouseUp to btn "Play"
     add 1 to theTries
    put theTries into fld "Tries"
    put (theScore/theTries)*100 into theAverage
    put theAverage into fld "Average"

    exit mouseUp
  end if
  if theState b	  7 then
   answer "No, this is not correct.  Please try again."
    add 1 to theTries
  put theTries into field "Tries"
  put (theScore/theTries)*100 into theAverage
    put theAverage into fld "Average"
end if

end mouseUp

Aside from the fact that there are probably vastly more elegant scripting
solutions, can anyone help tell me what is going on?  (The above script is
for one of the target state GIFs.  The rest have similar scripts.  "b" is
the not equals sign).

TIA,

Judy




More information about the use-livecode mailing list