Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!cernvax!chx400!ugun2b!ugun2a!estier From: estier@uni2a.unige.ch Newsgroups: comp.sys.mac.hypercard Subject: Re: Why no 'case' statement in Hypertalk? Suggestions? Message-ID: <1991Jun19.113253.998@uni2a.unige.ch> Date: 19 Jun 91 09:32:53 GMT Organization: University of Geneva, Switzerland Lines: 46 In article <1991Jun4.234844.1280@cognet.ucla.edu> earl@cogdev.cognet.ucla.edu (Earl Williams) writes: > Is there really no 'case' statement in Hypertalk, or am I missing its > equivalent? For simple keypress trapping, I'd like to do something like > the following: > > on keyDown key > case > key = 'a' then do this else > key = 'b' then do that else > key = 'c' then do the other > end > end keyDown In fact, there is no need of a case statement in HyperTalk since the handler mechanism can very conveniently be substituted to it. So instead of writing borrowing sequences of "if-then-else-end if" for your example, why not writing: on keyDown key if key is in "a b c" then send key end keyDown on a do this end a on b do that end b on c do the other end c (Please don't write me that it takes too much time to execute, just wait for the next (hopefully more powerfull) Mac ;-) Thibault +----------------------------- | estier@macmail.unige.ch or | estier@cui.unige.ch or | ESTIER@CGEUGE51 +-----------------------------