Matt Robertson wrote:

> 5 lines of code, total.  While you could do this without *too* much 
> more CF code, this is a very simple example.  Doing U.S. ZIP code 
> ranges, where you are selecting combinations of individual ZIPs and 
> ranges - can be coded in a LOT fewer lines if you allow something like 
> the following:
>
> <CFSWITCH EXPRESSION="#variables.ZIPCode#>
>    <CFCASE VALUE="LT 93711">
>       ...blahblahblah...
>    </CFCASE>
>    <CFCASE VALUE="93712, 93713 TO 93940, 93950, 94086 TO 95050">
>       ...blahblahblah...
>    </CFCASE>
>    <CFCASE VALUE="GT 93940">
>       ...blahblahblah...
>    </CFCASE>
> </CFSWITCH>
>
> I have statements like the above that in their native tongue take up a 
> small fraction of what CF needs to come to the same solution.

How much does CF *really* need? Pseudocode:
<cfif variables.ZIPCode LT 93711>
       ...blahblahblah...
<cfelseif mySwitch(variables.ZIPCode, "93712, 93713 TO 93940, 93950, 
94086 TO 95050")>
       ...blahblahblah...
<cfelseif variables.ZIPCode GT 93711>
       ...blahblahblah...
</cfif>

You just have to write mySwitch() once and put that in your standard UDF 
includefile.

> Of course, the price of this ease of coding may be horrifying 
> performance for both CF and Blue Dragon... but you asked ;D

I always believed the whole point of a switch statement was that only 
the switch side had to be evaluated as an expression and the case sides 
were simple values, thereby greatly reducing the amount of processing. 
Comments?

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
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

Reply via email to