RE: Why doe my cfscript if statement fail?
try just putting CFSCRIPT if (Check_NT.RecordCount gt 0) .. HTH Mike -Original Message- From: Kevin Gilchrist [mailto:[EMAIL PROTECTED]] Sent: Monday, January 22, 2001 17:10 To: CF-Talk Subject: Why doe my cfscript if statement fail? Hi There, 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... Thanks, Kevin Kevin Gilchrist, Senior Consultant RedSiren Technologies, www.redsiren.com ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Why doe my cfscript if statement fail?
Kevin, I'm actually surprised that CF doesn't throw an error with the statement. Get rid of the "is 'TRUE'" portion: if( Check_NT.RecordCount GT 0 ){ } (You can shortcut this further to just "if( Check_NT.RecordCount ){" Also, I don't notice any brackets around your IF statement, which means only the first line after the statement would be ignored. -Dan -Original Message- From: Kevin Gilchrist [mailto:[EMAIL PROTECTED]] Sent: Monday, January 22, 2001 12:10 PM To: CF-Talk Subject: Why doe my cfscript if statement fail? Hi There, 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... Thanks, Kevin Kevin Gilchrist, Senior Consultant RedSiren Technologies, www.redsiren.com ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Why doe my cfscript if statement fail?
if (Check_NT.RecordCount gt 0 is "TRUE") I don't know if this is the problem, but I would definitely not write that condition that way. I would use either: 1. if (check_NT.recordcount gt 0) or 2. if (check_NT.recordcount) Both will achieve the result I assume you are looking for. - Sean ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Why doe my cfscript if statement fail?
I'm trying to find why this if condition keeps getting evaluated as true when it shouldn't. ... if (Check_NT.RecordCount gt 0 is "TRUE") You've got two conditions, not one. You can just use one condition: if (Check_NT.RecordCount gt 0) Or, you can simply reference the variable - a nonzero value will evaluate to true: if (Check_NT.RecordCount) Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ voice: (202) 797-5496 fax: (202) 797-5444 ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Why doe my cfscript if statement fail?
just use cfscript if (check_nt.recordcount GT 0) . /cfscript There is no need to add the "is 'TRUE'" clause, which is what is causing the statement to fail. DC - Original Message - From: "Kevin Gilchrist" [EMAIL PROTECTED] To: "CF-Talk" [EMAIL PROTECTED] Sent: Monday, January 22, 2001 12:10 Subject: Why doe my cfscript if statement fail? Hi There, 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... Thanks, Kevin Kevin Gilchrist, Senior Consultant RedSiren Technologies, www.redsiren.com ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Why doe my cfscript if statement fail?
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/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists