|
There is a trick mentionned by someone of the list a while
ago:
Define <cfset var local = structNew()> at the top of your method.
Wherever you need a var scoped variable (does not need to be at the
top), you can then use <cfset local.x = 0>.
Jean From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hamoud, Ryan N. Sent: Friday, March 10, 2006 9:28 AM To: [email protected] Subject: RE: [CFCDev] cfc scope issues So var
scoping has to be done at the top of methods right?
So how
do var scope for a situation when you don't actually cfset the variable till the
end of your method.
The only reason I came across this is when I was
validating all my arguments at the top and then near the bottom I finally set my
variable that I wanted to retune.
Here is a example of what I am referring
to.
<CFFUNCTION NAME="tableSearch" access="remote"
returntype="string">
<CFARGUMENT NAME="searchFor" type="string" required="yes"> <CFARGUMENT NAME="tableName" type="string" required="yes"> <CFARGUMENT NAME="fieldToSearch" type="string" required="yes"> <CFARGUMENT NAME="returnField" type="string" required="yes"> <CFARGUMENT NAME="searchFieldType" type="string" required="yes"> <cfset var getValues = "" /> <cfif not IsDefined("ARGUMENTS.searchFor")> <cfabort showerror="The searchFor attribute is not defined, cannot process this tag."> </cfif> <cfif not IsDefined("ARGUMENTS.tableName")> <cfabort showerror="The tableName attribute is not defined, cannot process this tag."> </cfif> <cfif not IsDefined("ARGUMENTS.fieldToSearch")> <cfabort showerror="The fieldToSearch attribute is not defined, cannot process this tag."> </cfif> <cfif not IsDefined("ARGUMENTS.returnField")> <cfabort showerror="The returnField attribute is not defined, cannot process this tag."> </cfif> <cfif not IsDefined("ARGUMENTS.searchFieldType")> <cfabort showerror="The searchFieldType attribute is not defined, cannot process this tag. Please supply either text or integer"> </cfif> <cfif ARGUMENTS.searchFieldType is "text"> <cfset ARGUMENTS.searchFor = "#listChangeDelims(ARGUMENTS.searchFor,"','")#"> </cfif> <cfquery name="getValues" datasource="#request.app.DSN#" blockfactor="5" cachedwithin="#request.app.queryCache30#"> blah blah blah b;ah </cfquery>
<cfif getValues.recordCount> <cfset out = ValueList(getValues.myfield,', ')> <cfelse> <cfset out = ""> </cfif> <CFRETURN out /> </CFFUNCTION> ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). An archive of the CFCDev list is available at www.mail-archive.com/[email protected] ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). An archive of the CFCDev list is available at www.mail-archive.com/[email protected] |
- RE: [CFCDev] cfc scope issues Hamoud, Ryan N.
- Re: [CFCDev] cfc scope issues Daniel Roberts
- Re: [CFCDev] cfc scope issues Matt Woodward
- Re: [CFCDev] cfc scope issues Nando
- RE: [CFCDev] cfc scope issues Phillip Senn
- Re: [CFCDev] cfc scope issues Patrick Lebon
- RE: [CFCDev] cfc scope issues Hamoud, Ryan N.
- RE: [CFCDev] cfc scope issues Hamoud, Ryan N.
- RE: [CFCDev] cfc scope issues Hamoud, Ryan N.
- RE: [CFCDev] cfc scope issues Jean Moniatte
- Re: [CFCDev] cfc scope issues Peter J. Farrell
- RE: [CFCDev] cfc scope issues Phillip Senn
- Re: [CFCDev] cfc scope issues Matt Woodward
- [CFCDev] cfc scope issues Nando
