[Gambas-user] getting Gambas version info across devices

Brian G brian at westwoodsvcs.com
Fri Mar 26 02:49:44 CET 2021


Hi BruceS,

This should work great for most .gambas files like gbs3

Public Sub GetVersion(FilePath as string)
  Print "Loading file : ";; filePath
  Dim sfile As String = File.Load(FilePath)
  Dim project As Integer = InStr(sfile, "# Gambas Project File 3.0\n", 1)
  Dim location As Integer = InStr(sfile, "Version=", Project, gb.Binary)
  Dim length As Integer = InStr(sFile, "\n", Location, gb.binary) - location
  Print Mid(sFile, location, length)
end

This should work for gambas binary files like gbc3 or gba3
  Dim project As Integer = InStr(sfile, "/gambas" & System.version & "-" & System.Version, 1, gb.Binary)
  Dim length As Integer = InStr(sFile, "/", Project + 1, gb.binary) - project
  Print Mid(sFile, Project + 1, length - 1)

output would look like this

gambas3-3.15.90+git202103222309.dd1a35456+build14e27c76f~ubuntu20.04.1

"Failure is the key to success; 
 each mistake teaches us something"  .. Morihei Ueshiba
Brian G

----- On Mar 25, 2021, at 1:37 PM, Bruce adamnt42 at gmail.com wrote:

> On 26/3/21 3:07 am, Bruce Steers wrote:
>> ELF could work i think as i have readelf command.
>> 
>> but a bit of a needle in a haystack. Not sure where to look for the
>> version/trunk info.
>> 
>> 
>> Best i have come up with is this terrible awful , almost disgraceful hack
>> using the command strings.
>> "terrible but it works" ;)
>> 
>>      Dim sCli, sVer As String
>> 
>>          Shell "strings " & sDrive &/ "usr/bin/gbc3 | grep '3.'" Wait To sCli
>>          Dim sVar As String[] = Split(sCli, "\n")
>>          Dim c As Integer = sVar.Find("gbc3: start task: [%d] '%s'")
>>          While Left(sVer, 2) <> "3." And c < sVar2.Count
>>          Inc c
>>          sVer = sVar2[c]
>>          Wend
>> 
>> Hack , some might say.
>> Luck , could also be true.
>> 
>> whatever you cal it i'm now 10 out of 10 on getting it right ,,,, wrongly
>> ;) lol
>> 
>> 
>> But the ELF way looks to be the way if only you know what to look for (and
>> i don't :( )
>> 
>> BruceS
>> 
> 
> Urrgh, Yes, Sort of "If it looks a bit like a duck then it must be a
> duck, so shoot it." :-)
> 
> maybe
> Shell "strings " & sDrive &/ "usr/bin/gbc3 | grep '3\.[0-9]'" Wait To sCli
> might lower the risk.
> 
> b
> 
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----


More information about the User mailing list