[Gambas-user] Script vs Command Line Application

Tobias Boege taboege at gmail.com
Sat Mar 21 13:37:36 CET 2020


On Sat, 21 Mar 2020, Patrik Karlström wrote:
> I was about to do some bash scripts in order to
> 
>    - Create 3 Java run times environment, one for each major os, with jlink
>    - From one NetBeans application platform.zip
>       - edit a text file
>       - insert a JRE
>    - Create an AppImage
>    - Produce checksums
> 
> I'm already doing this semi-manual today and looking for a more automated
> version.
> 
> Then Gambas came to my mind, but it was a couple of years since I used it,
> and I've never touched scripts before
> 
> The question now is, should I go with a Script or a Command Line
> Application?
> 

Of the two types, Command Line Application is the one that is "native" to
Gambas. When you create a script and run it through gbs3, it takes your
source file and builds a command line project around it and then has gbc3
compile and gbx3 execute that temporary project. These projects are cached
in /tmp and a new one is created when your script source changes.

That is, scripts are mini-projects that get automatically recompiled when
needed. If your source doesn't change, they start up just as fast as pre-
compiled projects. The disadvantage of a script is that you are restricted
to a single source file. Note that you can still use components by writing
USE statements [1] at the top of your script. In particular gb.args can be
useful for utility scripts.

I tend to use scripts when the single-file restriction doesn't bother me
and when I may need to quickly edit them on a host which doesn't have the
Gambas IDE installed.

Regards,
Tobi

[1] http://gambaswiki.org/wiki/lang/use

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


More information about the User mailing list