|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Variables
Greetings, just need some help to understand how CF works in regards to variables.N kips 05/16/12 09:27 A If it's a local variable in a function, you'll scope it as local.varnameScott Stewart 05/16/12 09:36 A If the var is used only within a single program a regular local var is fine. If the var needs to persist and be recalled from another program later (i.e., a program where the var is not passed as a URL or form value), then use the session.var.Robert Harrison 05/16/12 10:20 A The larger question here is developing an understanding of the scopesCameron Childress 05/16/12 10:30 A Also, be careful using "var" as a variable name. It is a reservedCarl Von Stetten 05/16/12 11:03 A Greetings, just need some help to understand how CF works in regards to variables. Can CF might mix-up the variables, unless the variables are in the session? Is this sufficient? <cfset var = GetAuthUser()> or should I say <cfset session.var = GetAuthUser()> It is just a variable that is used to hold data which will be processed, but the data is different from user to user. Do not want to process one user's data in place of another. Appreciate it. If it's a local variable in a function, you'll scope it as local.varname If it's a local variable in a CFM page, you'll scope it as variables.varname if it's in the request scope, then it's request.varname if it's in the session, then it's session.varname application, application.varname form, form.varname ad nauseum.. On 5/16/2012 9:26 AM, N kips wrote: ----- Excess quoted text cut - see Original Post for more ----- If the var is used only within a single program a regular local var is fine. If the var needs to persist and be recalled from another program later (i.e., a program where the var is not passed as a URL or form value), then use the session.var. Robert Harrison Director of Interactive Services Austin & Williams Advertising I Branding I Digital I Direct 125 Kennedy Drive, Suite 100 I Hauppauge, NY 11788 T 631.231.6600 X 119 F 631.434.7022 http://www.austin-williams.com Blog: http://www.austin-williams.com/blog Twitter: http://www.twitter.com/austi The larger question here is developing an understanding of the scopes available in ColdFusion and why you would or wouldn't use them. This is a very fundamental thing that's quite important to understand in order to develop quality ColdFusion applications. Before continuing I'd recommend reading the following: Adobe ColdFusion 9 * Scope types http://adobe.ly/KfuPoP Adobe ColdFusion 9 * Using scopes http://adobe.ly/KfuYsi Adobe ColdFusion 9 * CFC variables and scope http://adobe.ly/Kfv5E5 Hope that helps... -Cameron ----- Excess quoted text cut - see Original Post for more ----- -- Cameron Childress -- p: 678.637.5072 im: cameroncf facebook <http://www.facebook.com/cameroncf> | twitter<http://twitter.com/cameronc> | google+ <https://profiles.google.com/u/0/117829379451708140985> Also, be careful using "var" as a variable name. It is a reserved keyword in ColdFusion. As Scott mentioned, you can make a variable local to a function by calling it local.varname. You can also make it local to a function by using the "var" keyword when you create the variable: <cfset var foo = "bar"> HTH, Carl
|
May 25, 2013
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||