Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / March 2005



Tip: Looking for answers? Try searching our database.

checking for values

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
fu-meng - 31 Mar 2005 18:52 GMT
hi.  i'd like to perform a check on some values. these values are being
populated into a structure that i'm then returning to flash. here's how it's
currently set up:  <cfscript>     inventory[counter]['visits_total'] =
visits_total;     inventory[counter]['time_total'] = time_total;
    inventory[counter]['time_view_avg'] = time_view_avg;    </cfscript>  what i'm
trying to do is check the visits_total. if that equals zero or if it returns
some undefined value, then i'd like to populate it with a value of '0'.
currently, it just returns an empty value. i tried this but it doesn't seem to
be working.  <cfscript>         <cfif visits_total NEQ ''>
            inventory[counter]['visits_total'] = visits_total;
            inventory[counter]['time_total'] = time_total;
            inventory[counter]['time_view_avg'] = time_view_avg;         <cfelse>
            inventory[counter]['time_total'] = time_total;
            inventory[counter]['visits_total'] = 0;
            inventory[counter]['time_view_avg'] = 0;         </cfif>                     </cfscript>  now
when i run this, no values are being returned at all. can i put a conditional
within cfscript tags? i'm not really sure where i'm going wrong as i'm
relatively new to coldfusion and my knowledge is a bit scattered on the
subject.   any insight is greatly appreciated.  best,  fumeng.
nTesla - 31 Mar 2005 19:41 GMT
You probably want something like this (remember, <cfscript> is a slightly
different *dialect* than cfml.  

<cfscript>
  if (visits_total NEQ "") {
    inventory[counter]["visits_total"] = visits_total;
    inventory[counter]["time_total"] = time_total;
    inventory[counter]["time_view_avg"] = time_view_avg;
  } else {
    inventory[counter]["time_total"] = time_total;
    inventory[counter]["visits_total"] = 0;
    inventory[counter]["time_view_avg"] = 0;
  }
</cfscript>

<!--- OR --->

<cfif (visits_total NEQ "")>
  <cfset inventory[counter]["visits_total"] = visits_total>
  <cfset inventory[counter]["time_total"] = time_total>
  <cfset inventory[counter]["time_view_avg"] = time_view_avg>
<cfelse>
  <cfset inventory[counter]["time_total"] = time_total>
  <cfset inventory[counter]["visits_total"] = 0>
  <cfset inventory[counter]["time_view_avg"] = 0>
</cfif>
fu-meng - 31 Mar 2005 20:50 GMT
hello.  thank you very much for responding to my post. i appreciate your help.
i knew cfscript had a different syntax, ironically, it is one that i'm more
used to coding in....and i still had to ask! but i got it now and understand
why it works. so, thanks for your help.  much appreciated -- fumeng.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.