Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

comparing two lists 1

Status
Not open for further replies.

doyle9732

Programmer
Apr 12, 2002
185
CA
I have spent all afternoon trying to get this to work and it just isn't coming. I've search the forum here and can't find the answer.....so I apologize if this is something simple - I just can't figure it out. :-(


This is for a conference booking application where admins are booking multiple bookings at the same time. So I start with one list that is all the dates they want to book and a second list that is all the dates that conflict with existing bookings.

I can't seem to manage to loop through the first (all dates) list with the second (existing bookings) list to create a new list of good dates that can be booked and put into the database.

This is my code, but it produces the whole list (all dates),

<cfloop index="AllDates" list="#NewAllDates#">
<cfloop index="badDate" list="#ErrorDates#">
<cfif AllDates is Not badDate>
<cfset NewAllDates2 = ListAppend(NewAllDates2, #AllDates#)>
<cfbreak>
</cfif>
</cfloop>
</cfloop>

yet if I reverse the logic to:

<cfloop index="AllDates" list="#NewAllDates#">
<cfloop index="badDate" list="#ErrorDates#">
<cfif AllDates is badDate>
<cfset NewAllDates2 = ListAppend(NewAllDates2, #AllDates#)>
<cfbreak>
</cfif>
</cfloop>
</cfloop>

I get just the errordate list???!

any guidance would be appreciated.....because I'm not just spinning in circles.

Stephanie
 
Here you go..

Code:
<cfset GreatDates="">
<cfloop index="AllDates" list="#NewAllDates#">
  <cfif listfind(ErrorDates,AllDates)>
    <cfset GreatDates=listappend(GreatDates,AllDates)>
  </cfif>
</cfloop>

Good Dates are <cfoutput>#GreatDates#</cfoutput>.

This should work.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
thanks for responding......your code gives me just the errordates......I need the good dates.

Stephanie
 
Code:
<cfset GreatDates="">
<cfloop index="AllDates" list="#NewAllDates#">
  <cfif [b]not[/b] listfind(ErrorDates,AllDates)>
    <cfset GreatDates=listappend(GreatDates,AllDates)>
  </cfif>
</cfloop>

Good Dates are <cfoutput>#GreatDates#</cfoutput>.

sorry

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
:)

I took a guess and added 'NOT' infront of listFind and happily it gave me the good dates!

Oh, I can see you also responded......so thanks again!

you're a star!

Stephanie
 
lol that would have been 3 of use dual posting. i was going to suggest the same but knew webmigit had it. he's the cflist king :)

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top