[Gambas-user] about Application.Args

Rob sourceforge-raindog2 at ...94...
Fri Oct 27 18:29:57 CEST 2006


On Friday 27 October 2006 10:30, Stefano Palmeri wrote:
> Application.Args.Count returns number of arguments + 1,
> because of the application name. Is it a feature or bug? I
> think is more logical that arguments don't count the name of
> the application.

Having the arguments include the application name is "the C way" 
of doing things.  Java and Perl omit the application name.  I 
personally expected it to behave as it does, but I can 
understand why it would be confusing.

The reason C does it that way is because you can have a single 
executable with multiple symbolic links to it, and have it do 
different things depending on what name the user ran it under.  
For example, gzip and gunzip are the same program, but behave 
differently depending on which one you run.  So there needs to 
be a way to get the actual name of the program, and the name 
under which the user ran it.  There's no reason to prevent Gambas 
programs from using this kind of functionality.

I have also seen programs behave differently if you called them 
with an absolute path versus just the name of the program by 
itself.... gbx used to be one of those programs, in fact.  
Again, that's user-supplied data and, in my opinion and 38 years 
of C tradition, belongs in the arguments.  Of course, BASIC 
isn't C, but I think Gambas is something beyond BASIC.

> Anyway, the help should be modified:
> Application.Args
> Returns an array containing the application name and the
> arguments passed to the program by the shell.

I'd add a note mentioning that the first argument is always the 
name of the program.  In fact, I just did.

Rob




More information about the User mailing list