|
Post by Rod on Apr 21, 2021 8:23:37 GMT
Yes I am pretty sure thats what is wrong. The assignment is reversed it should be
i=no1 j=no2
Your sort routine is fine as they are all in order. My code still needs the array to be one larger than required. If I get time I will puzzle that one out but it should all work now.
dim f1$(21) dim f2$(21)
f1$(1)="'Four Candles'-qu9MptWyCB8.mp4" f1$(2)="'Love Hurts' The Everly Brothers--5iJMfwwheY.mp3" f1$(3)="'One Day More' of President Trump - Les Mis‚rables parody-E4aTjeCP0Lo.mp4" f1$(4)="'Til I Kissed You _ Cathy's Clown ~~ Everly Brothers, Melbourne, 1989-yEp2dz5xvos.mp3" f1$(5)="'When You're Gay' Song - The Armstrong and Miller Show - Series 2 Episode 6 Preview - BBC One-FK6BQA7dUDs.mp4" f1$(6)="'You're My World' Cilla Black-e7-QBw862zk.mp3" f1$(7)="--qnRSfcjQf.js.download" f1$(8)="-COYwasVyyY.css" f1$(9)="-CQcNBE1DAY.js.download" f1$(10)="-hHOl1hwfuy.js.download" f1$(11)="-ln06vWFVTB.css" f1$(12)="-vI804b5LoF.css" f1$(13)="-x490iycc78.css" f1$(14)="!stDividedSound.wav" f1$(15)="#ENSINANDO A USAR O MACRO RECORD PRO 2 NO MUAWAY-jl0A_uT2sfM.mp4" f1$(16)="%filename%.accurip" f1$(17)="%filename%.accurip" f1$(18)="%filename%.accurip" f1$(19)="(F) Local Disk.lnk" f1$(20)="(The late) Phil Everly ~ sings ~ Let it Be Me ~-QAz2gLhdC80.mp3"
f2$(1)="'Four Candles'-qu9MptWyCB8.mp4" f2$(2)="'Love Hurts' The Everly Brothers--5iJMfwwheY.mp3" f2$(3)="'One Day More' of President Trump - Les Mis‚rables parody-E4aTjeCP0Lo.mp4" f2$(4)="'Til I Kissed You _ Cathy's Clown ~~ Everly Brothers, Melbourne, 1989-yEp2dz5xvos.mp3" f2$(5)="'When You're Gay' Song - The Armstrong and Miller Show - Series 2 Episode 6 Preview - BBC One-FK6BQA7dUDs.mp4" f2$(6)="'You're My World' Cilla Black-e7-QBw862zk.mp3" f2$(7)="--qnRSfcjQf.js.download" f2$(8)="-COYwasVyyY.css" f2$(9)="-CQcNBE1DAY.js.download" f2$(10)="-hHOl1hwfuy.js.download" f2$(11)="-ln06vWFVTB.css" f2$(12)="-vI804b5LoF.css" f2$(13)="-x490iycc78.css" f2$(14)="!stDividedSound.wav" f2$(15)="#ENSINANDO A USAR O MACRO RECORD PRO 2 NO MUAWAY-jl0A_uT2sfM.mp4" f2$(16)="%filename%.accurip" f2$(17)="%filename%.accurip" f2$(18)="%filename%.accurip" f2$(19)="(F) Local Disk.lnk" f2$(20)="(The late) Phil Everly ~ sings ~ Let it Be Me ~-QAz2gLhdC80.mp3"
'no1=i 'no2=j i=20 j=20
t=time$("ms")
unq=0 i1=1 i2=1 while i1<i or i2<j while f1$(i1)<f2$(i2) and i1<=i print "Upper loop,Unique to 1 ";f1$(i1):unq=unq+1 i1=i1+1 wend while f1$(i1)=f2$(i2) and i1<=i and i2<=j i1=i1+1 i2=i2+1 wend
while f1$(i1)>f2$(i2) and i2<=j print "Lower loop,Unique to 2 ";f2$(i2):unq=unq+1 i2=i2+1 wend wend while i1<=i print "Tail 1 loop Unique to 1 ";f1$(i1):unq=unq+1 i1=i1+1 wend while i2<=j print "Tail 2 loop Unique to 2 ";f2$(i2):unq=unq+1 i2=i2+1 wend print "reported ";unq;" unique filenames" end
|
|
|
Post by tsh73 on Apr 21, 2021 9:37:45 GMT
Not this one? general solution for compound while condition (while index not exceeds bound and some contition on array(index)) convert while info1$(i1,0)=info2$(i2,0) and i1<=no1 and i2<=no2 i1=i1+1 i2=i2+1 wend to while i1<=no1 and i2<=no2 if not(info1$(i1,0)=info2$(i2,0)) then exit while i1=i1+1 i2=i2+1 wend
, having "index not exceeds bound " WHILE condition and moving other part of condition inside IF NOT(condition) WHEN EXIT WHILE.
|
|
|
Post by Rod on Apr 21, 2021 10:16:58 GMT
Thanks Anatoly, too much going on for me to notice you had a solution but It gives me an endless loop applied to the above code. Need some thinking time. Plus one on the array seems like a very easy fix!
|
|
|
Post by Rod on Apr 21, 2021 17:11:25 GMT
I am hopping this is the final format, No need for an extra element in the array this stops at the correct boundary.
dim f1$(20) dim f2$(20)
f1$(1)="'Four Candles'-qu9MptWyCB8.mp4" f1$(2)="'Love Hurts' The Everly Brothers--5iJMfwwheY.mp3" f1$(3)="'One Day More' of President Trump - Les Mis‚rables parody-E4aTjeCP0Lo.mp4" f1$(4)="'Til I Kissed You _ Cathy's Clown ~~ Everly Brothers, Melbourne, 1989-yEp2dz5xvos.mp3" f1$(5)="'When You're Gay' Song - The Armstrong and Miller Show - Series 2 Episode 6 Preview - BBC One-FK6BQA7dUDs.mp4" f1$(6)="'You're My World' Cilla Black-e7-QBw862zk.mp3" f1$(7)="--qnRSfcjQf.js.download" f1$(8)="-COYwasVyyY.css" f1$(9)="-CQcNBE1DAY.js.download" f1$(10)="-hHOl1hwfuy.js.download" f1$(11)="-ln06vWFVTB.css" f1$(12)="-vI804b5LoF.css" f1$(13)="-x490iycc78.css" f1$(14)="!stDividedSound.wav" f1$(15)="#ENSINANDO A USAR O MACRO RECORD PRO 2 NO MUAWAY-jl0A_uT2sfM.mp4" f1$(16)="%filename%.accurip" f1$(17)="%filename%.accurip" f1$(18)="%filename%.accurip" f1$(19)="(F) Local Disk.lnk" f1$(20)="(The late) Phil Everly ~ sings ~ Let it Be Me ~-QAz2gLhdC80.mp3"
f2$(1)="'Four Candles'-qu9MptWyCB8.mp4" f2$(2)="'Love Hurts' The Everly Brothers--5iJMfwwheY.mp3" f2$(3)="'One Day More' of President Trump - Les Mis‚rables parody-E4aTjeCP0Lo.mp4" f2$(4)="'Til I Kissed You _ Cathy's Clown ~~ Everly Brothers, Melbourne, 1989-yEp2dz5xvos.mp3" f2$(5)="'When You're Gay' Song - The Armstrong and Miller Show - Series 2 Episode 6 Preview - BBC One-FK6BQA7dUDs.mp4" f2$(6)="'You're My World' Cilla Black-e7-QBw862zk.mp3" f2$(7)="--qnRSfcjQf.js.download" f2$(8)="-COYwasVyyY.css" f2$(9)="-CQcNBE1DAY.js.download" f2$(10)="-hHOl1hwfuy.js.download" f2$(11)="-ln06vWFVTB.css" f2$(12)="-vI804b5LoF.css" f2$(13)="-x490iycc78.css" f2$(14)="!stDividedSound.wav" f2$(15)="#ENSINANDO A USAR O MACRO RECORD PRO 2 NO MUAWAY-jl0A_uT2sfM.mp4" f2$(16)="%filename%.accurip" f2$(17)="%filename%.accurip" f2$(18)="%filename%.accurip" f2$(19)="(F) Local Disk.lnk0" f2$(20)="(The late) Phil Everly ~ sings ~ Let it Be Me ~-QAz2gLhdC80.mp30"
max1=20 'number of records in array 1 max2=20 'number of records in array 2 i1=1 'record index for file 1 i2=1 'record index for file 2 'run through the ordered list while i1<max1 and i2<max2 'while we are ahead, list exceptions in f1$() while f1$(i1)<f2$(i2) and i1<max1 print "Unique to 1 ";f1$(i1) i1=i1+1 wend 'if we are now matched, skip down both lists while f1$(i1)=f2$(i2) and i1<max1 and i2<max2 i1=i1+1 i2=i2+1 wend 'if we fall behind, list exceptions in f2$() while f1$(i1)>f2$(i2) and i2<max2 print "Unique to 2 ";f2$(i2) i2=i2+1 wend 'if we are not done loop round and find 'the next exception or match and keep going wend 'compare the last pair if f1$(i1)<> f2$(i2) then print "Unique to 1 ";f1$(i1) if f1$(i1)<>f2$(i2) then print "Unique to 2 ";f2$(i2) end
|
|
|
Post by toughdiamond on Apr 21, 2021 17:45:54 GMT
Looking good. I'll see if I can bolt it onto my program.
|
|
|
Post by tsh73 on Apr 21, 2021 19:05:02 GMT
I'm afraid checking "last pair" is not enough if number of files in arrays could be different - could it?
Here I left only 17 from first array (max1=17) and set
f2$(17)="(F) Local Disk.lnk0" f2$(18)="(F) Local Disk.lnk1" f2$(19)="(F) Local Disk.lnk2"
Now it prints
Unique to 1 %filename%.accurip Unique to 2 (F) Local Disk.lnk0
- it miss f2$(18), f2$(19), f2$(20)!
|
|
|
Post by toughdiamond on Apr 21, 2021 20:22:16 GMT
I'm afraid checking "last pair" is not enough if number of files in arrays could be different - could it? In my case, yes, one volume would very often contain more files than the other. The current lists I'm using as a test contain 16057 and 16056 filenames. An important use I have for the program is to detect mistakes in the maintenance of what should be 2 large, identical archive volumes. A major source of those mistakes is when the copying from master to backup has dropped some files. Just tested Rod's latest code, and got what looks like exactly the same result as before, i.e. 427 uniques (the real number should be a lot less). The assignment is reversed it should be i=no1 j=no2 Do you mean I need to change that round in my program?
|
|
|
Post by toughdiamond on Apr 21, 2021 20:35:21 GMT
Just got a perfect result when my 2 lists were identical, and again perfect when I altered just one filename in one list. But I got 223 uniques when I deleted one filename, so it does look as if the problem is associated with different numbers of files in the 2 lists.
|
|
|
Post by toughdiamond on Apr 22, 2021 3:47:30 GMT
I did some more tests, and I no longer think the difference in the lengths of the lists is the sole problem (and might not be a problem at all).
For each of the following tests, I altered the leftmost character of just one filename in one list by one ASCII code. The 2 lists contained the exact same number of filenames - 16057 in each.
Altering a filename that would otherwise have been very near the start of the sorted list: the program reported both that and its unaltered counterpart as unique, which was the correct result. No false positives.
Altering a filename about a quarter of the way down the sorted list: 8 uniques were reported - 2 were correct, and the other 6 represented 3 false positives.
Altering a filename that's in the middle of the sorted list: about 230 false positives.
Altering a filename 3/4 of the way down the list: 184 false positives. I was half expecting there to be more.
Altering a filename that would have been the last entry: no false positives, and the program reported the altered one as unique, but it didn't report the unaltered version from the other list - first example of under-reporting I've seen.
So, altered filenames generally caused as much trouble as omissions, particularly if the first part of the name is altered. I guess the thing about altering the right-hand end of a filename is that it's not that likely to change its position in the sorted list, while altering the left-hand end is.
I don't know what it all means, but maybe those observations will help.
|
|
|
Post by Rod on Apr 22, 2021 6:57:28 GMT
You can’t change the left most character. That changes the entire order of the list and so corrupts the search. You have to alter the rightmost character for testing. In a real world example you would need to resort the lists if any changes are made.I would go back to my version that used an additional array element. That was working pretty well.
|
|
|
Post by toughdiamond on Apr 22, 2021 8:08:56 GMT
I agree it would have messed up the alpha order if I'd edited the ordered list like that, but what I did was to alter the directory dump. The sorting was always done afterwards, so everything was in alphabetical order before your code was executed. OK I'll re-run some of the tests tomorrow, using your code from here, as you suggest: justbasiccom.proboards.com/post/4666/threadHopefully that'll be better. I won't forget to make sure the extra element is there.
|
|
|
Post by toughdiamond on Apr 22, 2021 21:55:06 GMT
OK, I've run the exact same tests on that version. Sad to say, the results were identical, apart from the test where I altered the filename that would become the last entry in the sorted list - this time the code found both of the uniques rather than just one like it did before, so that at least is better.
|
|
|
Post by Rod on Apr 23, 2021 7:22:24 GMT
Can you post code that shows the problem. Your matching routine and enough of the sorted lists to show the problem happening.? Can the problem be seen with the short lists we used earlier?
|
|
|
Post by toughdiamond on Apr 23, 2021 17:23:06 GMT
So far I've not found any false positives when I've run various selections of 20 filenames from my 1600-plus directory dump (altering the first character of one filename as before). I'll try something larger than 20 but smaller than 1600 - if I keep trying different cuts I should be able to isolate the problem in a relatively small list of filenames, and post that.
Here's the code I'm using, beginning with the transfer of the data into your arrays. If you want the previous code that loads the directory dumps and parses out the filenames, I can post that.
' putting the data into Rod's arrays
dim f1$(i+1) for k=1 to i f1$(k)=v$(k,2) next k dim f2$(j+1) for k=1 to j f2$(k)=w$(k,2) next k max1=i max2=j
print "i=";i print "max1=";max1 print "j=";j print "max2=";max2
'sort v$(),1,i,2 ' sort w$(),1,j,2 sort f1$(),1,max1 sort f2$(),1,max2 sort v$(),1,i,2 sort w$(),1,j,2
[RunRodsCode]
t=time$("ms")
unq=0 i1=1 i2=1 while i1<i or i2<j while f1$(i1)<f2$(i2) and i1<=i print "Upper loop,Unique to 1 ";f1$(i1):unq=unq+1 i1=i1+1 wend while f1$(i1)=f2$(i2) and i1<=i and i2<=j i1=i1+1 i2=i2+1 wend
while f1$(i1)>f2$(i2) and i2<=j print "Lower loop,Unique to 2 ";f2$(i2):unq=unq+1 i2=i2+1 wend wend while i1<=i print "Tail 1 loop Unique to 1 ";f1$(i1):unq=unq+1 i1=i1+1 wend while i2<=j print "Tail 2 loop Unique to 2 ";f2$(i2):unq=unq+1 i2=i2+1 wend print "reported ";unq;" unique filenames" end
|
|
|
Post by tsh73 on Apr 23, 2021 18:30:33 GMT
Could filenames duplicate? Probably they are So if we have in one list 3 "C" and in other 2 "C" and one "C.", what output we SUPPOSED to get? Now I got
Upper loop,Unique to 1 C Lower loop,Unique to 2 C.
code with data generated
' putting the data into Rod's arrays i = 20 j = 20 dim v$(i,2) dim w$(j,2) for k = 1 to i 'v$(k,2)=chr$(k-1+asc("A")) 'all uniquie v$(k,2)=chr$(k/3-1+asc("A")) 'doubling next
for k = 1 to i w$(k,2)=v$(k,2) next
'now change 'p=1 'ok 'p=5 'ok p=10 'ok 'p=20 'ok w$(p,2)=v$(p,2)+"." 'v$(p,2)=w$(p,2)+"."
dim f1$(i+1) for k=1 to i f1$(k)=v$(k,2) next k dim f2$(j+1) for k=1 to j f2$(k)=w$(k,2) next k max1=i max2=j
print "i=";i print "max1=";max1 print "j=";j print "max2=";max2
'sort v$(),1,i,2 ' sort w$(),1,j,2 sort f1$(),1,max1 sort f2$(),1,max2 sort v$(),1,i,2 sort w$(),1,j,2
'print after sort for k = 1 to i print k,v$(k,2), w$(k,2) next print
[RunRodsCode]
t=time$("ms")
unq=0 i1=1 i2=1 while i1<i or i2<j while f1$(i1)<f2$(i2) and i1<=i print "Upper loop,Unique to 1 ";f1$(i1):unq=unq+1 i1=i1+1 wend while f1$(i1)=f2$(i2) and i1<=i and i2<=j i1=i1+1 i2=i2+1 wend
while f1$(i1)>f2$(i2) and i2<=j print "Lower loop,Unique to 2 ";f2$(i2):unq=unq+1 i2=i2+1 wend wend while i1<=i print "Tail 1 loop Unique to 1 ";f1$(i1):unq=unq+1 i1=i1+1 wend while i2<=j print "Tail 2 loop Unique to 2 ";f2$(i2):unq=unq+1 i2=i2+1 wend print "reported ";unq;" unique filenames" end
|
|