OO (two) eyes is definitely better than one, probably in most cases, the following seems to demonstrate that. FYI, the test code is run under an app with session-enabled.
<h2>Find a structure's key/value pair</h2>
<p>
Note: an interesting thing about OO is that it is "spatial", for instance, the "internal" function may be placed below
its caller while the traditional structured programming can't.
</p>
<b>Source Code:</b><br>
<XMP>
<cfset FORM.f1 = "field one string">
<cfset FORM.f2 = "1">
<cfoutput>
FORM:<BR> #aStructKeyValuePair(FORM)# <BR>
SESSION:<BR> #aStructKeyValuePair(SESSION)# <BR>
SERVER:<BR> #aStructKeyValuePair(SERVER)# <BR>
</cfoutput>
<cffunction name="aStructKeyValuePair"
returntype="string"
access="private">
<cfargument name="aS"
type="struct"
required="true">
<cfloop item="a" collection="#arguments.aS#">
<cfoutput>
#a# -- <cfif IsSimpleValue(arguments.aS[a])>#arguments.aS[a]#<cfelse>oops, complex data here</cfif><br>
</cfoutput>
</cfloop>
</cffunction>
</XMP>
<b>Output:</b><br><br>
<cfoutput>
FORM:<BR> #aStructKeyValuePair(FORM)# <BR>
SESSION:<BR> #aStructKeyValuePair(SESSION)# <BR>
SERVER:<BR> #aStructKeyValuePair(SERVER)# <BR>
</cfoutput>
<cffunction name="aStructKeyValuePair"
returntype="string"
access="private">
<cfargument name="aS"
type="struct"
required="true">
<cfloop item="a" collection="#arguments.aS#">
<cfoutput>
#a# -- <cfif IsSimpleValue(arguments.aS[a])>#arguments.aS[a]#<cfelse>oops, complex data here</cfif><br>
</cfoutput>
</cfloop>
</cffunction>
[Todays Threads]
[This Message]
[Subscription]
[Fast Unsubscribe]
[User Settings]
[Donations and Support]