Page 1 of 3

removeDuplicateElements

Posted: 08 Sep 2017 03:42
by simon_magus101
removeDuplicateElements() function does not give me the intended result. It does not seem to remove duplicates. It will only remove one elements if there are more than 3 of the same. Can somebody please confirm this? Here is what I did

global_x1=removeDuplicateElements(global_x1);

I have also tried
removeDuplicateElements(global_x1);

I still get duplicates in the list. No error message when executing the flow.
I am on the Automagic 1.33.0 and android 4.4

Re: removeDuplicateElements

Posted: 08 Sep 2017 04:51
by Bluscre
simon_magus101 wrote:global_x1=removeDuplicateElements(global_x1);
What's the content of your global_x1 variable?

Re: removeDuplicateElements

Posted: 08 Sep 2017 04:58
by simon_magus101
global_x1 is a list of Cell ID. Each element is a number of 7 digits length.

Re: removeDuplicateElements

Posted: 08 Sep 2017 05:10
by Desmanto
I get the proper result, all duplicate element will be removed, either 2 or 3, will become only 1. That 2 elements those didn't removed must be checked if they are the same. If global_x1 = [x, tes, tes, abc], means element 2 and 3 seems duplicate. Try
a = global_x1[1] == global_x1[2]
use debug dialog to check a.

a must be false if they are not the same. You can try to encode them to see if any "invisible whitespace" or special character. Try
e = encodeURL(global_x1[1])
f = encodeURL(global_x1[2])

Check if e and f now shows something that is not supposed to be there.

I have similiar problem with you. When I parse my flowception, I also curious why the element not removed. Turns out "\n" (newline), when stored inside list, will become empty string, but not null. That element doesn't match null or empty, but match with '' (two single quote). Confirmed it via debug dialog. Debug dialog really helps a lot. Can't imagine scripting without it.

You don't need to assign the value back when using remove series. Just the remove function is enough, no need = anymore.

Re: removeDuplicateElements

Posted: 08 Sep 2017 05:11
by Bluscre
simon_magus101 wrote:global_x1 is a list of Cell ID. Each element is a number of 7 digits length.
Add a "Debug Dialog" condition to the end, wait for it to pop up then tap on "global_x1" then tap on copy and obfuscate personal stuff then post it for us to review

Re: removeDuplicateElements

Posted: 08 Sep 2017 05:51
by simon_magus101
I have tried the encodeURL for the two elements, display on screen notification, and they are duplicate.
Let me give more details. I have twelve unique numbers and one duplicate.
//script begin
global_x2=newList(7350474, 7350475, 1608847, 1618847, 1618846, 1608846, 7350473, 1628846); //eight numbers
global_x3=newList(1124582, 7344998, 7345098, 1134582); //four numbers
global_x4=newList(1608847); //notice this number is a duplicate in global_x2[2]
global_x1=newList();
//combining all elements in global_x1
global_x1=addAllElements(global_x1, global_x2);
global_x1=addAllElements(global_x1, global_x3);
global_x1=addAllElements(global_x1, global_x4);
removeDuplicateElements(global_x1);
//script end

Now when I view global variables I can see 1608847 occur twice in global_x1.

Re: removeDuplicateElements

Posted: 08 Sep 2017 05:59
by Desmanto
I've tried your script without modification.
The result of global_x1 is
[7350474, 7350475, 1608847, 1618847, 1618846, 1608846, 7350473, 1628846, 1124582, 7344998, 7345098, 1134582]

12 elements. If I comment out the remove(), it will have 13 elements, 1608847 at the end.

I am using Automagic 1.33.0 on LP 5.1, root + Xposed.

Re: removeDuplicateElements

Posted: 08 Sep 2017 06:52
by simon_magus101
Thanks for trying out Desmanto. On my phone global_x1 end up with 13 elements. 1608847 being the last element. I can see two of 1608847.

Re: removeDuplicateElements

Posted: 08 Sep 2017 08:07
by Bluscre
simon_magus101 wrote:Thanks for trying out Desmanto. On my phone global_x1 end up with 13 elements. 1608847 being the last element. I can see two of 1608847.
Can you share your full flow so we can try to help you ? Make sure to remove personal info before uploading

Re: removeDuplicateElements

Posted: 08 Sep 2017 10:44
by simon_magus101
Bluscre wrote:
Can you share your full flow so we can try to help you ? Make sure to remove personal info before uploading
I am new to this forum. I just clicked Publish Flows at the bottom, and selected some flows. I hope you receive them. The objective is to collect Cell Id from three different areas, one area at a time, and combine them into one list, without duplicate. Cell collector stopper flow is where I combined them.
http://automagic4android.com/flow.php?i ... a5cfad9c41