IMHO...
Tip #1 (drop the unneeded #'s) is good.
Tip #2 (drop the query name within the loop) is very, very bad.

Why? Because from reading the code it isn't clear where those unscoped
values are coming from.  You might as well tell people not to explicitly
reference the url, form, attributes, arguments, or variables scopes
while you're at it, and then no one will be able to follow their own
code, let alone someone else's.

Proper scoping is perhaps the best way to make your CF code readable and
maintainable.

Thanks
        Mark

-----Original Message-----
From: Jason Fisher [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 11, 2008 8:38 AM
To: cf-talk
Subject: Re: inserting a structure...within a structure...within a
structure

A little OT, but you can save some keystrokes with proper use of the '#'
symbol.  Safer to lose the internal reference to the query inside the
loop, too:

<cfquery name="cats" datasource="#Application.DSN#"> .... snip ..
</cfquery>

<cfloop query="cats">
        <cfif NOT StructKeyExists(allcats, category)>
                <cfset allcats[category] = StructNew()>
                <cfset allcats[category].created = 0>
                <cfset allcats[category].catid = acategoryid>
        </cfif>
        <cfif NOT StructKeyExists(allcats[category], subsection)>
                <cfset allcats[category][subsection] = StructNew()>
                <cfset allcats[category][subsection].created = 0>
                <cfset allcats[category][subsection].catid = categoryid>
        </cfif>
        <cfif NOT StructKeyExists(allcats[category][subsection], manuf)>
                <cfset allcats[category][subsection][manuf] =
StructNew()>
                <cfset allcats[category][subsection][manuf].created = 0>
                <cfset allcats[category][subsection][manuf].l3catid =
l3catid>
        </cfif>
</cfloop> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:315078
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to