The reason it's working is that you changed your inner loop from a LIST loop
to a simple counter loop.  The problem you had, as mentioned in a previous
email which has yet to reach the list, was with the combination of the LIST
loop and the WordToGet variable, which was always extracting the same
element from the list.

Go back to a list loop and get rid of WordToGet (see my earlier posting) and
it will both work and be more elegant.  One of the problems with the
solution below is that you've hardcoded the number of elements in the list
(6), so you can't just add an item to the list, or switch the list to a
passed-in parameter.

Hope the above explains the problem with the original code,
Bob

-----Original Message-----
From: Angél Stewart [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 21, 2001 4:15 PM
To: CF-Talk
Subject: RE:Solved the problem( Need assistance:Nested CFLOOPs)


<CFSET AlreadyFound = False>
<CFSET CompanyList = "Limited,LTD,LTD.,Co.,Company,the ">
<cfloop query="judgement" startrow="1" endrow="1000">
        <cfset tempDefendant = #judgement.defendant#>
        <CFOUTPUT>Current Defendant is :#judgement.defendant#</CFOUTPUT>
        <br>
        <cfloop index="x" from="1" to="6">

                <!---<CFOUTPUT> The iteration is #x#</CFOUTPUT>--->
                <CFSET WordToGet=ListGetAt(#CompanyList#,#x#)>
                <!----<CFOUTPUT> The Current List Item Is:#WordToGet#</cfoutput>---->
                        <CFIF FindNoCase(#WordToGet#,#tempdefendant#) neq 0 AND NOT 
AlreadyFound>

                                <CFOUTPUT>  <font size="5" color="Red">Hey! We Found A
Company</font><br> </cfoutput>
                                <CFSET AlreadyFound =True>
                        </cfif>
        </CFLOOP>
<CFSET AlreadyFound = False>
</CFLOOP>


That's code is working just fine.

Now if someone can tell me WHY its working ..I'd like to know. Because I
just opened a new document and recoded it from scratch, and ..voila..it
works now.

I am using the same CFLOOP structure I was using before...except for this
tempdefendant thing, which does not have an effect on the inner loop.

*sigh*
I must be tired or something?

-Gel
Original Code:
<cfloop query="judgement" startrow="1" endrow="20">
        <CFSET CompanyList = "Limited,LTD,LTD.,CO,Co.,Company,&,The">
        <cfloop index="counter" list="#CompanyList#" delimiters=",">
                        <CFOUTPUT> The Defendant IS:#judgement.defendant#</cfoutput>
                        <br>
                        <CFSET WordToGet=ListGetAt(#CompanyList#,#counter#,",")>
                        <CFOUTPUT> The Current List Item Is:#WordToGet#</cfoutput>
                        <br>
                        <CFIF Find(judgement.defendant,#Counter#) neq 0>

                                <CFOUTPUT>  Hey! We Found A Company </cfoutput>

                        </cfif>
        </CFLOOP>
</CFLOOP>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to