Distinguishing CLI from GUI

Richard Gaskin ambassador at fourthworld.com
Mon Jun 13 08:50:23 CDT 2011


"Bug" in the documentation, or the implementation?

Any workaround to determine if launched facelessly?

--
  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


Björnke von Gierke wrote:
>
> bug
>
> On 13 Jun 2011, at 14:41, 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
>>




More information about the use-livecode mailing list