The best way to evaluate those expressions is as Boolean values...

<cfif NOT IsDefined("Attributes.Request_Time")>

Is way faster than saying IS "NO" That is even slower than saying IS 0 since
you are using a string.  Strings are slower to evaluate than numbers, so
don't put quotes around numbers, it may evaluate slower if CF treats it as a
string.

<cfif NOT RequestTime>

Would be the faster way to execute the conditional in your second statement.

Boolean expressions treat non zero numbers as true, and zeros as false.  So
if you want to check to see if a variable is defined all you really have to
say is...
<cfif IsDefined("var")> IsDefined returns a Boolean (true/false) if you want
to check for true you don't need any thing extra, if you want to check for
false, you insert a NOT.

_______________________________________________
Pete Freitag
CFDEV.COM
Cold Fusion Developer Resources
http://www.cfdev.com/

-----Original Message-----
From: Ben Lowndes [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 07, 2000 2:24 PM
To: [EMAIL PROTECTED]
Subject: Most efficeint validation


Hello,

I've just been trying to figure out the most efficent way to check for a
passed (form or url) variables pesence and value. The code I've been using
is:

<CFIF (IsDefined("ATTRIBUTES.Request_time") IS "No") OR
(Trim(ATTRIBUTES.Request_time) IS "")>
Request_time is not defined
<CFELSE>
Request_time is defined
</CFIF>

But is this the best way, it must be a common problem. I also thought about
using :

<CFPARAM NAME="ATTRIBUTES.Request_Time" DEFAULT="0">
<CFIF Trim(RequestTime) IS "0">
Request_time is not defined
<CFELSE>
Request_time is defined
</CFIF>

but that doesn't work as it doesn't apply the value 0 if Request_time is
passed but not defined... So is the first method the best?

Thanks
Ben

----------------------------------------------------------------------------
--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.

------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to