[thelist] CF form problems...

.jeff jeff at members.evolt.org
Sun Jun 2 18:31:01 CDT 2002


rudy,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: rudy
>
> awesome post, jeff
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

thanks

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> question about one of the tips
>
> > save yourself alot of hassle and the coldfusion
> > server additional processing time --
> > scope your variables.
>
> does this include local variables?  if not, why not?
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

well, previous to cfv6 (cfmx for you marketing oriented developers) the
variables scope wasn't a true structure so you couldn't interrogate it.  to
me, half the reason to even use a scope is so you have a way of reporting
all variables that exist for a given request using a collection loop, for/in
loop within a <cfscript></cfscript> block, the <cfdump> tag, or any number
of other custom ways.

til cfv6 this wasn't possible with the variables scope so i never bothered
typing "variables." every time i created a local variable (which doesn't
happen very often actually).

besides (and this brings me to another tip) coldfusion looks to the
variables scope first when trying to find what scope the local variable
belongs to so in the very few instances where i actually use unscoped, local
variables it's a minimal hit for the server to find their proper scope.

additionally, there are times when it's handy and appropriate to not scope
your variables.  take a search application, for example.  you may want to
allow this application to be driven by form variables (coming in from a form
post) or url variables.  by using unscoped variables, you can allow this to
work without any extra development, doubling of work, more difficulty in
maintenance/upgrades, etc.

<tip type="ColdFusion" author=".jeff">

if you use unscoped variables, the coldfusion server has to look in various
scopes to try to find them.  here's the scopes it looks in and what order it
searches them.

1. Local variables created using CFSET and CFQUERY
2. CGI variables
3. File variables
4. URL variables
5. Form variables
6. Cookie variables
7. Client variables

coldfusion doesn't look in every scope.  the following scopes don't get
interrogated when searching for the unscoped variable.  instead, if the
coldfusion server doesn't find the unscoped variable in the scopes above, it
will simply throw an error.

1. Application
2. Session
3. Server
4. Request
5. Caller

in order for the coldfusion server to find variables in the scopes above you
*must* scope them properly.

</tip>

enjoy,

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/





More information about the thelist mailing list