No it is not possible to remove an index. You can either clear the whole array (set every item to its "empty" value) or remove the array variable itselfHello All,
Does anyone knows if its possible to remove an index in an array or dictionay ?
can you show me sample how to do it ?
best regards,
View attachment 2778
true, but it's a very valid feature requestNo it is not possible to remove an index. You can either clear the whole array (set every item to its "empty" value) or remove the array variable itself
Does anyone knows if its possible to remove an index in an array or dictionay ?
can you show me sample how to do it ?
Why don't you leave it with an empty value or any conventional value?Thanx
But I want to remove the Array index
so there will be no Array[1] index.
Any ideas ?
"Clear Variables" does thatThanx
But I want to remove the Array index
so there will be no Array[1] index.
Any ideas ?
You are partially right because Clear variable clears the whole array (removes all the items) but doesn't allow to remove them selectively."Clear Variables" does that
If I have some free time, I'll write such an Action block and share it here on the forum and MD Templates.
Here you have it...Thanx
But I want to remove the Array index
so there will be no Array[1] index.
Any ideas ?
ORIGINAL (old index | array old value) | || || | NEW (new index | array new value) |
---|---|---|---|---|
-3 | value of -3 | || | -3 | value of -1 |
-1 | value of -1 | || | -2 | value of 1 |
1 | value of 1 | || | -1 | value of 3 |
3 | value of 3 | || | 0 | value of 4 |
4 | value of 4 | || |
Thanks guys for your !
I don't know whether the guy who made the feature request (@Shaykid) even saw the answers... Never mind if it can help other members!
While I was thinking about this subject (removing indexes in an array) I realized that it could be a problem to have arrays with "holes" in index numbering (when removing one of them somewhere in the middle of the sequence) because outside the specific Loop action it's not possible to check whether an index exists or not if they are not in sequence...
So I made the Action block below:
Here are the comments:
INPUT variables:
• ArrayIN => Your_array
• IndexToRemove => the index you want to remove (don't forget to set its value otherwise index #0 will be removed)
• FirstIndexUnchanged (optional) => to start numbering from the original first index. Default value=True
• FirstNewIndex (optional) => the index # you want to start with (not taken into account if FistIndexUnchanged is True). Default value=0
OUTPUT variable:
• ArrayOUT => Your_array (same as ArrayIN)
IndexToRemove refers to numbering BEFORE reorganization (the original one)
Let's say we have such an array with:
FirstIndexUnchanged=True
IndexToRemove=-3
ORIGINAL
(old indexarray
old value)||
||NEW
(new indexarray
new value)-3 value of -3 || -3 value of -1 -1 value of -1 || -2 value of 1 1 value of 1 || -1 value of 3 3 value of 3 || 0 value of 4 4 value of 4 ||
I wouldn't say that arrays are broken, they are just unusualThis should have arleady been in the app. The way how MacroDroid deals with arrays is just broken. As @MacroDroidDev stated they are they are just tweaked dictionaries and it becames very striking and obvious when you try to use them.
I agree with you!I wouldn't say that arrays are broken, they are just unusual
they are more like the arrays of the computer language Lua (famously used by Adobe Lightroom among others)
if you don't use negative indexes and you don't remove indexes then you have a nice classic array
if you do tricky things then you get tricky arrays
I think it was a smart decision by @MacroDroidDev to standardize on a single base container , the dictionary
what he didn't anticipate though was that the MD users are smart too and want to do all the tricks ,
so some more functions related to arrays and dictionaries have to be added in the future (like the famous length, the remove element at an index of an array or remove element at a key of dictionary, join two dictionaries etc etc)
I'm sure there will be many such additions and we just have to wait
Yeah just a telephone with more power than computers of the 1990s.But I sometimes have the opportunity to make some of my friends remember that the device they/we are using (the mobile) is a... telephone. Not a computer!