[Gambas-user] Gambas script gbs Application.Path Args[0]

Tobias Boege taboege at gmail.com
Mon Nov 2 19:58:20 CET 2020


On Mon, 02 Nov 2020, Benoît Minisini wrote:
> Le 02/11/2020 à 17:30, Bruce Steers a écrit :
> > Hi Benoít.
> > 
> > Would you consider this simple modification to gbs3?
> > https://gitlab.com/bsteers4/gambas/-/commit/19cbe5853e9a3079bae2d4503c1627fc538bd850
> > 
> > I've made the scripter set up 2 Env variables as it runs as script.
> > Env["Application.Path"] and
> > Env["Args[0]"]
> > 
> > of course they emulate the same as a normal applications would.
> > 
> > I kept the naming Application.Path and Args[0] so converting an
> > application to a script would require minimum modifications.
> > 
> > I've tested it and it works great :)
> > Cheers
> > BruceS
> > 
> > 
> 
> As I said, converting a normal application to a script is a non-sense.
> 
> Just provide the source of the application and a little script that compiles
> and runs it.
> 
> As for your proposal (which does not depend on my previous remark), even if
> it works great, it's awful in my opinion. Instead there should be a way of
> overriding Application.Path and Args[0].
> 

Maybe this commit is a better solution:

  https://gitlab.com/gambas/gambas/-/merge_requests/161

I'm still unsure if I understood what problem is actually intended to be
solved here. My understanding is that you have a script /a/b/c.gbs3 and
*besides it* some resource file, /a/b/icon.png or so. Now you want to be
able to refer to the icon.png from the script? With the above commit,
you can do that using

  File.Load(".public/icon.png")

The commit adds a symlink .public/ to the generated project directory
which points at the directory where the script file is located (/a/b/
in the above example). The name was chosen in analogy to the .public
subdirectory for assets in gb.web.form projects.

Regards,
Tobias

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk


More information about the User mailing list