Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!nntp.club.cc.cmu.edu!goldenapple.srv.cs.cmu.edu!rochester!udel-eecis!gatech!csulb.edu!hammer.uoregon.edu!news.mathworks.com!uunet!in2.uu.net!165.254.2.53!nonexistent.com!not-for-mail
From: vlad@world2u.com (Vlastimil Adamovsky)
Subject: Re: HELP:case statement in smalltalk?
X-Newsreader: Forte Free Agent 1.0.82
X-Nntp-Posting-User: (Unauthenticated)
Message-ID: <E7s7Is.3Lo@nonexistent.com>
References: <5hdqt8$3ca@babyblue.cs.yale.edu>
X-Trace: 859599890/4656
X-Nntp-Posting-Host: i123.184.world2u.com
Date: Sat, 29 Mar 1997 01:48:41 GMT
Lines: 40

STOLPEC@ECSUC.CTSTATEU.EDU (CHRISTOPHER STOLPE) wrote:

>Pardon my C but how do you do a case statement in smalltalk? How do you do
>structures? And in smalltalk express how do you check for a keypress event? I
>want to be able to set a flag by checking if a key was pressed while the window
>had focus and then get that key from input.

>Thanks
>Chris Stolpe

I usually faked the case statement like this:


getInput:  aString
   |case|

case := Dictionary new.

case at: 'blahblah' put: [ self beep];
         at: 'nono' put: ["I said no"];
         at: 'getRichQuickly' put:[ (Date today < (Date yesterday)) ifTrue:[5]


ifFalse:["It does not happen"].

^case at: aString




Hope you will enjoy this code.





 Vlastimil Adamovsky
 ** C++ and Smalltalk consultant **


