Re: [Cocoadialog-users] Bourne Shell Script Equivalent to Perl Script Sample for CocoaDialog Dropdo
Status: Beta
Brought to you by:
sporkstorms
From: Thomas P. <tp...@gm...> - 2008-12-02 16:50:25
|
Is there a way to return the number of files selected when using the filselect cocoadialog with --select-multiple option enabled? This would be quite convenient and I am wondering if there is a flag to return this value as perhaps the first return variable followed by all of the file paths thereafter? Thanks, Thomas On Mon, Dec 1, 2008 at 5:53 AM, Thomas Patko <tp...@gm...> wrote: > Hello Bill: > > Thanks again for the alternate approach. I see how cut may be much faster > and more lightweight and fast solution. I just made a syntax error when > trying to implement it last time. My project is integrating CocoaDialog and > Platypus to create a simple drag and drop run application with the ability > to take graphical user input. At this point, I am not 100% sure that the > users want so I am just playing with the basics. You might wan to mention > the synergy between CocoaDialog and Platypus (both are open source) as it > has worked out well for me and might for others as well. > > Thanks again for the help. Once you get the details down, CocoaDialog is > a very simple way to add graphical input to such drag and drop application > as those that I am making. > > Cheers, > > Thomas > > > On Mon, Dec 1, 2008 at 3:13 AM, Bill Larson <wl...@sw...> wrote: > >> On Nov 30, 2008, at 11:44 PM, Thomas Patko wrote: >> >> Hello Bill: >>> >>> Thank you very much for the Bourne shell script code and concept. I >>> agree that it is not necessarily the most elegant approach but the >>> combination of --no-newline and the awk '{print $X}' code reliably script >>> out the multiple variables passed back by CocoaDialog. I have made it work >>> quite well for my application, wherein I was only really interested in the >>> second variable. >>> >> >> An alternative, without using "awk", and having a "case...esac" statement >> to display the selected answer: >> >> #!/bin/sh >> >> CD="/Applications/CocoaDialog.app/Contents/MacOS/CocoaDialog" >> >> result=`$CD dropdown \ >> --title "Preferred OS" \ >> --items "Mac OS X" "GNU/Linux" "Windows" \ >> --button1 "That one!" \ >> --button2 Nevermind` >> >> return=`echo $result | cut -d" " -f1` >> answer=`echo $result | cut -d" " -f2` >> >> if [ $return -eq 1 ]; then >> case $answer in >> 0) echo "Mac OS X";; >> 1) echo "GNU/Linux";; >> 2) echo "Windows";; >> esac >> else >> echo "Nevermind" >> fi >> >> The "--no-newline" really isn't necessary. I originally included it >> because the original Perl script had it there. I am using "cut" to parse >> the output rather than "awk". >> >> My complaint with using "awk" is that it is a fairly heavy handed approach >> to a problem. It is great when you need to do a lot of processing of the >> input but has a tremendous amount of overhead to use when the processing is >> quite simple. >> >> I'm actually very impressed to see that someone is USING this mailing >> list. The inactivity on this list implies that not much is happening with >> CocoaDialog, which I'm glad to see isn't totally correct. >> > |