fizzled
07-01-2004, 04:50 PM
I have a function:
<cffunction name="MyFunction" output="false" returnType="boolean">
<cfargument name="thisArg" type="string" default="">
<cfquery name="qryWhatever" datasource="dsnWhatever">
SELECT Field1, Field2
FROM ThisTable
WHERE Field3 = '#thisArg#';
</cfquery>
<cfset srcEmail = 'nameATdomain.com'>
<cfset destEmail = 'nameATdomain.com'>
<cfinclude template="MyInclude.cfm">
<cfreturn true>
</cffunction>
Within MyInclude.cfm:
<cfmail from="#srcEmail#" to="#destEmail#" subject="whatever">
Hello #thisArg#
</cfmail>
The values of srcEmail and destEmail seem to work correctly, but I get an error saying thisArg is undefined when I first use it in the include file. However I can see from my debugging info that the value of thisArg existed within the UDF that called the include. Is this a scope issue? I just noticed I hadn't explicitly (with the var keyword) limited srcEmail and destEmail to the local scope in the UDF. But since the include is within the UDF, should it not have access to any value within the UDF's scope as well?
<cffunction name="MyFunction" output="false" returnType="boolean">
<cfargument name="thisArg" type="string" default="">
<cfquery name="qryWhatever" datasource="dsnWhatever">
SELECT Field1, Field2
FROM ThisTable
WHERE Field3 = '#thisArg#';
</cfquery>
<cfset srcEmail = 'nameATdomain.com'>
<cfset destEmail = 'nameATdomain.com'>
<cfinclude template="MyInclude.cfm">
<cfreturn true>
</cffunction>
Within MyInclude.cfm:
<cfmail from="#srcEmail#" to="#destEmail#" subject="whatever">
Hello #thisArg#
</cfmail>
The values of srcEmail and destEmail seem to work correctly, but I get an error saying thisArg is undefined when I first use it in the include file. However I can see from my debugging info that the value of thisArg existed within the UDF that called the include. Is this a scope issue? I just noticed I hadn't explicitly (with the var keyword) limited srcEmail and destEmail to the local scope in the UDF. But since the include is within the UDF, should it not have access to any value within the UDF's scope as well?



