Distinguishing CLI from GUI

Richard Gaskin ambassador at fourthworld.com
Thu Jun 16 09:04:04 CDT 2011


Warren Samples wrote:

> Just to point out, although I'm sure you noticed;  while I do get the promised $ vars, which appears to be not
> working for you, the "-ui" flag is not being stored here, and it seems you're interested in getting that. That
> the $ values exist at all would indicate commandline, but it's not inconceivable that one might want some
> conditional behaviors based on whether or not the app is running with a gui, thus storing the "-ui" flag could
> be helpful. Such refinement is naturally only useful if the basics can be relied on, though :(

Actually, the $ vars will contain the paths to any files the app is 
launched with in the GUI too, which is why relying on the presence of 
the $ vars alone won't work for me since our apps read those values to 
determine which files to open at launch.

Thanks for confirming what Mark Weider discovered, that flags used by 
the engine ("-ui" is among the very few that are still used) aren't 
passed along to the app.  It seems other args not used by the engine are 
passed along, however, so we can design our own syntax as needed - quite 
exciting, in a geeky sorta way. :)

For now it seems I can use the window ID to figure out whether the app 
is launched with -ui; in my testing on all three platforms the window ID 
of the mainstack is 1 when launched with -ui, but not when launched with 
the GUI.


Extra bonus points:

When using R, MySQL, Mongo, and many other apps, I'm in an interactive 
mode in which the app provides its own console UI and its own prompt.

It may be useful down the road to be able to provide such an interactive 
mode for the command line, but I've been unable to wrap my head around 
using stdin and stdout to do this.  So far, I can only pass args to the 
app, have it process those, and deliver output from them and quit.

How can I set up my own interactive mode from the command line, and can 
I make a custom prompt to signify to the user that they're in my app?

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