Get build data
Posted
#1
(In Topic #593)
Enthusiast

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.
Posted
Guru

Code (gambas)
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?
Posted
Guru

Code (gambas)
Posted
Enthusiast

cogier said
The version number is easy: -Code (gambas)
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?
Sorry I should have said the build date was when it was last made into a executable
Posted
Guru

Posted
Enthusiast

BruceSteers said
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.
Thanks Bruce I shall try that. Worse case is I just have to changed the date manually.
Posted
Guru

AndyGable said
BruceSteers said
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.
Thanks Bruce I shall try that. Worse case is I just have to changed the date manually.
you're welcome
I tried it , it works a treat
Got it down to a one liner
Code (gambas)
- '
- 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 changes
the 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
Posted
Guru

Thanks Bruce I shall try that. Worse case is I just have to changed the date manually.
No need. Try this code: -
Code (gambas)
My text program printed TestNew V0.0.6 Created: - 24/02/2021 14:38
EDIT
I see Bruce pipped me to the post, but my version does look for the actual executable and puts the date in world format.
Posted
Enthusiast

cogier said
Thanks Bruce I shall try that. Worse case is I just have to changed the date manually.
No need. Try this code: -Code (gambas)
I have just tried this and I get a error "Unexpected 'Application' in frmSplash.Class:15 any idea what this means
Posted
Guru

I have just tried this and I get a error "Unexpected 'Application' in frmSplash.Class:15 any idea what this means
Please post your program, so we can see what happens.
Posted
Enthusiast

Code
' Gambas class file
Public Sub Form_Open()
Me.labApplicationVersion.Text = "Application Version : " & Application.Version
getBuildDate
End
Private Sub getBuildDate()
Dim sText As String = "no "
Dim spath As String = Application.Path & "/" Application.Name & ".Gambas"
If Exist(sPath) Then sPath = Format(Stat(sPath).LastModified, DD dd mmm yyyy)
Me.labBuildDate.Text = Build Date: " & " sText
End
That is my code from the application
Posted
Guru

1/. When posting code use the 'gb' button, it's much nicer
2/. &/ is a powerful command that sorts out if you need, or don't need, a slash in the path. The following will work sPath = "/usr/" &/ "/bin/" &/ "/amidi"
3/. Dim spath As String = Application.Path & "/" Application.Name & ".Gambas", You changed "gambas" to "Gambas". The file ending is ".gambas"
4/. Me.labApplicationVersion.Text, just labApplicationVersion.Text will do.
5/. If Exist(sPath) Then sPath = Format(Stat(sPath).LastModified, DD dd mmm yyyy). The DD dd mmm yyyy needs to be in inverted commas "DD dd mmm yyyy" and sPath needs to be sText
6/. Me.labBuildDate.Text = Build Date: " & " sText. Again "Me." is not required, and you have got your inverted commas muddled.
Try this: -
Code (gambas)
- getBuildDate
- labBuildDate.Text = "Build Date: " & sText
Posted
Enthusiast

Thanks so much for sorting my code I am still finding myself working in VB.net (as I am porting my application across from that to Gambas)
I use to work in VB6 for a long time and then moved to vb.net I should have moved to Gambas then but for some reason I moved to .NET (big mistake) now I am getting my head around Gambas I really like it
on the date side is it possible to have it show like
Monday 1st February 2021 and not Monday 1 February 20201?
Posted
Guru

AndyGable said
…on the date side is it possible to have it show like
Monday 1st February 2021 and not Monday 1 February 20201?
The quick answer is yes, but you need to create the code to do it. Try this: -
Code (gambas)
1 guest and 0 members have just viewed this.



