Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to compare two variables in different scope dynamically?

Posted on 2000-04-18
7
Medium Priority
?
188 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
Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

610 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