Solved

How to compare two variables in different scope dynamically?

Posted on 2000-04-18
7
183 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
  • 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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 100 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Apache SSL and mod_rewrite not working 8 162
.htaccess rewrite url with querystring problem 13 96
AWS New EC2 Instance and EBS Storage 2 79
System Analysis 5 58
A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

821 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