House of Fusion
Home of the ColdFusion Community

Search cf-talk

December 02, 2008

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
   1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31       

Search over 2,500 ColdFusion resources here  >>>      
Home /  Groups /  ColdFusion Talk (CF-Talk)

List Comparison

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Kamru Miah
07/08/2008 10:35 AM

Could some one please advise me how to compare two lists of Ids (oldList, newList) and decide which Ids have been added or deleted (in the newList compared to oldList) but ignore any item that are unchanged? Many thanks, Kamru

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Adrian Lynch
07/08/2008 10:39 AM

This might do it: http://cflib.org/index.cfm?event=page.udfbyid&udfid=149 Adrian www.adrianlynch.co.uk Could some one please advise me how to compare two lists of Ids (oldList, newList) and decide which Ids have been added or deleted (in the newList compared to oldList) but ignore any item that are unchanged? Many thanks, Kamru

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Che Vilnonis
07/08/2008 10:43 AM

Here you go... try a UDF... http://cflib.org/udf/ListCompare http://cflib.org/udf/ListInCommon Regards, Che Could some one please advise me how to compare two lists of Ids (oldList, newList) and decide which Ids have been added or deleted (in the newList compared to oldList) but ignore any item that are unchanged? Many thanks, Kamru

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tom McNeer
07/08/2008 10:47 AM

Kamru, > Could some one please advise me how to compare two lists of Ids (oldList, > newList) and decide which Ids have been added or deleted (in the newList > compared to oldList) but ignore any item that are unchanged? Take a look at the ListDiff and ListDiffDup functions on cflib.org -- Thanks, Tom Tom McNeer MediumCool http://www.mediumcool.com 1735 Johnson Road NE Atlanta, GA 30306 404.589.0560

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Kamru Miah
07/09/2008 12:06 PM

Thanks to all those to responded. The ListDiff and ListInCommon UFDs seems to have solved my problem:) Kamru > Could some one please advise me how to compare two lists of Ids > (oldList, newList) and decide which Ids have been added or deleted (in > the newList compared to oldList) but ignore any item that are > unchanged? Many thanks, Kamru

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Larry Lyons
07/09/2008 12:50 PM

> Could some one please advise me how to compare two lists of Ids > (oldList, newList) and decide which Ids have been added or deleted (in > the newList compared to oldList) but ignore any item that are > unchanged? Many thanks, Kamru You might try this approach, taken from Rupesh Kumar's blog (http://coldfused.blogspot.com/2007/01/extend-cf-native-objects-harnessing.html). BTRW he's one of the Adobe engineers in India. First convert both lists to arrays using the list to array function, then use the equals method that's a part of CFMX's java base, as in <!--- convert your lists to arrays ---> <cfset array1 = ListToArray("1,2,3,4,5,6,7,8") /> <cfset array2 = ListToArray("2,3,4,5") /> <cfset array3 = ListToArray("1,2,3,4,5,6,7,8") /> <!--- Are the arrays equal? ---> <cfoutput>    array1 equals array2 : #array1.equals(array2)#<br />    array1 equals array3 : #array1.equals(array3)#<br /> </cfoutput> Then to find out what items are different between two list you can use the removeAll method, as in: <!--- Duplicate the first array we don't mess it up ---> <cfset dupArray1 = Duplicate(array1) /> <!--- Remove any common items between the two arrays (and lists)---> <cfset dupArray1.removeAll(array2)> <!--- convert the array back to a list and report ---> Items in array1 not in array2: <cfoutput>#arrayToList(dupArray1)# hth, larry


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists