> >
> > > Yep, to localize a variable, just use the var scope:
> >
> > Okay, I'm confused even more now... I thought that UDF's in
> CF5 were
> > done inside of CFScript and in MX are done using CFFunction
> - that's
> > how I've been doing it.
>
> MX can do both - the only reason to do one in CFFunction is
> if you're using CF tags rather than just script
Not true. Writing a UDF in CFFUNCTION also allows you to add validation
using returnType. It makes validating arguments a heck of a lot easier. It
also makes using optional args easier as well.
>
> > Here's the UDF that was causing the problem -
> >
> > <cffunction name="SetDefaultValues" returntype="query"
> access="private"
> > output="false">
> > <cfargument name="UseDate" required="yes">
> > <cfset DateStart = CreateDate(Year(UseDate),
> Month(UseDate), 1)>
> > <cfset NumDays = DaysInMonth(DateStart)>
> > <cfset qDefaultPlan =
> > QueryNew("id,dEntry,Hours,Downtime,Rate")>
>
> Use a CFSCRIPT block at the top and Var the variables to make
> them local, otherwise you're using the Variables. scope versions
>
You don't need to do that. You can also do this:
<cffunction name="SetDefaultValues" returntype="query" access="private"
output="false">
<cfargument name="UseDate" required="yes">
<cfset var DateStart = CreateDate(Year(UseDate), Month(UseDate), 1)>
<cfset var NumDays = DaysInMonth(DateStart)>
<cfset var qDefaultPlan = QueryNew("id,dEntry,Hours,Downtime,Rate")>
Note the use of "var" in the cfset statement.
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

