Results 1 to 2 of 2
Hi,
I use arrays to fill in the dialog's entries.
Problem is, with the remaining Array Variables, which are not being used.
I managed to give them the value of ...
- 03-09-2011 #1Just Joined!
- Join Date
- May 2008
- Posts
- 6
Bash dialog array
Hi,
I use arrays to fill in the dialog's entries.
Problem is, with the remaining Array Variables, which are not being used.
I managed to give them the value of " ", but this is unwanted by the users.
Any idea how I can delete the remaining Arrays without getting errors from dialog?
dialog --clear --cancel-label "BACK" --title "Some Title" \
--menu "$banner2080" 20 80 10 \
"${SELECTIONLST[0]}" "${SELECTIONLSTDSC[0]}" \
"${SELECTIONLST[1]}" "${SELECTIONLSTDSC[1]}" \
"${SELECTIONLST[2]}" "${SELECTIONLSTDSC[2]}" \
"${SELECTIONLST[3]}" "${SELECTIONLSTDSC[3]}" \
"${SELECTIONLST[4]}" "${SELECTIONLSTDSC[4]}" \
"${SELECTIONLST[5]}" "${SELECTIONLSTDSC[5]}" \
"${SELECTIONLST[6]}" "${SELECTIONLSTDSC[6]}" \
"${SELECTIONLST[7]}" "${SELECTIONLSTDSC[7]}" \
"${SELECTIONLST[8]}" "${SELECTIONLSTDSC[8]}" \
"${SELECTIONLST[9]}" "${SELECTIONLSTDSC[9]}" \
"${SELECTIONLST[10]}" "${SELECTIONLSTDSC[10]}" \
"${SELECTIONLST[11]}" "${SELECTIONLSTDSC[11]}" \
"${SELECTIONLST[12]}" "${SELECTIONLSTDSC[12]}" \
"${SELECTIONLST[13]}" "${SELECTIONLSTDSC[13]}" \
"${SELECTIONLST[14]}" "${SELECTIONLSTDSC[14]}" \
"${SELECTIONLST[15]}" "${SELECTIONLSTDSC[15]}" \
"${SELECTIONLST[16]}" "${SELECTIONLSTDSC[16]}" \
"${SELECTIONLST[17]}" "${SELECTIONLSTDSC[17]}" \
"${SELECTIONLST[18]}" "${SELECTIONLSTDSC[18]}" \
"${SELECTIONLST[19]}" "${SELECTIONLSTDSC[19]}" \
"${SELECTIONLST[20]}" "${SELECTIONLSTDSC[20]}" \
"${SELECTIONLST[21]}" "${SELECTIONLSTDSC[21]}" \
"${SELECTIONLST[22]}" "${SELECTIONLSTDSC[22]}" \
"${SELECTIONLST[23]}" "${SELECTIONLSTDSC[23]}" \
"${SELECTIONLST[24]}" "${SELECTIONLSTDSC[24]}" \
"${SELECTIONLST[25]}" "${SELECTIONLSTDSC[25]}" \
"${SELECTIONLST[26]}" "${SELECTIONLSTDSC[26]}" \
"${SELECTIONLST[27]}" "${SELECTIONLSTDSC[27]}" \
"${SELECTIONLST[28]}" "${SELECTIONLSTDSC[28]}" \
"${SELECTIONLST[29]}" "${SELECTIONLSTDSC[29]}" \
"${SELECTIONLST[30]}" "${SELECTIONLSTDSC[30]}" \
"${SELECTIONLST[31]}" "${SELECTIONLSTDSC[31]}" \
"${SELECTIONLST[32]}" "${SELECTIONLSTDSC[32]}" \
"${SELECTIONLST[33]}" "${SELECTIONLSTDSC[33]}" \
"${SELECTIONLST[34]}" "${SELECTIONLSTDSC[34]}" \
"${SELECTIONLST[35]}" "${SELECTIONLSTDSC[35]}" \
"${SELECTIONLST[36]}" "${SELECTIONLSTDSC[36]}" \
"${SELECTIONLST[37]}" "${SELECTIONLSTDSC[37]}" \
"${SELECTIONLST[38]}" "${SELECTIONLSTDSC[38]}" \
"${SELECTIONLST[39]}" "${SELECTIONLSTDSC[39]}" \
"${SELECTIONLST[40]}" "${SELECTIONLSTDSC[40]}" 2>/tmp/.tmp."$tmpdate"
- 03-21-2011 #2Linux User
- Join Date
- Jan 2005
- Location
- Saint Paul, MN
- Posts
- 262
Rather than having a command with a fixed number of references in as you do, how about generating an array form the arrays just before the dialog request.
Of course if there is a character not used in the data that you have in "SELECTIONLST" (say '|') then the two arrays can be combined into one making the syncing the the value and description easier.Code:SELECTIONLST=( "value a" "value b" "value c" ) SELECTIONLSTDSC=( "Choice a" "Choice b" "Choice c" ) SELECTIONINFO=() for idx in "${!SELECTIONLST[@]}"; do SELECTIONINFO+=( "${SELECTIONLST[${idx}]}" "${SELECTIONLSTDSC[${idx}]}" ); done dialog --clear --cancel-label "BACK" --title "Some Title" --menu "$banner2080" 20 80 10 "${SELECTIONINFO[@]}" 2>/tmp/.tmp."$tmpdate"
Code:SELECTIONLST=( "value a|Choice a" "value b|Choice b" "value c|Choice c" ) SELECTIONINFO=() for f in "${SELECTIONLST[@]}"; do SELECTIONINFO+=( "${f%|*}" "${f#*|}" ); done dialog --clear --cancel-label "BACK" --title "Some Title" --menu "$banner2080" 20 80 10 "${SELECTIONINFO[@]}" 2>/tmp/.tmp."$tmpdate"


Reply With Quote