Answered
Variables inside functions...
I understand the following... the this scope is accessible
outside of the component as well as inside the component. the
variables scope is accessible to all functions within the
component.
You can also use: <cfset var myvar = 1 /> to set a variable that is only availaible in the current instance of a function. When the function completes, the variable is lost. I am assuming that a non-scoped variable is in this "var" scope and therefore non-persistent. Is this true?
Main reason I am asking is that you cannot use the "var" style of naming a variable when using queries and such in a function.
So if I do the following:
<cfquery datasource="dsn" name="testQuery">
...
</cfquery>
The resulting variable of testQuery is only available to the function that ran it correct? It would not be available to any other functions in the component without putting it in the variables scope, correct?
I am pretty sure I am understanding this correctly, just want to make sure. Thanks! Sorry if it sounds like a dumb question...lol
You can also use: <cfset var myvar = 1 /> to set a variable that is only availaible in the current instance of a function. When the function completes, the variable is lost. I am assuming that a non-scoped variable is in this "var" scope and therefore non-persistent. Is this true?
Main reason I am asking is that you cannot use the "var" style of naming a variable when using queries and such in a function.
So if I do the following:
<cfquery datasource="dsn" name="testQuery">
...
</cfquery>
The resulting variable of testQuery is only available to the function that ran it correct? It would not be available to any other functions in the component without putting it in the variables scope, correct?
I am pretty sure I am understanding this correctly, just want to make sure. Thanks! Sorry if it sounds like a dumb question...lol
