> I'm trying to find why this if condition keeps getting evaluated as true
> when it shouldn't.  I've traced through the debugger to track the value of
> the if condition and even though the record count condition comes up as 0
> when I put a watch on it, it still executes.
> I added a CFOUTPUT between the query and the <CFSCRIPT> and it always
> returns a 0 on the page too.
>
> <!--- Check if we're monitoring NT --->
> <cfquery name="Check_NT" datasource="#dsn#" dbtype="#driver_type#">
>       select distinct system_type from uv_system_all
>       where system_type='NT'
> </cfquery>
>
> <cfoutput>#Check_NT.RecordCount#</cfoutput>
>
> <!--- If we count one or more we add it to an array of structures --->
> <CFSCRIPT>
>       if (Check_NT.RecordCount gt 0 is "TRUE")
>               session.device_view_list[#device_no#]=StructNew();
>               StructInsert(session.device_view_list[#device_no#],
> "monitored", "TRUE");
>               StructInsert(session.device_view_list[#device_no#],
> "description", "NT Servers");
>               StructInsert(session.device_view_list[#device_no#],
> "icon_filename", "../images/med_icons/icon_fileserver");
>               device_no=device_no + 1;
>               // Note, the icon filename is incomplete because the status
> color and the .gif will be appended later
> </CFSCRIPT>
>
> Would appreciate any help as this is my first time putting my hand to
> cfscript...

CFScript works pretty much like JavaScript, therefore if you have an if()
then you need to tell it if there is more than one line of code to handle

Firstly, your if() is a bit wrong;

        if (Check_NT.RecordCount gt 0 is "TRUE")

has 3 options in the condition, which is just plain wrong

        if (Check_NT.RecordCount gt 0)

will work, the {is "TRUE"} will never be accepted as a logical part of the
if(), therefore it'll never evaluate.


Next, you need to specify what is handled with the if()

        session.device_view_list[#device_no#]=StructNew();

is the only line of code executed after the if, you want;

        if (Check_NT.RecordCount gt 0)
        {session.device_view_list[#device_no#]=StructNew();
         StructInsert(session.device_view_list[#device_no#],"monitored", "TRUE");
         StructInsert(session.device_view_list[#device_no#],"description", "NT
Servers");
         StructInsert(session.device_view_list[#device_no#],"icon_filename",
"../images/med_icons/icon_fileserver");
         device_no=device_no + 1;
         // Note, the icon filename is incomplete because the statuscolor and the
..gif will be appended later
        }

This should help

Philip Arnold
Director
Certified ColdFusion Developer
ASP Multimedia Limited
T: +44 (0)20 8680 1133

"Websites for the real world"

**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to