Here's a slightly modified version of Tobi's demo showing most (?) of the features of the Args processor with comments.
hth Bruce On Thu, 21 Aug 2014 01:07:28 +0200 Tobias Boege <[email protected]> wrote: > On Wed, 20 Aug 2014, Geoffrey De Belie wrote: > > > > Op 19-08-14 om 21:28 schreef Tobias Boege: > > >On Tue, 19 Aug 2014, Geoffrey De Belie wrote: > > >>Hi, > > >> > > >>After reading the documentation at > > >>http://gambasdoc.org/help/comp/gb.args/args/has?v3 I'm not sure how to > > >>use command line arguments in Gambas. Can you explain it to me? > > >> > > >>1) Is it possible to pass command line arguments to my GUI application? > > >>If so, how? > > >>2) How can I define command line arguments (options) like --execute, -e > > >>or --replace, -r? > > >> > > >Does the attached project help you? > > > > > >Note that you call the Gambas interpreter to start your Gambas program. The > > >interpreter takes arguments of its own so you have to take the canonical > > >measures (i.e. the sole double dash) to make gbx3 leave your argument to > > >gb.args: > > > > > > $ gbc3 && gbx3 -- --replace ABC > > > > > >in your project directory will compile and call the program. > > > > > >Also, you wrote this message to the gambas-devel mailing list which is for > > >people who contribute to Gambas. To ask Gambas user/usage questions like > > >yours, there is the gambas-user mailing list (which I'm CC'ing now). You > > >will likely get an even quicker response there :-) > > > > > >Regards, > > >Tobi > > > > > Hi, > > > > Thanks for the project. Just what I needed. One last question: how can I add > > the parameter to the --help text? > > > > I read at http://gambasdoc.org/help/comp/gb.args/args/getinteger?v3 > > "_ArgName_ is the name of the option argument used by the --help option." > > > > Almost what I need, I just don't know how to define an option that takes an > > argument, like --replace sometext does. > > > > Args.Get() is for options which accept some data (in string form). There are > GetInteger() and GetFloat() which convert the argument to Integer or Float > for you. For argument-less options, you have the Has() method. > > You specify the help text and stuff in the call to Args.Get()/GetInteger()/ > GetFloat()/Has(), like so (adapting the project I sent): > > $sReplace = Args.Get("r", "replace", "Specify the replacement text", "rep") > > Then > > $ gbc3 && gbx3 -- --help > Usage: gui-args <options> <arguments> > > Options: > -r --replace <rep> Specify the replacement text > -V --version Display version > -h --help Display this help > > I first thought it was some non-deterministic black magic which makes the > arguments to some method call appear in that help text but if you experiment > a bit with gb.args (place Args.Begin(), ..., Args.End() blocks into different > sections of your program or look into its source code), you'll see that it is > still limited to the traditional idea of action before reaction. > > Regards, > Tobi > > -- > "There's an old saying: Don't change anything... ever!" -- Mr. Monk > > ------------------------------------------------------------------------------ > Slashdot TV. > Video for Nerds. Stuff that matters. > http://tv.slashdot.org/ > _______________________________________________ > Gambas-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/gambas-user -- B Bruen <[email protected]>
gui-args-0.0.12.tar.gz
Description: Binary data
------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/
_______________________________________________ Gambas-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/gambas-user
