LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-31-2011, 08:27 PM   #1
Abezz
LQ Newbie
 
Registered: Jan 2011
Posts: 4

Rep: Reputation: 0
[solved] Xdialog - how to save checklist selection ?


hi,
I am creating an script with Xdialog.
The checklist option is confusing me a litte.

Can someone tell me how to save the checklist states so they can be used in a script?
As an example:
Code:
Xdialog --checklist "Choose toppings:" 10 40 3 \
        1 Cheese on \
        2 "Tomato Sauce" on \
        3 Anchovies off
I would then like to put these values through if/else statements to perform different things with respect to the user selection.

I have a feeling this involves arrays somewere....

Thanks

Last edited by Abezz; 01-31-2011 at 10:06 PM.
 
Old 01-31-2011, 09:24 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
According to the man page:
Code:
DIAGNOSTICS
       On completion of each box option (i.e. every time a widget is closed)
Xdialog sends any result (text, numbers) as one or more strings to stderr (this
can be changed so that the results are sent to stdout thanks to a common option).
It then goes on to talk about exit codes.

So you need to tell xdialog to send the result to stdout, then capture the output in a variable (or array), which you can then process normally. Something like this:

Code:
result=$(Xdialog --stdout --checklist \
 "Choose toppings:" 10 40 3 \
         1 Cheese on\
         2 "Tomato Sauce" on\
         3 Anchovies off
)
$ echo $result  #after checking all items
1/2/3
 
1 members found this post helpful.
Old 01-31-2011, 10:05 PM   #3
Abezz
LQ Newbie
 
Registered: Jan 2011
Posts: 4

Original Poster
Rep: Reputation: 0
Thank you very much, kind sir!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
changing OS selection at boot selection screen gcmhmedic17 Linux - Desktop 4 12-21-2010 11:38 AM
Selection Buffer sending text before completing selection fakie_flip Linux - Software 2 06-20-2010 07:54 AM
Xdialog checklist help serris Programming 2 10-31-2006 02:57 AM
Alsamixer does not save the unmuted selection seraph-seph Slackware 3 07-28-2005 07:43 PM
Need help with Xdialog justintime32 Linux - Software 1 06-17-2005 02:17 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration