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

Bruce Steers bsteers4 at gmail.com
Mon Nov 2 20:50:17 CET 2020


Yes that could work.
Thank you.
Understanding the problem..
It's a double barreled problem for me.
App dir for resources yes or any other reason to know the location the
script was called from but also to get the full path of the running app.
Simply put it's missing something.
In Gambas you have Args[0] , points to string used to launch the app.
In bash you have "$0" , same thing

gambas scripting is lacking this feature due to how it works.

I've also used Arg[0] to relaunch an app. won't be able to do that with
scripting.
your solution would work for this as the app name can be derived from the
scripts Arg[0] field.

My solution I thought offered a simple..
sArgs0 = Iif(Not Env["Args[0]"], Args[0], Env["Args[0]"])

thus having code that simply adjusts depending on if a script or an exe.

the ultimate solution would be for a gambas script to report Args[0] and
Application.Path as the launched script and not the compiled temporary
project.

Bruce

On Mon, 2 Nov 2020 at 18:59, Tobias Boege <taboege at gmail.com> wrote:

> 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
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20201102/7fbcff7b/attachment.htm>


More information about the User mailing list