Question
declaring a variable in CF
I thought when a variable is needed, CF developer can just
set it on the fly, <cfset var MyVar="assign a value here">
I'm writing a simple UDFs, and did not declare a variable. The error I got was Variable is undefined. Should I declared the variable when it is used within a function?
<cffunction name="InUser">
<cfargument name="EmpID" required="true" type="numeric">
<cfargument name="DeptArray" required="true" type="array">
<cfset NewUserID = 0> ----????????? If Omitted this, I got error saying NewUserID is Undefined.
.
.
.
<CFSET NewUserID = GetNewUser(UserName)>
.
.
Then I use the value of NewUserID for something else down here.
.
.
</cffunction>
<cffunction name="GetNewUser">
select statement to get userID based on userName
<CFRETURN #GetID.UserID#>
</cffunction>
I'm writing a simple UDFs, and did not declare a variable. The error I got was Variable is undefined. Should I declared the variable when it is used within a function?
<cffunction name="InUser">
<cfargument name="EmpID" required="true" type="numeric">
<cfargument name="DeptArray" required="true" type="array">
<cfset NewUserID = 0> ----????????? If Omitted this, I got error saying NewUserID is Undefined.
.
.
.
<CFSET NewUserID = GetNewUser(UserName)>
.
.
Then I use the value of NewUserID for something else down here.
.
.
</cffunction>
<cffunction name="GetNewUser">
select statement to get userID based on userName
<CFRETURN #GetID.UserID#>
</cffunction>