0
Find empty value on structure

/t5/coldfusion-discussions/find-empty-value-on-structure/td-p/911585
Dec 09, 2008
Dec 09, 2008
Copy link to clipboard
Copied
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?
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
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/find-empty-value-on-structure/m-p/911586#M83786
Dec 09, 2008
Dec 09, 2008
Copy link to clipboard
Copied
Perhaps a better place for that if/else logic would be as you
are populating the structure.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Guest
AUTHOR
/t5/coldfusion-discussions/find-empty-value-on-structure/m-p/911587#M83787
Dec 09, 2008
Dec 09, 2008
Copy link to clipboard
Copied
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>
<cfloop from="1" to="#ArrayLen(Variables.aResults)#" index="ARY">
<!--- Lets reset the blanks --->
<cfset str_mystruct[Variables.aResults[ARY]['key']] = 'blank' />
</cfloop>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Advocate
,
LATEST
/t5/coldfusion-discussions/find-empty-value-on-structure/m-p/911588#M83788
Dec 10, 2008
Dec 10, 2008
Copy link to clipboard
Copied
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
http://cflib.org/udf/RemoveEmptyStructureKeys
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

