ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 10th, 2005, 09:44 AM
andy11983 andy11983 is offline
Newbie wannabe extrodanaire
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: stoke
Posts: 315 andy11983 User rank is Corporal (100 - 500 Reputation Level)andy11983 User rank is Corporal (100 - 500 Reputation Level)andy11983 User rank is Corporal (100 - 500 Reputation Level)andy11983 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 9 h 25 m 6 sec
Reputation Power: 6
assigning something to a cfif outcome

Hi,

I was just wondering if osmeone can point me in the right direction in coldfusion/sql can you have something to equal the outcome of a if statement.

E.G
Code:

iL.languageID =

<cfif (translator eq 1) AND (Currentsite IS NOT NULL) AND (bOnPage eq 0)>
filterLanguage
<cfelse>
s.defaultLanguage
</cfif>


Thanks for your help

Andy

Reply With Quote
  #2  
Old May 10th, 2005, 09:57 AM
CfFreelancer CfFreelancer is offline
CF Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Long Island, NY
Posts: 34 CfFreelancer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 29 m 50 sec
Reputation Power: 5
try

<cfif a = b>
<cfset myvar = 1>
<cfelse>
<cfset myvar = 2>
</cfif>

then use myvar anywhere in the code

Reply With Quote
  #3  
Old May 10th, 2005, 10:25 AM
fx910 fx910 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Australia
Posts: 31 fx910 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 16 m 59 sec
Reputation Power: 6
IIf function

In addition to CfFreelancer's code, you can also say:

Code:
<cfset il.LanguageID =
       Iif((Translator IS 1) AND (CurrentSite IS NOT NULL) AND (bOnPage IS 0),
           DE(filterLanguage),
           DE(s.defaultLanguage))>
This has the advantage of being somewhat faster, though the code is less immediately understandable.

Reply With Quote
  #4  
Old May 10th, 2005, 11:27 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,689 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 33 m 51 sec
Reputation Power: 53
Actually, iif() is significantly slower than <cfif>. When you combine that with the unreadability, I recommend against using it.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #5  
Old May 12th, 2005, 07:14 AM
fx910 fx910 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Australia
Posts: 31 fx910 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 16 m 59 sec
Reputation Power: 6
Thanks kiteless - I just always assumed a function would be faster. Live and learn, as they say!

Reply With Quote
  #6  
Old May 12th, 2005, 08:36 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,689 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 33 m 51 sec
Reputation Power: 53
Happy to help.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > assigning something to a cfif outcome


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT