Solved

How to compare two variables in different scope dynamically?

Posted on 2000-04-18
7
181 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
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…
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now