Re: Case Statements and INequalities

  • From: Jared Wright <wright.jaredm@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Tue, 18 Sep 2007 07:11:42 -0400

Cool. Yeah, as mentioned before, I couldn't find any examples of using statements like this and didn't want to spedn too long trying to force a left shoe on a right foot so to speak. Now that I know I'm at least headed the right way, I'll play around with the sintax and see if I can't get things working. Thanks.


JW
Bob J. wrote:
I don't remember the exact syntax so I'll leave that up to you.  Here is how
to handle your example...

Case x<10

Case x>100

Default

The effect is that if x is not < 10 and x is not > 100 then it is somewhere
between.

hth

Bob


----- Original Message ----- From: "Jared Wright" <wright.jaredm@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Tuesday, September 18, 2007 12:43 AM
Subject: Case Statements and INequalities


Hey all, Two in one night; I'm on a role. Anyway... I am familiar with
the properties of a switch statement and how case statements work with
it. My question is whether or not I can specify anything other than
direct values for case statements? For an example... Let's  assume I
have a variable of X, and I indicate this variable in a switch
statement. I want the flow of control to go one place if X is less than
10, another if X is between 10 and 100, and another if X is greater than
100. I see how to specify these inequalities using if statements, but it
seems that using a switch statement with three separate cases would be a
more efficient way of handling this. But all I see in the online
documentation I've dug up is case statements directly defined
and nothing about case statements that cover a range of potential values
for the variable indicated in the switch statement. I know that I can
assign multiple case statements to one block of code, but I can't
imagine having to specify each potential value in the range this way.
Thoughts on how I can clean this up are welcome, and as always, are
appreciated.

JW
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind



__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: