Skip to main content
Known Participant
October 22, 2013
Question

StructIsEmpty function, help!

  • October 22, 2013
  • 1 reply
  • 481 views

I'm passing a structure to a function for req. fields validation but I first check whether or not my structure is empty.

If all element in my structure is empty I don't pass this structure to the validation function.

So I use StructIsEmpty to check my structure.

The problem is, when my Structure's elements contain only empty string, StructIsEmpty return "NO"

How can I have StructIsEmpty to return YES when all of the structure element is an empty string?

   <cfset st_MyStruct=StructNew()>

   <cfset st_MyStruct["InstType"]="#Trim(arr[112])#">    

   <cfset st_MyStruct["InstId"]="#Trim(arr[113])#">  

   <cfset st_MyStruct["PLN"]="#Trim(arr[115])#">    

   <cfset st_MyStruct["PFN"]="#Trim(arr[116])#">

   <cfset st_MyStruct["Referal"]="#Trim(arr[118])#">

 

   <cfif StructIsEmpty(st_MyStruct) NEQ "NO">

         <CFINVOKE component="cfcomponents.ValidateFields" method="CheckReqFields"

                                                                st_MyStruct="#st_MyStruct#"

                                                                Inst="#arguments.Inst#" >   

  </cfif>

This topic has been closed for replies.

1 reply

p_sim
Participating Frequently
October 23, 2013

<cfif NOT ( StructIsEmpty(st_MyStruct["InstType"]) AND

StructIsEmpty(st_MyStruct["InstId"]) AND ........................

)>

     <CFINVOKE component="cfcomponents.ValidateFields" method="CheckReqFields"

                                                                st_MyStruct="#st_MyStruct#"

                                                                Inst="#arguments.Inst#" >  

</cfif>