Hi everyone,
Is it possible in Gambas to get the build date and version number and show it on a label?
I can do this in vb.net I just wondered if it something you can do in Gambas.
Get build data
- cogier
- Site Admin
- Posts: 1126
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Get build data
The version number is easy: -
I'm not sure what you mean by 'Build Date'. Is it the last time it was run in the IDE or when it was last made an executable?
Label1.Text = "MySuperProgram V" & Application.Version
You can change the version number from the menu Projects > Properties... It is also updated when you make a executable.I'm not sure what you mean by 'Build Date'. Is it the last time it was run in the IDE or when it was last made an executable?
- BruceSteers
- Posts: 1578
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Get build data
you could Stat() the application exe to get modified date...
Dim s As String = Application.Path &/ Application.Name
If File.Ext(s) <> "gambas" Then s &= ".gambas" ' gat app path this way for it to work if run from shell or if run from IDE
Label1.Text = Application.Name & " V" & Application.Version & " , date: " & Stat(s).LastModified
If at first you don't succeed , try doing something differently.
BruceS
BruceS
-
- Posts: 363
- Joined: Wednesday 2nd December 2020 12:11am
- Location: Northampton, England
- Contact:
Re: Get build data
Sorry I should have said the build date was when it was last made into a executablecogier wrote: ↑Tuesday 23rd February 2021 5:37pm The version number is easy: -
You can change the version number from the menu Projects > Properties... It is also updated when you make a executable.
Label1.Text = "MySuperProgram V" & Application.Version
I'm not sure what you mean by 'Build Date'. Is it the last time it was run in the IDE or when it was last made an executable?
- BruceSteers
- Posts: 1578
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Get build data
It might be an even better idea to use Stat() on one of the exes internal files rather than the actual exe , I'm not sure If modified date if exe can change but the file ./.gambas/FMAIN For example will be present and its date should stay the same even if the exe changes.
If at first you don't succeed , try doing something differently.
BruceS
BruceS
-
- Posts: 363
- Joined: Wednesday 2nd December 2020 12:11am
- Location: Northampton, England
- Contact:
Re: Get build data
Thanks Bruce I shall try that. Worse case is I just have to changed the date manually.BruceSteers wrote: ↑Tuesday 23rd February 2021 11:27pm It might be an even better idea to use Stat() on one of the exes internal files rather than the actual exe , I'm not sure If modified date if exe can change but the file ./.gambas/FMAIN For example will be present and its date should stay the same even if the exe changes.
- BruceSteers
- Posts: 1578
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Get build data
AndyGable wrote: ↑Wednesday 24th February 2021 11:05amThanks Bruce I shall try that. Worse case is I just have to changed the date manually.BruceSteers wrote: ↑Tuesday 23rd February 2021 11:27pm It might be an even better idea to use Stat() on one of the exes internal files rather than the actual exe , I'm not sure If modified date if exe can change but the file ./.gambas/FMAIN For example will be present and its date should stay the same even if the exe changes.
you're welcome
I tried it , it works a treat
Got it down to a one liner
'
Label1.Text = Application.Name & " V" & Application.Version & " , date: " & Stat(Application.Path &/ ".gambas/FMAIN").LastModified
'
when you make the executable the .gambas/FMAIN file is renewed and it's modified date changesthe file is stored inside the executable and accessible with the above code.
then if the executable files modified date gets changed by an archiver or something then the FMAIN file inside the .gambas dir inside the executable will not change.
Bruce
If at first you don't succeed , try doing something differently.
BruceS
BruceS
- cogier
- Site Admin
- Posts: 1126
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Get build data
No need. Try this code: -Thanks Bruce I shall try that. Worse case is I just have to changed the date manually.
Public Sub Form_Open()
Print GetProgDetails()
End
Public Sub GetProgDetails() As String
Dim sText As String = "No executable file found"
Dim sPath As String = Application.Path &/ Application.Name & ".gambas"
If Exist(sPath) Then sText = Format(Stat(sPath).LastModified, "dd/mm/yyyy hh:nn")
Return Application.Name & " V" & Application.Version & " Created: - " & sText
End
My text program printed TestNew V0.0.6 Created: - 24/02/2021 14:38EDIT
I see Bruce pipped me to the post, but my version does look for the actual executable and puts the date in world format.
-
- Posts: 363
- Joined: Wednesday 2nd December 2020 12:11am
- Location: Northampton, England
- Contact:
Re: Get build data
I have just tried this and I get a error "Unexpected 'Application' in frmSplash.Class:15 any idea what this meanscogier wrote: ↑Wednesday 24th February 2021 2:41pmNo need. Try this code: -Thanks Bruce I shall try that. Worse case is I just have to changed the date manually.
Public Sub Form_Open() Print GetProgDetails() End Public Sub GetProgDetails() As String Dim sText As String = "No executable file found" Dim sPath As String = Application.Path &/ Application.Name & ".gambas" If Exist(sPath) Then sText = Format(Stat(sPath).LastModified, "dd/mm/yyyy hh:nn") Return Application.Name & " V" & Application.Version & " Created: - " & sText End
- cogier
- Site Admin
- Posts: 1126
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Get build data
Please post your program, so we can see what happens.I have just tried this and I get a error "Unexpected 'Application' in frmSplash.Class:15 any idea what this means