[Gambas-user] check 4 Gambas Runtime files?

Tobias Boege taboege at gmail.com
Wed Dec 13 08:54:50 CET 2017


On Tue, 12 Dec 2017, mikeB wrote:
> On my web site, that I offer software programmed using Gambas, I have a
> notice :
> ***********************************************************************
> VERY IMPORTANT: before installing this app you will need to install Gambas
> Runtime  v10 files - most systems will not have these very new files
> installed yet.
> 
> Do so via the terminal commands:
> sudo add-apt-repository ppa:gambas-team/gambas3
> sudo apt-get update
> ***********************************************************************
> Now that Gambas runtime 10 files are more common - being install by the
> Distro - is there a way for the user (terminal command) to check if they are
> installed?
> 
> This is a real newbie question I'm sure but hey.. I'm a newbie!
> Thanks for any all help on this matter and have a GREAT day,
> mikeB
> 

First check if the interpreter gbx3 is found in PATH, using the "which"
utility. If not, I wouldn't call Gambas properly installed (although
some people might disagree -- it's their computer -- but then they will
be able to figure their Gambas version out themselves).

Once you have that, the System class has FullVersion which gives you the
Gambas version as a string and you can compare it like this:

  $ gbx3 -e 'Comp(System.FullVersion, "3.10", gb.Natural) >= 0'

Comp will return the sign (-1, 0 or 1) of subtracting the version 3.10
from your Gambas version. You want the comparison to yield 0 or 1.
With the above line, you will see either the string "True" or "False"
printed to the terminal; you can make the output fancier.

NOTE: gb.Natural makes the comparison by natural sort, which is appropriate
to compare version numbers. Observe:

  $ gbx3 -e 'Comp("3.2", "3.10")'
  1
  $ gbx3 -e 'Comp("3.2", "3.10", gb.Natural)'
  -1

Because "2" comes before "1" in the alphabet, the default lexicographic
comparison mode declares the string "3.2" to be greater than "3.10",
but gb.Natural gets it right.

Also never coerce the string version into a float for easier comparison
because you'll run into nasty bugs caused by float roundoff.

Regards,
Tobi

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


More information about the User mailing list