On Monday, June 13, 2011 07:41:32 AM Richard Gaskin wrote: > As Todd Geist quoted here earlier, in the Dictionary entry for "$" it says: > > If you start up the application from the command line (on OS X, > Unix or Windows systems), the command name is stored in the > global variable $0 and any arguments passed on the command line > are stored in numbered variables starting with the $ character. > For example, if you start the application by typing the following > shell command: > > myrevapp -h name > > then the global variable $0 contains "myrevapp" (the name of the > application), $1 contains "-h", and $2 contains "name". > > In my tests here, it seems this is only partially correct: $0 contains > the app name from the command line ("myrevapp" in their example), but $1 > contains the "name" portion after the "-h" option flag, and the flag > itself does not appear in any $ variable. > > I have an app in which I'd like to have two different behaviors, > depending on whether it's being run from the command-line or as a GUI. > > This would be easy if the engine worked as described in the Dictionary > so I could easily detect if the user launched it with "-ui", but it > seems the option flags are not being passed to the application, though > everything that doesn't begin with "-" is. > > So my question is two-fold: > > 1. I've tested this on Windows and Linux and get identical behavior, in > which the "-" flags aren't present in the "$" vars. Can anyone here > confirm this on Linux, Win, or OS X? > > 2. If this is indeed a documentation bug and what I see in my tests is > what happens for everyone, how can I determine whether the app was > launched with "-ui" or not? > > -- > Richard Gaskin > Fourth World > LiveCode training and consulting: http://www.fourthworld.com > Webzine for LiveCode developers: http://www.LiveCodeJournal.com > LiveCode Journal blog: http://LiveCodejournal.com/blog.irv >
Richard, It seems to be working here although certain letters seem not to be usable. For example -s does not work. I can get an answer dialog to return "-h" when used as a cl flag and the app will do something if there is a variable $x which equals -h. as a silly example, this script does exactly what it looks like it should: on openstack answer $0 && $1 && $2 && $3 && $4 && $5 if $1 is "-h" then answer "hooboy, it works" end openstack using this command: '/myApp -h a-param -o some-param' answers "/myApp -h a-param -o some-param" and then answers "hooboy, it works". openSUSE 11.4 with Bash. Regards, Warren _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode