[Gambas-user] gb.args - a question

Willy Raets willy at ...2734...
Sat Feb 16 16:31:22 CET 2013


On Sat, 2013-02-16 at 14:51 +0100, Tobias Boege wrote:
> On Sat, 16 Feb 2013, Willy Raets wrote:
> > Okay Bruce,
> > 
> > Thanks again, you got me on the right track and I got it solved showing
> > me about info without launching the application.
> > 
> > Here is how I did it:
> > 
> > Public Sub Main()
> >   
> >   Dim bAOption As Boolean
> >   Args.Begin(Application.Name & " <options>")
> >   bAOption = Args.Has("a", "about", "Display About")
> >   Args.End()
> >   If bAOption Then
> >     Print "Application to test gb.args"
> >   Else
> >     FMain.Show
> >   Endif
> >   
> > End
> > 
> > When doing <appname> -h it now correctly states "Display About" for help
> > with -a and --about
> > When doing <appname> -a it now correctly returns "Application to test
> > gb.args" (without the GUI application getting launched)
> > 
> > Perfect, I think I'm slowly beginning to get a grasp at it.
> > Public Sub Main()
> >   
> >   Dim bAOption As Boolean
> >   Args.Begin(Application.Name & " <options>")
> >   bAOption = Args.Has("a", "about", "Display About")
> >   Args.End()
> >   If bAOption Then
> >     Print "Application to test gb.args"
> >   Else
> >     FMain.Show
> >   Endif
> >   
> > End
> > 
> > Feel free to use this example in documentation if you like (or an
> > adapted version for that matter). An example tells a whole lot more in
> > way less time than studying the documentation, try, fail, study
> > documentation, try, fail, study documentation, try, fail, search google,
> > find nothing, post on mailing list, get answer, try, fail, study
> > documentation, try, fail and so on... :)
> > 
> > Thanks again Bruce for the spark...
> 
> Since gb.args is written in Gambas and implements -V and -h, it is an
> example itself. Look into comp/src/gb.args/.src/Args.module. It is done with
> those options there the same way inside Args.End(). I _believe_ that you can
> even save the bAOption variable by using: If Args.Has(...) Then Print "..."
> before calling Args.End().
> 
> Regards,
> Tobi

Thanks Tobi,

The If Args,Has() Then Print seems very interesting.
I think I'll have to have a look at the source of gb.args
Guess that will give more insight :)
But an example in the documentation wouldn't harm.
Don't think a lot of us would look in gb,args source code for a
solution :)

-- 
Kind regards,

Willy (aka gbWilly)

http://gambasshowcase.org/
http://howtogambas.org
http://gambos.org








More information about the User mailing list