?
Solved

How to compare two variables in different scope dynamically?

Posted on 2000-04-18
7
Medium Priority
?
187 Views
Last Modified: 2013-12-24
I want to compare two query variables like this:

Query1 has a name fild with values a, b, c, d.
Query2 is a subset of Quer1. It also has a name fild with values a, or b, or c, or d, or any combination of them.

I tried the following code:

<CFLOOP NAME="Query1">
      <CFLOOP NAME="Query2">
           <CFIF Compare(Query1.name, Query1.name) is 0>
                <br>A match found!!!<br>                
           </CFIF>    
      </CFLOOP>
</CFLOOP>

My problem is that Query1.name in the comparation statement is still a, it never changed to b, c, d. I tried to use Evaluate function, but it helpless.

Could You help me?

Thanks.

Jun
0
Comment
Question by:liuj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 2

Expert Comment

by:dlewis9
ID: 2728208
Try not using the query identifier in front of the variable..when you do, that only gives you the first record of the query..

<CFLOOP QUERY="Query1">
  <CFSET somevar = name>
      <CFLOOP QUERY="Query2">
           <CFIF Compare(somevar, name) is 0>
                <br>A match found!!!<br>                  
           </CFIF>      
      </CFLOOP>
</CFLOOP>

0
 

Author Comment

by:liuj
ID: 2728402
Thanks for your help.
I tried the similare way, and print out  somevar in outer loop and in inner loop, like this:

<CFLOOP QUERY="Query1">
        <CFSET somevar = name>
             <br>1. #somevar# <br>
        <CFLOOP QUERY="Query2">
            <br>2. #somevar# <br>
             <CFIF Compare(somevar, name) is 0>
                      <br>A match found!!!<br>                              </CFIF>      
         </CFLOOP>
 </CFLOOP>

1. is correct, but 2. remains the same.
0
 
LVL 2

Expert Comment

by:dlewis9
ID: 2728656
2 would remain the same inside that second loop..your code should print:

1.a
2.a
a match is found!
2.a
2.a
2.a
1.b
2.b
2.b
a match is found!
2.b
2.b

etc..what output are you trying to get?

i'll test it on a server when i get a chance..
0
How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

 

Author Comment

by:liuj
ID: 2728725
Thanks  lot!

I retest it and get the right answer. Last time I got a incorrect result may be because some thing wrong with my account. Each time I need to ftp my programm into there.

Thanks again.
0
 
LVL 5

Expert Comment

by:nathans
ID: 2728855
If it works GRADE him.... Give him a 'A'

Nathan Stanford
Mr. ColdFusion
www.nsnd.com
ColdFusion Tips Plus
0
 

Author Comment

by:liuj
ID: 2729160
HOw can I grade the answer? I want grade A, but how?
0
 
LVL 2

Accepted Solution

by:
dlewis9 earned 400 total points
ID: 2729231
There should be a button on the comment that says "Accept comment as answer" and then you grade it after that..

Glad it worked for ya..i hate it when a web server doesn't use the page I just uploaded...darn caching..
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month14 days, 18 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question