Args and namespaces
Posted
#1
(In Topic #1251)
Trainee
I'm using gb.Args as an example here, but I guess I'm primarily interested in how to correctly reference components (especially those supplied within the gb namespace). Pretty sure this is laid out somewhere in the wiki, but try as I might I cannot find the info I need (or I need more coffee).
Code (gambas)
- ' Gambas module file
- bR = Args.Has("r", "revision", "Display revision number")
- bS = Args.Has("s", "state", "Display application state")
Above is the entirety of my module file, a slightly reduced version of what I see over here. I don't expect it to do anything, because I removed the code that evaluates BA, bR etc, but I do expect it to compile, except what I get is the following error:
Code
Unknown symbol 'Begin' in class 'Args'Do I need to import gb, or gb.Args and how do I do that? I also tried fully qualifying ("gb.Args.Begin") but that doesn't seem to help. A litte lost, would love a steer in the right direction :-)
Posted
Guru

Once you have the component added then the additional Args functions will work.
Posted
Trainee
Posted
Guru

BillyGoatGruff said
As easy as that … fantastic, thank you.
You're welcome
It is possible to import gb.args and many other components/classes to your program but only do that if you need to modify the component to work differently than default.
For example some of my programs have imported gb.args that supports more than one char short names.
so something like -ab is treated as -ab and not both -a & -b
If you need a component to work differently you can simply import many of them into your project .src folder and remove the setting to load the gambas component.
So for gb.args it's a simple case of removing the gb.args from the project properties then copying the comp/src/gb.args/.src/Args.module · master · Gambas / gambas · GitLab file to your projects .src folder then you can modify it to your hearts content
Posted
Trainee
1 guest and 0 members have just viewed this.



