Some questions about Command-line argument parser library

Mark Waddingham mark at livecode.com
Tue Oct 19 04:28:14 EDT 2021


On 2021-10-18 23:04, matthias rebbe via use-livecode wrote:
> Mark,
> 
> thank you very much for your explanations.
> 
> It works now.
> 
> Would  you please be so kind to also explain what for the
> argumentArray can be used?
> 
> GetOpt(grammar [, argumentArray])
> 
> Okay, i could use it for testing in the LC IDE, so i do not need to
> compile and execute the standalone.
> But is there another scenario where it would make sense to include
> that array in the call?

It just makes it more flexible - you may need to pre-process the 
argument array before processing it for options - or perhaps some 
commands are just shorthand for others, so it allows you to separate the 
arguments from the thing which uses them e.g. in C, the main function 
passes you argv and argc, so you can in principal substitute at your 
leisure - indeed GetOpt() is based on the 'standard' C function getopt 
which does the same thing with the same grammer... The latter requires 
you pass in the argument array.

> The environment function can also return "development command line"
> The dictionary says about that : The stack is running in the
> development environment with the "-ui" command line option.
> 
> So would i be able to run a stack by running the LC IDE with -ui, add
> the stack as parameter and add also command line options, which then
> could be parsed with getop()?

Heh - I can't remember off the top of my head exactly what does work 
there - the licensed editions of LC were always a bit different from 
community. I did have to make some tweaks for 9.6,4 though to ensure all 
our build systems still run (we use LiveCode for a fair bit of stuff 
which occurs after the engine is built) so perhaps try it and see? :)

Warmest Regards,

Mark.

-- 
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps




More information about the use-livecode mailing list