Random Item from Array

MrMetroGnome

New member
I'm trying to send an SMS from an array of strings. I've defined the array, but I don't understand the syntax of simply accessing the array explicitly, let alone randomly choosing an integer from 0 to the array size - 1.
 

Dm114

Well-known member
I'm trying to send an SMS from an array of strings. I've defined the array, but I don't understand the syntax of simply accessing the array explicitly, let alone randomly choosing an integer from 0 to the array size - 1.
Set n=[size=Array]-1
Set i=random from 0->n
Set s=Array[[lv=i]]
 

Dm114

Well-known member
I'm new to MacroDroid. Please give an example. thank you
You first should have a look to MD Wiki to get familiar with MD.

Then, in the example provided, the array called "Array" is supposed to be manually populated with appropriate strings.

Actions described are common Set variable actions to set values to named variables as described.

Last action Set s=Array[[lv=i]] is even not mandatory as you can use and display Array[[lv=i]] like any other string variable.
 
Top