the second line of script should be removeAllElementValues(files, exclude);
but I get it, you test the script several times.
This is such a peculiar bug. I have run your flow more than 80 times in several occassions, for probably more than 1 hour. Here are my finding :
1. Init Variable Files List to {files}, changing name of this variable, doesn't make different
2 .the newfiles still inherit the same problem
3. then try to remove from the glovar, same problem.
Code: Select all
for(i in files) addElement(newfiles)
4.the newfiles still inherit same problem.
5. Amazingly, create a newList()
Code: Select all
create = newList(
"/storage/emulated/0/Alarms",
"/storage/emulated/0/Android",
"/storage/emulated/0/Automagic",
"/storage/emulated/0/bluetooth",
"/storage/emulated/0/CallRecordings");
exclude=newList("/storage/emulated/0/Android");
removeAllElementValues(create, exclude);
//or
//removeElementValue(create, exclude[0]);
This will remove the /storage/emulated/0/Android. So the function works. Testing with other created list from script also work. But it won't work for the list created by the init variables files list and all its derivation.
6. Suprisingly, if we save the list element from the {files} itself, it works
Code: Select all
global_file = newList(files[1]); //save "/storage/emulated/0/Android"
in the next execution, if we call
Code: Select all
removeAllElementValues(files, global_file);
it works. So the {files} can only be removed value by using its own derivation, not by the list created by other script.
7. Use debug dialog, copy out the /storage/emulated/0/Android and paste it in script, still doesn't get removed. Only assigned directly just like point 6 will work
8. use debug dialog, show the {files} as JSON. Copy out all lines and put it as newList(). The new list match true to files, mean they are the same. But new list can be removed properly, while files can't.
9. Use encodeURL() on /storage/emulated/0/Android, get /storage/emulated/0/Android, result is %2Fstorage%2Femulated%2F0%2FAndroid. The same as the value assigned using script.
10. It shows {a} is true, so actually it match. But why if they are the same already, we can't use removeElementValue() or removeAllElementValues()
11. iteration removal using index, removeElement() works
12. Use Execute command :
ls -ad /storage/emulated/0/*
Then at script, parse the result into {files}
Code: Select all
files = removeElementValue(findAll(stdout, ".*"), '');
using the {files} from this parsing works fine. I can say that the list created by using script works fine.
13. Using Init Variable File List, and check Include file attributes. This will result in the {files} become nested list. If we remove from the nested list or the derived list from it, it works.
Code: Select all
filelist = newList()
for(i in files)
addElement(filelist, i[0]);
or if we just remove directly from the files[1] (which is a list), also work.
So the culprit seems like action Init variable File List created a {files} list variable which has something that has extra attribute/char which is same and different at the same time. Same means the evaluation == will be true, but different because we can't use removeElementValue() or removeAllElementValues() on it.
This is even more mysterius than my invisible character at the BOM text file troubleshooting.