EIVERSO@cms.cc.wayne.edu (06/17/91)
psych@watserv1.waterloo.edu (R. Crispin - Psychology) writes >In article <1991Jun14.175048.20051@cs.wayne.edu> EIVERSO@cms.cc.wayne.edu write >>I'd write it like this: >> >>on keyDown >> if key = "a" then doThis >> if key = "b" then doThat >> if key = "c" then doTheOther >>end keyDown >> >This is a slower technique since no matter what value KEY has all 3 statements >are executed. The only time this is faster is if key is unassigned. A >better technique is as follows >on keyDown Key > if key = "a" then doThis > else if key = "b" then doThat > else if key = "c" then doTheOTher >end keydown >I ran some tests and this can be up to 25% faster but usually it is 10% faster If I don't talk may way out of this one, well... All three statements would not necessarily be executed. It depends on the handlers messaged in the KeyDown handler. For instance: on doThis <many things> exit to HyperCard --no further processing! end doThis Since some of you might think this os a cop-out here's a MUCH BETTER script on keyDown Key --check to see if the key pressed has a handler (either a, b, or c has one) if key is in "abc" then do "keyProc" & key --calls handlers keyProca, keyProcb, or keyProcc end keyDown Hopefully the elegance of this code will save my good name. --Eric Iverson