Getting the index of a selected menu choice.

Hi, just starting with bash scripting on opensuse 12.3 (64bit)
I am trying to create a menu script that handles 2 arrays and the choices
with the “dialog” command.

One of the arrays is the options shown in the menu, the other array is a
string that is the argument to another command.
This is what sets up the dialog:

[…]
dialog --clear --backtitle “My menu”
–title “[MENU]”
–menu “Use the UP/DOWN arrow keys, first letter or number.

" 15 55 9
${MyTitle[li]} 2>”${INPUT}"[/li]menuitem=$(<"${INPUT}")

This correctly stores the chosen menu item in the “menuitem” variable.
However how do I know the index of the array holding the choice I made? The
menu entries are stored in MyTitle[] and the strings in MyString[]

I need to know that index to acccess the other array where the strings are
stored.
Is that possible at all?

Many thanks for any insight!

-G-

Hi, I think you will have to iterate over the array to find the element corresponding to the menu item chosen. Look here Search array return index in bash - Stack Overflow for that. HTH Lenwolf