[Gambas-user] gb.args - a question
Willy Raets
willy at ...2734...
Sat Feb 16 03:32:36 CET 2013
On Sat, 2013-02-16 at 02:55 +0100, Willy Raets wrote:
> On Sat, 2013-02-16 at 08:59 +1030, Bruce wrote:
> > On Fri, 2013-02-15 at 23:07 +0100, Willy Raets wrote:
>
> Thanks Bruce,
>
> I tried this but instead of <appname> -a returning the info required it
> launches the application and thus is not recognised as a argument!!
>
> I did remove:
> sAbout = Args.Get("a", "about", "To test gb.args in GUI application")
>
> Did it have to stay in?
>
> And what if where now the line:
> "To test gb.args in GUI application"
> it should actually say:
> "Display about"
> as I see it when doing a <appname> -h
>
> And when doing the <appname> -a it should give:
> "To test gb.args in GUI application"
> So that should be the value returned, but how to return the value?
> And how to get the argument recognized?
>
> Willy
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...
More information about the User
mailing list