I want to easily put an argument's struct contents into the variables scope for all functions of a component. 'Title' is one of the searchitems struct.
<cffunction name="setSearch" acces="public" returntype="void">
<cfargument name="searchitems" type="struct" required="true" />
<cfset variables = arguments.searchitems>
<cfset variables.test = "yo">
</cffunction>
<cffunction name="testit" acces="public" returntype="void">
<cfdump var="#variables.test#"><br>
<cfif isdefined('variables.test')>found in variables.test </cfif>
<cfif isdefined('variables.variables.test')>found in variables.variables.test </cfif>
<hr>
<cfdump var="#variables.title#"><br>
<cfif structkeyexists(variables,'title')>found in variables.title with structkeyexists </cfif>
<cfif structkeyexists(variables.variables,'title')>found in variables.variables.title with structkeyexists</cfif>
<cfif isdefined('variables.title')>found in variables.title </cfif>
<cfif isdefined('variables.variables.title')>found in variables.variables.title</cfif>
</cffunction>
however running this gives:
yo
found in variables.test
mytitletext
found in variables.variables.title with structkeyexists
found in variables.variables.title
I find this strange that title can be dumped or output as variables.title but it can't be detected with isDefined or structkeyexists. Is there a more efficient way to assign
<cfset variables = arguments.searchitems>
Use the component's "this" scope.