I've know the syntax IndexNumber that gives "the index of the array value within the Variable Array ", so that IndexNumber returns the corresponding Variable in an array
But how can I do to have my Variable in an array to return its IndexNumber ?
One way you could do this with a list of numbers that might change is to first have your list of numbers as a Variable with each number on a new line. Then convert that list into a form that can be used in your prompt (10|20|30|45 etc).
After the choice of number is made, you can use a For Each Action to count down through the lines until a match is found (the chosen number matched to one of the original numbers in the list). The number of lines counted until the match will be the "index" number you are after.
The good thing about this approach is that you can change the numbers in the list at any time, the list can be of any length and the Macro will still return the index number.
And since I seem to be on a roll... Since our (pseudo) array is just text, we can chop off the text after our chosen item, then get the length of the remaining array. (Note -- you need to add |s to the start and end of the text so you can search for a completely-delimited number, hence the subtraction after getting the matched index.)
You can use a text file for the prompt list to make maintenance easier. (I use BBEdit for such things Keep in mind that BBEdit reverts to a still very powerful lite version after a set demo period.)
Just be aware that to use a Variable for the dropdown list you need to put an extra | in front of it to tell Keyboard Maestro to treat it as a dropdown list.