Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Find empty value on structure

Guest
Dec 09, 2008 Dec 09, 2008
I'm assigning values to my structure dynamically and I need to find if one or more of the value(s) is/are empty string value
I tried to use :
<cfset aResults = #StructFindValue(mystruct,"", "all" )#> and I got what I wanted but now I'm not sure how can I refer back to the Key for those empty value(s)?

For example if this is my structure:
<CFSET str_mystruct= structNew()>
<CFSET str_mystruct["FN"}="Sylvia">
<CFSET str_mystruct["LN"}="Smith">
<CFSET str_mystruct["Add"}="">
<CFSET str_mystruct["City"}="Bladensburg">
<CFSET str_mystruct["zip"}="">

The StructFindValue function found 2 keys with empty values,they are Add and Zip
what is the syntax for CFIF condition, for example if Add or Zip keys is "" do something?


TOPICS
Getting started
380
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 09, 2008 Dec 09, 2008
Perhaps a better place for that if/else logic would be as you are populating the structure.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 09, 2008 Dec 09, 2008
Get the array of results from the function then loop over that array. The array will only contain results for blank keys. So something like:

<cfloop from="1" to="#ArrayLen(Variables.aResults)#" index="ARY">
<!--- Lets reset the blanks --->
<cfset str_mystruct[Variables.aResults[ARY]['key']] = 'blank' />
</cfloop>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 10, 2008 Dec 10, 2008
LATEST
If you want to remove all the empty keys form your structure, you can make use of the "RemoveEmptyStructureKeys" UDF...

http://cflib.org/udf/RemoveEmptyStructureKeys
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources