I think one problem is that StructKeyFind returns an array , not a boolean value that can be tested in the CFIF.
Overall though a simpler approach may work just as well :-) On Thu, 21 Oct 2004 08:50:12 -0700, Harold Brauer <[EMAIL PROTECTED]> wrote: > I have an array of structures in a UDF. I am trying to see if a certain key > exists in the structure and if it does I want to highlight the row. When I > tried this code <CFIF form.process AND StructFindKey( #reqiredfields()#, > "main" )> I got a 500 internal error. Then when I just tried to output the > new structure I got an error saying Complex object types cannot be converted > to simple values. I have included all of the code below. Can someone please > help me with this. Thanks. > > UDF > > <!--- Are required fields filled in ---> > > <cffunction name="reqiredfields" returntype="array"> > > <!--- validate your inputs, set Variables.ErrorText if anything failes ---> > > <cfif not len(form.city) or not len(form.country) or not len(form.mgender) > or not len(form.dob1) or not len(form.title) or not len(form.message) or not > len(form.yold) or not len(form.mold) > > <-- If Error is found, create an Array of Structures ---> > > <Cfset emessage = ArrayNew(1)> > > <Cfset emessage [1] = StructNew()> > > <Cfset emessage[1].ecode = "main"> > > <cfset emessage[1].edisplay = "Required fields are blank"> > > <!--- No City ---> > > <cfelseif form.city is ""> > > <Cfset emessage [2] = StructNew()> > > <Cfset emessage[2].ecode = "city"> > > <cfset emessage[2].edisplay = "You must fill in your city"> > > </Cfif> > > <cfreturn emessage> > > </cffunction> > > Looking for Structure > > <!--- If something failed, tell the user what it was ---> > > <CFIF form.process AND StructFindKey( #reqiredfields()#, "main" )> > > <Caption align="center" valign="top" > class="error"><cfoutput>#emessage[1].edisplay#</cfoutput></Caption> > > <cfelse> > > <Caption align="center" valign="top" class="error">All fields marked with * > are required</Caption> > > </CFIF> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Purchase from House of Fusion, a Macromedia Authorized Affiliate and support the CF community. http://www.houseoffusion.com/banners/view.cfm?bannerid=36 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:182426 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54