Newsgroups: comp.sys.mac.hypercard
Path: utzoo!utgpu!watserv1!psych
From: psych@watserv1.waterloo.edu (R. Crispin - Psychology)
Subject: Re: Why no 'case' statement in Hypertalk?  Suggestions?
Message-ID: <1991Jun16.143300.4893@watserv1.waterloo.edu>
Organization: University of Waterloo
References: <1991Jun14.175048.20051@cs.wayne.edu>
Date: Sun, 16 Jun 1991 14:33:00 GMT
Lines: 25

In article <1991Jun14.175048.20051@cs.wayne.edu> EIVERSO@cms.cc.wayne.edu writes:
>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.
Richard Crispin              Phone:    (519)888-4781
Dept. of Psychology          EMail:    psych@watdcs.uwaterloo.ca 
University of Waterloo                 psych@watserv1.uwaterloo.ca 
Waterloo, Ont.   Canada   N2L 3G1
