voice input works with variables of type dict but not array

dsnz

Well-known member
as the title says, action "voice input" works with variables of type dict but not with variables of array type
I find this nice that works with dictionaries instead of only plain string variables
but why array variables are excluded ?
 

FrameXX

Well-known member
It really does work with dictionaries? For me it only allows saving into a string. How does it work in dictionary? Every word is new index?
 

dsnz

Well-known member
when you configure the action it asks to select an existing key or add a new key !
much like what happens in "set variable" action

I was surprised too 😂
 

FrameXX

Well-known member
Now I tryed again. You are right. If I setup a dictionary and add a string into it with whatever key it allows me to save the input in, however doesn't work if I try the same with array.

It's sad that if I choose option to add key into dict with every voice input, the key doesn't support magic text. I could imagine saving dozens of voice inputs with time as their key. That could be useful. Currently the new voice input alwys overwrites the previous because the key is same.

Screenshot_20220508-093300_MacroDroid.png
 

Dm114

Well-known member
Now I tryed again. You are right. If I setup a dictionary and add a string into it with whatever key it allows me to save the input in, however doesn't work if I try the same with array.

It's sad that if I choose option to add key into dict with every voice input, the key doesn't support magic text. I could imagine saving dozens of voice inputs with time as their key. That could be useful. Currently the new voice input alwys overwrites the previous because the key is same.

View attachment 2677
Why wouldn't you save every Voice input in a plain string variable and then save this variable in an Array or Dictionary entry?

I've just noticed that index/key values in Arrays are strings and can contain text (not only integers as I first thought).
 

dsnz

Well-known member
Why wouldn't you save every Voice input in a plain string variable and then save this variable in an Array or Dictionary entry?

I've just noticed that index/key values in Arrays are strings and can contain text (not only integers as I first thought).
index of array can be string ?!
then it's not an array really, it's a dict masquerading as array 😂
(the Lua language similarly has only dict - called table - and no array)

btw. has anyone noticed if there is a way to get length of an array or number of keys in a dictionary ?
 

FrameXX

Well-known member
btw. has anyone noticed if there is a way to get length of an array or number of keys in a dictionary ?

I think it isn't. But was requested.

 

dsnz

Well-known member
regarding on these assignments to arrays and dicts and the future functions to get length and surely many more in the future, I think that @MacroDroidDev
should abandon visual configuration screens for these things because theg will grow unwieldy (eg. the use of a variable to specify a key in a dict or an index in an array)
and instead think carefully a small expression language whenever a variable specification is needed
eg.
a_dict[a_string_var] or a_dict[${a_string_var}]
a_dict["this is a key"]
a_array[a_integer_variable]
a_dict["a_key"][a_integer_variable_to_index_a_array] <- this can continue deeper
a_array[#a_array] where #a_array is length of array (or dict too)
etc.
ie a kinda Python-esque way (or could be like Groovy)

in this scheme the old way of [v=a_variable] must be deprecated sometime
 
Top