Find the answer to your Linux question:
Results 1 to 2 of 2
I'm trying to create a multi-column menu using Dialog in a Bash script. The man page offers this syntax: Code: --column-separator <string>: split data for ... menus on the occurrences ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2012
    Posts
    2

    Need dialog --column-separator example


    I'm trying to create a multi-column menu using Dialog in a Bash script. The man page offers this syntax:

    Code:
    --column-separator <string>: split data for ... menus on  the occurrences of the given string
    but leaves out the particulars or examples, nor have I been able to turn up any usage examples on the net. For example, is "string" wrapped in quotes? What characters are legal? And where exactly do I insert the string in my menu definitions?

    Here's a menu that works:

    Code:
    #!/bin/bash
    
    dialog --title " Welcome to My Menu! " \
           --menu "" 19 40 12              \
                   "1" "Option One"        \
                   "2" "Option Two"        \
                   "3" "Option Three"      \
                   "4" "Option Four"       \
    2>temp
    Cancelled=$?
    Choice=`cat temp` ; rm temp
    if [ $Cancelled -eq 0 ] 
      then echo "You selected: $Choice"
      else echo "You cancelled!"
    fi
    But when I try to add a column separator, for example this way:

    Code:
    #!/bin/bash
    
    dialog --title " Welcome to My Menu! " \
           --column-separator "|"          \
           --menu "" 19 40 12              \
                   "1" "Option One"        \
                   "2" "Option Two"        \
    "|"            "3" "Option Three"      \
                   "4" "Option Four"       \
    2>temp
    Cancelled=$?
    Choice=`cat temp` ; rm temp
    if [ $Cancelled -eq 0 ] 
      then echo "You selected: $Choice"
      else echo "You cancelled!"
    fi
    It fails. The above, for example, just spits out "You cancelled!" and exits. Other attempts generally elicit syntax errors inside the --menu definition.

    Can someone provide me with an example of the proper syntax for --column-separator? Thanks.

    --Nathanael

  2. #2
    Just Joined!
    Join Date
    Sep 2012
    Posts
    2
    For future generations, here's the answer:

    Turns out --column-separator doesn't do what I was expecting. Whereas I was trying to create column breaks *between* menu items (creating multiple columns of items), --column-separator is for breaks *within* items, like this:

    Code:
    ┌─────────────────── Welcome to My Menu! ──────────────────────┐
    │ ┌──────────────────────────────────────────────────────────┐ │  
    │ │   1  Option One     1-2 buckle my shoe                   │ │  
    │ │   2  Option Two     Old MacDonald had a farm             │ │  
    │ │   3  Option Three   Jack and Jill went up a hill         │ │  
    │ │   4  Option Four    Old King Cole was a merry old soul   │ │  
    │ └──────────────────────────────────────────────────────────┘ │  
    ├──────────────────────────────────────────────────────────────┤  
    │                 <  OK  >         <Cancel>                    │  
    └──────────────────────────────────────────────────────────────┘
    Here's the code:

    Code:
    #!/bin/bash
    
    dialog --title " Welcome to My Menu! " \
           --column-separator "|"          \
           --menu "" 6 0 0              \
                   "1" "Option One | 1-2 buckle my shoe"        \
                   "2" "Option Two | Old MacDonald had a farm"        \
                   "3" "Option Three | Jack and Jill went up a hill"      \
                   "4" "Option Four | Old King Cole was a merry old soul"       \
    2>temp
    Cancelled=$?
    Choice=`cat temp` ; rm temp
    if [ $Cancelled -eq 0 ] 
      then echo "You selected: $Choice"
      else echo "You cancelled!"
    fi
    Unfortunately, not what I was after.

    --Nathanael

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •