variable number of checkboxes in dialog

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I am using Cdparanoia and Sox (play) to play CD's on an old Nokia internet tablet. I am using 'dialog' with the checklist option, to either select individual tracks or the entire disk for playback.



How can I adapt the script so that it can find out the number of tracks on the CD and so create a checkbox for each track (and name them track1, track2 etc)



I can find the number of tracks:



var=`cdparanoia -sQ |& cat | wc -l`; echo $[ $var - 8 ]


and the script that I am currently using is based on:



 #!/bin/bash

mycmd=(dialog --separate-output --checklist "Select options:" 22 76 16)
options=(1 "Track 1" off # any option can be set to default to "on"
2 "Track 2" off
3 "Track 3" off
4 "All Tracks" off)
choices=$("$mycmd[@]" "$options[@]" 2>&1 >/dev/tty)
clear
for choice in $choices
do
case $choice in
1)
echo "Track1"
;;
2)
echo "track2"
;;
3)
echo "track3"
;;
4)
echo "All Tracks"
;;
esac






share|improve this question


















  • 1




    Actually that's not a checklist, but a menu (see the manual). As a start, you'd have to add a column to the array of off tokens.
    – Thomas Dickey
    Oct 22 '17 at 23:41










  • Thanks, I've edited my post to show correct example code (It was late when I posted originally)
    – Phil Turner
    Oct 23 '17 at 7:26














up vote
0
down vote

favorite












I am using Cdparanoia and Sox (play) to play CD's on an old Nokia internet tablet. I am using 'dialog' with the checklist option, to either select individual tracks or the entire disk for playback.



How can I adapt the script so that it can find out the number of tracks on the CD and so create a checkbox for each track (and name them track1, track2 etc)



I can find the number of tracks:



var=`cdparanoia -sQ |& cat | wc -l`; echo $[ $var - 8 ]


and the script that I am currently using is based on:



 #!/bin/bash

mycmd=(dialog --separate-output --checklist "Select options:" 22 76 16)
options=(1 "Track 1" off # any option can be set to default to "on"
2 "Track 2" off
3 "Track 3" off
4 "All Tracks" off)
choices=$("$mycmd[@]" "$options[@]" 2>&1 >/dev/tty)
clear
for choice in $choices
do
case $choice in
1)
echo "Track1"
;;
2)
echo "track2"
;;
3)
echo "track3"
;;
4)
echo "All Tracks"
;;
esac






share|improve this question


















  • 1




    Actually that's not a checklist, but a menu (see the manual). As a start, you'd have to add a column to the array of off tokens.
    – Thomas Dickey
    Oct 22 '17 at 23:41










  • Thanks, I've edited my post to show correct example code (It was late when I posted originally)
    – Phil Turner
    Oct 23 '17 at 7:26












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am using Cdparanoia and Sox (play) to play CD's on an old Nokia internet tablet. I am using 'dialog' with the checklist option, to either select individual tracks or the entire disk for playback.



How can I adapt the script so that it can find out the number of tracks on the CD and so create a checkbox for each track (and name them track1, track2 etc)



I can find the number of tracks:



var=`cdparanoia -sQ |& cat | wc -l`; echo $[ $var - 8 ]


and the script that I am currently using is based on:



 #!/bin/bash

mycmd=(dialog --separate-output --checklist "Select options:" 22 76 16)
options=(1 "Track 1" off # any option can be set to default to "on"
2 "Track 2" off
3 "Track 3" off
4 "All Tracks" off)
choices=$("$mycmd[@]" "$options[@]" 2>&1 >/dev/tty)
clear
for choice in $choices
do
case $choice in
1)
echo "Track1"
;;
2)
echo "track2"
;;
3)
echo "track3"
;;
4)
echo "All Tracks"
;;
esac






share|improve this question














I am using Cdparanoia and Sox (play) to play CD's on an old Nokia internet tablet. I am using 'dialog' with the checklist option, to either select individual tracks or the entire disk for playback.



How can I adapt the script so that it can find out the number of tracks on the CD and so create a checkbox for each track (and name them track1, track2 etc)



I can find the number of tracks:



var=`cdparanoia -sQ |& cat | wc -l`; echo $[ $var - 8 ]


and the script that I am currently using is based on:



 #!/bin/bash

mycmd=(dialog --separate-output --checklist "Select options:" 22 76 16)
options=(1 "Track 1" off # any option can be set to default to "on"
2 "Track 2" off
3 "Track 3" off
4 "All Tracks" off)
choices=$("$mycmd[@]" "$options[@]" 2>&1 >/dev/tty)
clear
for choice in $choices
do
case $choice in
1)
echo "Track1"
;;
2)
echo "track2"
;;
3)
echo "track3"
;;
4)
echo "All Tracks"
;;
esac








share|improve this question













share|improve this question




share|improve this question








edited Oct 23 '17 at 21:07

























asked Oct 22 '17 at 23:34









Phil Turner

12




12







  • 1




    Actually that's not a checklist, but a menu (see the manual). As a start, you'd have to add a column to the array of off tokens.
    – Thomas Dickey
    Oct 22 '17 at 23:41










  • Thanks, I've edited my post to show correct example code (It was late when I posted originally)
    – Phil Turner
    Oct 23 '17 at 7:26












  • 1




    Actually that's not a checklist, but a menu (see the manual). As a start, you'd have to add a column to the array of off tokens.
    – Thomas Dickey
    Oct 22 '17 at 23:41










  • Thanks, I've edited my post to show correct example code (It was late when I posted originally)
    – Phil Turner
    Oct 23 '17 at 7:26







1




1




Actually that's not a checklist, but a menu (see the manual). As a start, you'd have to add a column to the array of off tokens.
– Thomas Dickey
Oct 22 '17 at 23:41




Actually that's not a checklist, but a menu (see the manual). As a start, you'd have to add a column to the array of off tokens.
– Thomas Dickey
Oct 22 '17 at 23:41












Thanks, I've edited my post to show correct example code (It was late when I posted originally)
– Phil Turner
Oct 23 '17 at 7:26




Thanks, I've edited my post to show correct example code (It was late when I posted originally)
– Phil Turner
Oct 23 '17 at 7:26















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f399799%2fvariable-number-of-checkboxes-in-dialog%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f399799%2fvariable-number-of-checkboxes-in-dialog%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)