>It appears to me that "scope" in CF is purely arbitrary, and in fact, is
>just a different way of representing a structure. It occured to me the
other
>day that I can create any darn scope I want.
This is not true. If you create a variable called "MyScope.MyVar" without
first declaring "MyScope" a structure with the StructNew() function, my
scope is not considered a function and, as a result, you can not run any
structure functions against it. The scope here is nothing more than a naming
convention.
>For example, I, as a habit (bad or good you decide) take any variable
that's
>gonna be saved as text into SQL, and PReserveSingleQuotes on it. I've also
>noted that you cannot directly say, in the midst of a CFQUERY, "INSERT
>'#PreserveSingleQuotes(squid)#'"' you gotta do the PSQ first.
This is not necessary. You can use the PreserveSingleQuotes() function
within the CFQUERY tag. One of our developers (of C/C++ background) was fond
of building queries outside of the CFQUERY tag. Then he would output
something like #PreserveSingleQuotes(Query)# within the CFQUERY tags.
>SoOo, what I do is, if I have a var squid, I'll say "CFSET sql.squid =
>PReserveSingleQuotes(squid)", thus, creating a new variable, which I've
>scoped as "sql." I note that you can use any darn name you like, so long as
>it isn't already a predefined CF scope.
The only disadvantage that I can think of would be the overhead incurred by
the PreserveSingleQuotes() function. Otherwise, I think this is just a
stylistic preference. Like I said, our C/C++ really preferred to script the
query rather than place the logical constructs within the CFQUERY tag
itself.
>I think that behind the scenes, any variable is being implicitly scoped
>anyway, and in fact, is being stored as a structure. Its just a theory, but
>I think its right...
Actually, it seems like it's just a variable with a dot in the name. As far
as I can tell, nothing separates MyScope.MyVar from MyScopeMyVar in terms of
functionality. In terms of readability, I prefer MyScope.MyVar. If you don't
need any of the functionality that a structure provides, this method is
probably preferable since it does incur the extra overhead.
Benjamin S. Rogers
Web Developer, c4.net
voice: (508) 240-0051
fax: (508) 240-0057
------------------------------------------------------------------------------
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/fusebox or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.