Hey guys,

I don't understand why you guys don't like switch case statements? Really. I am trying to remember the first time I saw and used them back in Supercard. I remember thinking they were more difficult to write but once I did they seemed to do a lot more than if then's or at least with fewer words. I am curious to maybe what I saw that others didn't or what others see (and don't like) that I didn't see.
Given:

on mouseUp
put "Red" into colorBall

switch colorBall
        case "Blue"
                answer "Blue" with "OK"
        break
        case "Red"
                answer "Red" with "OK"
        break
        case "Green"
                answer "Green" with "OK"
        break
        default
                answer "None" with "OK"
end switch

end mouseUp
-----------------
on mouseUp
put "Red" into colorBall

if colorBall is "Blue" then
        answer "Blue" with "OK"
else if colorBall is "Red" then
        answer "Red" with "OK"
else if colorBall is "Green" then
        answer "Green" with "OK"
else if colorBall is not "Green" or "Red" or "Blue" then
        answer "None" with "OK"
end if

end mouseUp

The if then statement looks busier to me and just seems uglier whereas the case just seems a little cleaner. but does have more lines. But my eye can follow the different 'cases' a lot easier in the switch statement.

(I am not trying to argue this as much as I am trying to gain some insight to how others think and see things)

Thanks

Tom

On Feb 18, 2006, at 2:38 PM, Garrett Hylltun wrote:


On Feb 18, 2006, at 10:43 AM, Judy Perry wrote:

Hi Eric,

I do think that Ken IS making effort. Lots of effort. He is doing us and
the company a favor by showing exactly what it is (in this particular
situation) that absolutely bedevils newcommers who are not programmers.

Case statements and pWhich's simply are NOT comprehensible to
non-programmers!

I myself avoid Case statements completely and end up replacing them with If statements. I've been programming since about 1996ish, using either a basic or scripting language, and even in those, I've always seemed to avoid Case.

Not sure why either, just didn't like Case and always found an alternative to it.

I recently uploaded to the user spaces a text editor example that I made to learn Rev. In it you'll see that for the menu bar and a popup menu that I completely dumped the case statements and replaced them all with if statements.

on menuPick varMenuItemSelected
  if varMenuItemSelected is "Cut" then
    SubCut
  else if varMenuItemSelected is "Copy" then
    SubCopy
  else if varMenuItemSelected is "Paste" then
    SubPaste
  else if varMenuItemSelected is "Undo" then
    SubUndo
  else if varMenuItemSelected is "Word Wrap" then
    SubWordWrap
  end if
end menuPick

I wouldn't go so far as to say I'm a real experienced programmer, but enough brains left in my head that I am capable of getting something done (when the A.D.D. isn't screwing with me).

And to this day, I just don't understand the whole purpose of the Case statement..... Still don't even after reading a few of the replies to this thread.

And I think another thing, a bit odd I'm sure, but I find the Case statements to be... well... Ugly for some reason. Just looking at code for a Case statement doesn't seem to flow naturally in my mind, but an equivalent If statement does. Don't ask me why! Could be that I'm just a seriously odd fellow ;-)

-Garrett
P.S. BOYCOTT CASE STATEMENTS!  IF STATEMENTS ROCK!
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Thomas J McGrath III
[EMAIL PROTECTED]

Lazy River Software™ - http://www.lazyriversoftware.com

Lazy River Metal Art™ - http://www.lazyriversoftware.com/metal.html

Meeting Wear™ - http://www.cafepress.com/meetingwear

Semantic Compaction Systems - http://www.minspeak.com

SCIconics, LLC - http://www.sciconics.com/sciindex.html







_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to