Just after Start-up Sluggishness

Bill Marriott wjm at wjm.org
Tue Jun 20 00:59:37 EDT 2006


Tom Cole wrote,

>>>
The “Start the Game” button has a lot of script and the first time it
is clicked, it is slow.

The sluggishness only occurs when I click the "start the game button"
for the FIRST time. Afterwards, everything is fast.
<<<

I think the answer to this is to modularize the script in that button. For 
example, if the button currently does this:

----------------------
on mouseup
  task 1
  blah blah
  task 2
  task 3
  confirmation 1
    do if yes
  else
    do if no
  task 4
end mouseup
----------------------

you would be better off with:

----------------------
on mouseup
  module A
  module B
  module C
  module D
  module E
end mouseup

on module A
  task 1
  blah blah
end module A

on module B
  task 2
end module B

on module C
  task 3
end module C

on module D
  confirmation 1
    do if yes
  else
    do if no
  return xyz
end module D

on module E
  task 4
end module E
----------------------

In this way, you can "send" messages to the button to perform discrete 
functions... even passing along parameters and getting results returned. You 
won't have to worry about dialog alerts, because you can slice the modules 
up in such a way as to avoid them. Some modules could be called from the 
pre-openstack handler, and some could still be called from the button.

In fact, I strongly suspect if you break up the code this way you'll find 
where some inefficiencies are occurring to cause the slowdown in the first 
place. (At least it will be easier to isolate them).


>>>
My only problem is that both buttons say, “ARE YOU SURE YOU WANT TO DO
THIS?” (or whatever) with “Yes” or “No.” What script do I write to
click the YES in the answer dialog box? For example:

On preopenstack
Click card button “Play Game” of card “Menu”
-- (It will say “Play game?” Yes    No)
Choose YES please! (How do I write this?)
Click card button “Go to Main Menu” of card “Play Game”
-- (It will say “Go to the Menu” Yes  No)
Choose YES please! (How do I write this?)
End preopenstack

If I know how to write the script to click the yes or no option, I can
try this out.
<<<

You would not "click the card button" but instead do something like this:

on preOpenStack
  send "initialize" to btn "Play Game" of cd "Menu"

end preOpenStack

-- cd btn "Play Game" --
on mouseup
  initialize
  ask "Do you want to play a game?"
  if it is "Yes" then playgame
end mouseup


on initialize
  -- do lots of boring stuff
end initialize

on playgame
  -- rev your engines
end playgame

Do you see what I'm getting at? 






More information about the use-livecode mailing list