RE: multiple case values in switch statement in cfscript

2002-10-10 Thread S . Isaac Dealey

Please, no pictures. :P

It's just once around the block in c++ land. :)

I taught myself c++ a few months before I got into CF thinking it would help
me get a good job... Since then I've never been asked to do anthing but CF,
ASP and JavaScript. But when I started working with CF I was thinking
something similar about  -- "So, how do I cascade my case
statements???" ... :P

And technically, the cfscript syntax gives you more control.

> Sir Isaac - I bow to your wisdom.  I have never seen it in
> that context.

> -Original Message-
> From: S. Isaac Dealey [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, October 10, 2002 12:59 PM
> To: CF-Talk
> Subject: Re: multiple case values in switch statement in
> cfscript


>> Hi

>> Could anyone tell me if its possible to define multiple
>> case statements
>> In a switch block in cfscript..

>> So a cfscript version of :

>> 


> Yes it is.

> CFScript uses standard C/C++/Java/JavaScript syntax for
> switch/case, so the
> cfscript equivalent looks like this:

> switch (exp) {
>   case "a": { ; }
>   case "b": { .. do something ... }
>   case "c": { .. do something ... break; }
>   default: { ... do something ... }
> }

> The case expressions cascade, so from the point that your
> case evaluates, to
> the point that you insert a break; in your case statements
> is what portion
> of the code will execute, thus, if the value of exp is a
> or b, in the
> example above, all of the actions ( or lack thereof in the
> case of a ) will
> occur for cases a,b and c. If the value of exp is c then
> only the action for
> c will occur. The default actions will not be processed
> unless something
> other than a b or c is found in the value of exp because
> of the break; at
> the end of the actions for c.

> hth

> S. Isaac Dealey
> Certified Advanced ColdFusion 5 Developer

> www.turnkey.to
> 954-776-0046

> ~~
> ~~~|
> Archives:
> http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
> Subscription: http://www.houseoffusion.com/index.cfm?sideb
> ar=lists&body=lists/cf_talk
> FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
> Structure your ColdFusion code with Fusebox. Get the
> official book at http://www.fusionauthority.com/bkinfo.cfm


Isaac
Certified Advanced ColdFusion 5 Developer

www.turnkey.to
954-776-0046

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm



RE: multiple case values in switch statement in cfscript

2002-10-10 Thread Mark A. Kruger - CFG

Sir Isaac - I bow to your wisdom.  I have never seen it in that context.

-Original Message-
From: S. Isaac Dealey [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 10, 2002 12:59 PM
To: CF-Talk
Subject: Re: multiple case values in switch statement in cfscript


> Hi

> Could anyone tell me if its possible to define multiple case statements
> In a switch block in cfscript..

> So a cfscript version of :

> 


Yes it is.

CFScript uses standard C/C++/Java/JavaScript syntax for switch/case, so the
cfscript equivalent looks like this:

switch (exp) {
case "a": { ; }
case "b": { .. do something ... }
case "c": { .. do something ... break; }
default: { ... do something ... }
}

The case expressions cascade, so from the point that your case evaluates, to
the point that you insert a break; in your case statements is what portion
of the code will execute, thus, if the value of exp is a or b, in the
example above, all of the actions ( or lack thereof in the case of a ) will
occur for cases a,b and c. If the value of exp is c then only the action for
c will occur. The default actions will not be processed unless something
other than a b or c is found in the value of exp because of the break; at
the end of the actions for c.

hth

S. Isaac Dealey
Certified Advanced ColdFusion 5 Developer

www.turnkey.to
954-776-0046

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm



RE: multiple case values in switch statement in cfscript

2002-10-10 Thread Fitch, Tyler

One option might be to selectively use your break; command in the switch
statement.

If muliple cases can do the same code try


switch (theVar){
case "val1":{
setAVar = 'it was case 1';
break;
}
case "val2":
case "val3":{
setAVar = 'it was case 2 or 3'; 
break;
}
case "val4":{
setAVar = 'it was case 4';  
break;
}
}


I _think_ from what I remember reading that it'll keep processing until
it hits a break;

Their might be a cleaner way to implement the case statements too, but
it works from my quick tests.

t

**
Tyler M. Fitch
Certified Advanced ColdFusion 5 Developer

http://isitedesign.com
**

-Original Message-
From: Gyrus [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, October 10, 2002 9:56 AM
To: CF-Talk
Subject: Re: multiple case values in switch statement in cfscript


- Original Message -
> Could anyone tell me if its possible to define multiple case 
> statements In a switch block in cfscript..
---

I don't think this is possible. If you get an error when you try it,
that would confirm things :-)  I think it might be to do with CFScript
being kept as close as possible to JavaScript. Use  if
necessary...

Gyrus
[EMAIL PROTECTED]
work: http://www.tengai.co.uk
play: http://www.norlonto.net
PGP key available


~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm



RE: multiple case values in switch statement in cfscript

2002-10-10 Thread S . Isaac Dealey

Nope -- you can include empty case statements without a break; and they will
cascade down into the following case statements until it finds a break; It's
definitely doable ( see my previous post ), it's just that the syntax is
_very_ different.

S. Isaac Dealey
Certified Advanced ColdFusion 5 Developer

www.turnkey.to
954-776-0046

> No it is not.  Each case must be listed individually.  If you really must
> use a single case for multiple values you will have to move to tag syntax
> ().

> -Original Message-
> From: Kola Oyedeji [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, October 10, 2002 11:11 AM
> To: CF-Talk
> Subject: multiple case values in switch statement in cfscript


> Hi

> Could anyone tell me if its possible to define multiple case statements
> In a switch block in cfscript..

> So a cfscript version of :

> 


> Thanks

> Kola



> 
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.



Re: multiple case values in switch statement in cfscript

2002-10-10 Thread S . Isaac Dealey

> - Original Message -
>> Could anyone tell me if its possible to define multiple case statements
>> In a switch block in cfscript..
> ---

> I don't think this is possible. If you get an error when you try it, that
> would confirm things :-)  I think it might be to do with CFScript being
> kept as close as possible to JavaScript. Use  if necessary...

No it's definitely doable ( see my previous message ) -- it's just that the
syntax is _very_ different.

S. Isaac Dealey
Certified Advanced ColdFusion 5 Developer

www.turnkey.to
954-776-0046
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com



Re: multiple case values in switch statement in cfscript

2002-10-10 Thread S . Isaac Dealey

> Hi

> Could anyone tell me if its possible to define multiple case statements
> In a switch block in cfscript..

> So a cfscript version of :

> 


Yes it is.

CFScript uses standard C/C++/Java/JavaScript syntax for switch/case, so the
cfscript equivalent looks like this:

switch (exp) {
case "a": { ; }
case "b": { .. do something ... }
case "c": { .. do something ... break; }
default: { ... do something ... }
}

The case expressions cascade, so from the point that your case evaluates, to
the point that you insert a break; in your case statements is what portion
of the code will execute, thus, if the value of exp is a or b, in the
example above, all of the actions ( or lack thereof in the case of a ) will
occur for cases a,b and c. If the value of exp is c then only the action for
c will occur. The default actions will not be processed unless something
other than a b or c is found in the value of exp because of the break; at
the end of the actions for c.

hth

S. Isaac Dealey
Certified Advanced ColdFusion 5 Developer

www.turnkey.to
954-776-0046
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm



RE: multiple case values in switch statement in cfscript

2002-10-10 Thread Rob Rohan

Woops! sorry didn't see the "in cfscript" part.

Guessing...

switch(#variabel#){
case a:

case b:

case c:

break;

case q:

break;
}

if that doesn't work, then it wont work.

-Original Message-
From: Rob Rohan [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 10, 2002 10:13 AM
To: CF-Talk
Subject: RE: multiple case values in switch statement in cfscript




-Original Message-
From: Kola Oyedeji [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 10, 2002 9:11 AM
To: CF-Talk
Subject: multiple case values in switch statement in cfscript


Hi

Could anyone tell me if its possible to define multiple case statements
In a switch block in cfscript..

So a cfscript version of :




Thanks

Kola




~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm



RE: multiple case values in switch statement in cfscript

2002-10-10 Thread Bryan Love

yes, but not exactly as you hoped...

Keep in mind that when a case evaluates to true, CF will execute EVERYTHING
until it finds a break statement...

so this would do what you want...


switch( someVal ){
case "a":
case "b":
case "c":
case "d":
case "e":
[execute some code]
break;
}

+---+
Bryan Love
  Macromedia Certified Professional
  Internet Application Developer
  Database Analyst
TeleCommunication Systems
[EMAIL PROTECTED]
+---+

"...'If there must be trouble, let it be in my day, that my child may have
peace'..."
- Thomas Paine, The American Crisis

"Let's Roll"
- Todd Beamer, Flight 93



-Original Message-
From: Kola Oyedeji [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 10, 2002 9:11 AM
To: CF-Talk
Subject: multiple case values in switch statement in cfscript


Hi

Could anyone tell me if its possible to define multiple case statements
In a switch block in cfscript..

So a cfscript version of :




Thanks

Kola



~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.



Re: multiple case values in switch statement in cfscript

2002-10-10 Thread Jochem van Dieten

Kola Oyedeji wrote:
> 
> So a cfscript version of :
> 
> 

switch(name) {
 case "Xander":
 case "Oz":
 case "Angel":
 {
 male=true;
 break;
 }
 case "Tara":
 case "Willow":
 case "Cordelia":
 {
 male=false;
 break;
 }
 }

Jochem

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com



Re: multiple case values in switch statement in cfscript

2002-10-10 Thread Nick Han

Don't think it's possible to specify a list like that  with cfscript.  You would need 
five different case statements.
Not sure whether you can do this in cfmx.

Nick Han

>>> [EMAIL PROTECTED] 10/10/02 09:11AM >>>
Hi

Could anyone tell me if its possible to define multiple case statements
In a switch block in cfscript..

So a cfscript version of :




Thanks

Kola



~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com



RE: multiple case values in switch statement in cfscript

2002-10-10 Thread Rob Rohan



-Original Message-
From: Kola Oyedeji [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 10, 2002 9:11 AM
To: CF-Talk
Subject: multiple case values in switch statement in cfscript


Hi

Could anyone tell me if its possible to define multiple case statements
In a switch block in cfscript..

So a cfscript version of :




Thanks

Kola



~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm



RE: multiple case values in switch statement in cfscript

2002-10-10 Thread Mark A. Kruger - CFG

No it is not.  Each case must be listed individually.  If you really must
use a single case for multiple values you will have to move to tag syntax
().

-Original Message-
From: Kola Oyedeji [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 10, 2002 11:11 AM
To: CF-Talk
Subject: multiple case values in switch statement in cfscript


Hi

Could anyone tell me if its possible to define multiple case statements
In a switch block in cfscript..

So a cfscript version of :




Thanks

Kola



~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm



Re: multiple case values in switch statement in cfscript

2002-10-10 Thread Gyrus

- Original Message -
> Could anyone tell me if its possible to define multiple case statements
> In a switch block in cfscript..
---

I don't think this is possible. If you get an error when you try it, that
would confirm things :-)  I think it might be to do with CFScript being kept
as close as possible to JavaScript. Use  if necessary...

Gyrus
[EMAIL PROTECTED]
work: http://www.tengai.co.uk
play: http://www.norlonto.net
PGP key available

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.



multiple case values in switch statement in cfscript

2002-10-10 Thread Kola Oyedeji

Hi

Could anyone tell me if its possible to define multiple case statements
In a switch block in cfscript..

So a cfscript version of :




Thanks

Kola


~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com