Uhm.. If..elseif..elseif..elseif..etc..else..endif

Cfswitch is equivalent to cfscript's switch which is equivalent to most
C-like languages' switch statements which REQUIRES literals in its case
"labels". :P

This is not specific to CFML v5. CFMX has the same "problem".

-------------------------------
James Ang
Sr. Developer/Product Engineer
MedSeek, Inc.
[EMAIL PROTECTED]



-----Original Message-----
From: Shawn Grover [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 26, 2003 2:46 PM
To: CF-Talk
Subject: Using variables in a Switch case?


CF 5 doesn't like this:

<cfset nID = 3>
<cfset nTest1 = 2>
<cfset nTest2 = 3>
<cfswitch expression="#nID#">
        <cfcase value="#nTest1#">
                <br>Two
        </cfcase>
        <cfcase value="#nTest2#">
                <br>three
        </cfcase>
</cfswitch>

It throws an error saying the cfcase must have a constant value.  So, if
I
do this instead:

        <cfcase value="2">
                <br>Two
        </cfcase>
        <cfcase value="3">
                <br>three
        </cfcase>

all works as expected.

The downside is that we have a large number of items where their IDs
will be
changing on a regular basis (update, and replace in a different system
assigns a new ID - our code is keyed on that ID).  We are assigning
these
IDs into a structure in application.cfm to minimize the number of
changes we
need to make when the IDs change.  But, this switch block doesn't like
that
plan.  Is there any way to do this with the variables?

Thanks in advance.

Shawn

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
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

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to