Page 1 of 1
Count the times that the program has been built.
Posted: Fri Jul 11, 2003 2:39 pm
by Johan_Haegg
One thing i realy would like to see in PureBasic might be quite easy to code into the compiler.
Each time a program is built, when the compiler is checking stuff like ; ExecuteableFormat = Whatever, let it add one to something lite ; Build = X
and put a #Build.l = X at the beginning of the source (only in compiler, not in source-file)
Version is for the user to decide, but its a pain trying to remember the times you have built the program.
Ok, it might get ugly if someone uses the good old trial and error technique, but for those who write serious programs in PureBasic, writeing a few hundred lines of code between the debuging sessions its nice to know (and show) what build the end-user is using.
OT:
If i get a bunch of Euros left from my vacations, its going directly to Fred, i ran into the limit today and im getting tired of people whineing about the Debug-box.

Posted: Fri Jul 11, 2003 4:13 pm
by freak
I know it is not quite the same, but to clearly identify each build, you
could also use the time of compilation.
The compiler stores it in the #PB_Compiler_Date constant. It is the kind
of date format you can use with all the Date functions.
Timo
Posted: Tue Jul 29, 2003 2:16 pm
by Johan_Haegg
Well, that works to, but as you said, it is not quite the same.
#PB_Compiler_Build would be nice and easy to implement.
Posted: Tue Jul 29, 2003 2:52 pm
by Inner
I wrote something to handle this, compiler it as an exe and build a batch file or something inbetween, and bobs your ucle.
Code: Select all
; PureBasic Visual Designer v3.70a
;- Window Constants
;
#WINBUMP = 0
;- Gadget Constants
;
#Gadget_0 = 0
;-----------------------------------------------------------------------------
; Title : Bump Revsion
; Code : T.J.Roughton
; Version : 0.1
; Comment : Compiling World.c fatal expection
;-----------------------------------------------------------------------------
IncludeFile "_bumpversion.pb"
Declare Open_WINBUMP()
Structure PARAM
cmd.s
action.s
EndStructure
NewList cmdline.PARAM()
Dim cvtable.s(64)
Global numlabellines
Global majver
Global minver
Global revver
Global betaver
Global alphaver
Global build
Global bumpvers.s
Declare ParameterPhase()
Declare Info()
Declare WriteVersion(filename.s)
Declare ReadVersion(filename.s)
Declare BumpVersion()
readcvtable.s=""
Restore codevertable_bb
While readcvtable<>"-1"
Read readcvtable
cvtable(i)=readcvtable : i=i+1
Wend
numlabellines=i-2
Open_WINBUMP()
Info()
ParameterPhase()
;Repeat
; EventID.l = WaitWindowEvent()
; If EventID = #PB_Event_CloseWindow ; If the user has pressed on the close button
; Quit = 1
; EndIf
;Until Quit = 1
;
;-----------------------------------------------------------------------------
;
;-----------------------------------------------------------------------------
Procedure ParameterPhase()
param.s=" "
While param<>""
AddElement(cmdline())
param=ProgramParameter()
cmdline()\cmd=param
cmdline()\action=ProgramParameter()
Wend
ResetList(cmdline())
bump=#FALSE : mode=#FALSE : load=#FALSE
While NextElement(cmdline())
;AddGadgetItem(#Gadget_0,0,("CMD: "+cmdline()\cmd)
;AddGadgetItem(#Gadget_0,0,("ACT: "+cmdline()\action)
If(cmdline()\cmd="-i")
infile.s=cmdline()\action
load=#TRUE
EndIf
If(cmdline()\cmd="-b")
bumpvers=cmdline()\action
bump=#TRUE
EndIf
If(cmdline()\cmd="-m")
If(cmdline()\action="c")
Restore codevertable_c
AddGadgetItem(#Gadget_0,0,"Output C Source")
mode=#TRUE
EndIf
If(cmdline()\action="bb")
Restore codevertable_bb
AddGadgetItem(#Gadget_0,0,"Output Blitz Basic Source")
mode=#TRUE
EndIf
If(cmdline()\action="pb")
Restore codevertable_pb
AddGadgetItem(#Gadget_0,0,"Output Pure Basic Source")
mode=#TRUE
EndIf
EndIf
Wend
If mode=#TRUE
readcvtable.s=""
While readcvtable<>"-1"
Read readcvtable
cvtable(i)=readcvtable : i=i+1
Wend
numlabellines=i-2
Else
AddGadgetItem(#Gadget_0,0,"Output Blitz Basic Source")
EndIf
If load=#TRUE
ReadVersion(infile)
EndIf
If bump=#TRUE
BumpVersion()
WriteVersion(infile)
EndIf
EndProcedure
;-----------------------------------------------------------------------------
;
;-----------------------------------------------------------------------------
Procedure Info()
AddGadgetItem(#Gadget_0,0,"-----------------------------------------------------------------------------")
AddGadgetItem(#Gadget_0,0," Bump Revision v"+_FullVer+" "+_CompileTime+" "+_CompileDate)
AddGadgetItem(#Gadget_0,0,"-----------------------------------------------------------------------------")
AddGadgetItem(#Gadget_0,0," Written By T.J.Roughton (A.K.A) Inner (FREEWARE)")
AddGadgetItem(#Gadget_0,0," -i [file] : Input Version File ")
AddGadgetItem(#Gadget_0,0," -r mnrbai : Reset Version Value")
AddGadgetItem(#Gadget_0,0," -b mnrbai : Bump Version +1")
AddGadgetItem(#Gadget_0,0," -m mode : Output Code Style [default bb]")
AddGadgetItem(#Gadget_0,0," bb = Blitz Basic Source")
AddGadgetItem(#Gadget_0,0," pb = Pure Basic Source")
AddGadgetItem(#Gadget_0,0," c = C Source")
AddGadgetItem(#Gadget_0,0,"")
EndProcedure
;-----------------------------------------------------------------------------
;
;-----------------------------------------------------------------------------
Procedure BumpVersion()
If(Mid(bumpvers,1,1)="1")
majver=majver+1
EndIf
If(Mid(bumpvers,2,1)="1")
minver=minver+1
EndIf
If(Mid(bumpvers,3,1)="1")
revver=revver+1
EndIf
If(Mid(bumpvers,4,1)="1")
betaver=betaver+1
EndIf
If(Mid(bumpvers,5,1)="1")
alphaver=alphaver+1
EndIf
If(Mid(bumpvers,6,1)="1")
build=build+1
EndIf
EndProcedure
;-----------------------------------------------------------------------------
;
;-----------------------------------------------------------------------------
Procedure ReadVersion(filename.s)
If(ReadFile(0,filename)<>0)
While Eof(0)=0
ln.s=ReadString()
If(Mid(ln,0,1)<>";")
For i=0 To numlabellines
If(FindString(ln,cvtable(i),0)>0)
foundtablab=i
EndIf
ln=RemoveString(ln,cvtable(i),1)
Next
Select foundtablab
Case 0
majver=Val(ln)
Case 1
minver=Val(ln)
Case 2
revver=Val(ln)
Case 3
betaver=Val(ln)
Case 4
alphaver=Val(ln)
Case 5
build=Val(ln)
EndSelect
EndIf
Wend
CloseFile(0)
Else
WriteVersion(filename)
EndIf
EndProcedure
;-----------------------------------------------------------------------------
;
;-----------------------------------------------------------------------------
Procedure WriteVersion(filename.s)
If(CreateFile(0,filename)<>0)
WriteStringN(";-----------------------------------------------------------------------------")
WriteStringN("; Bump Revision ")
WriteStringN(";-----------------------------------------------------------------------------")
WriteStringN(cvtable(0)+Str(majver))
WriteStringN(cvtable(1)+Str(minver))
WriteStringN(cvtable(2)+Str(revver))
WriteStringN(cvtable(3)+Str(betaver))
WriteStringN(cvtable(4)+Str(alphaver))
WriteStringN(cvtable(5)+Str(build))
_fullver.s=Str(majver)+"."+Str(minver)+"."+Str(revver)+"."+Str(betaver)+"."+Str(alphaver)+" Build "+Str(build)
WriteStringN(cvtable(6)+Chr(34)+_fullver+Chr(34))
_midver.s=Str(majver)+"."+Str(minver)+"."+Str(revver)+"."+Str(betaver)+" Build "+Str(build)
WriteStringN(cvtable(7)+Chr(34)+_midver+Chr(34))
_smlver.s=Str(majver)+"."+Str(minver)+" Build "+Str(build)
WriteStringN(cvtable(8)+Chr(34)+_smlver+Chr(34))
WriteStringN(cvtable(9)+Chr(34)+FormatDate("%dd/%mm/%yy",Date())+Chr(34))
WriteStringN(cvtable(10)+Chr(34)+FormatDate("%hh:%ii:%ss",Date())+Chr(34))
CloseFile(0)
EndIf
EndProcedure
;-----------------------------------------------------------------------------
;
;-----------------------------------------------------------------------------
Procedure Open_WINBUMP()
If OpenWindow(#WINBUMP, 305, 258, 428, 129, #PB_Window_SystemMenu | #PB_Window_TitleBar , "Bump Revision v"+_FullVer)
If CreateGadgetList(WindowID())
ListViewGadget(#Gadget_0, 5, 5, 420, 120)
AddGadgetItem(#Gadget_0,0,"FOO")
EndIf
EndIf
EndProcedure
;-----------------------------------------------------------------------------
;
;-----------------------------------------------------------------------------
DataSection
codevertable_c:
Data.s "#Define _MAJORVERSION "
Data.s "#Define _MINORVERSION "
Data.s "#Define _REVISION "
Data.s "#Define _BETA "
Data.s "#Define _ALPHA "
Data.s "#Define _BUILD "
Data.s "#Define _FULLVER "
Data.s "#Define _MIDVER "
Data.s "#Define _SMLVER "
Data.s "#Define _COMPILEDATE "
Data.s "#Define _COMPILETIME "
Data.s "-1"
codevertable_bb:
Data.s "Global _MajorVersion :_MajorVersion="
Data.s "Global _MinorVersion :_MinorVersion="
Data.s "Global _Revision :_Revision="
Data.s "Global _Beta :_Beta="
Data.s "Global _Alpha :_Alpha="
Data.s "Global _Build :_Build="
Data.s "Global _FullVer$ :_FullVer$="
Data.s "Global _MidVer$ :_MidVer$="
Data.s "Global _SmlVer$ :_SmlVer$="
Data.s "Global _CompileDate$ :_CompileDate$="
Data.s "Global _CompileTime$ :_CompileTime$="
Data.s "-1"
codevertable_pb:
Data.s "Global _MajorVersion :_MajorVersion="
Data.s "Global _MinorVersion :_MinorVersion="
Data.s "Global _Revision :_Revision="
Data.s "Global _Beta :_Beta="
Data.s "Global _Alpha :_Alpha="
Data.s "Global _Build :_Build="
Data.s "Global _FullVer.s :_FullVer.s="
Data.s "Global _MidVer.s :_MidVer.s="
Data.s "Global _SmlVer.s :_SmlVer.s="
Data.s "Global _CompileDate.s :_CompileDate.s="
Data.s "Global _CompileTime.s :_CompileTime.s="
Data.s "-1"
EndDataSection
Posted: Mon May 22, 2006 12:05 pm
by Bonne_den_kule
Would be nice with a such constant
Posted: Wed May 24, 2006 5:37 am
by Anden
Yes, this is a minimum requirement for a compiler.
Simple workaround: Use jaPBe, it's already built in there (#jaPBe_ExecuteBuild)
Posted: Thu May 25, 2006 9:41 am
by blueznl
codecaddy

Posted: Sun Apr 22, 2007 6:48 pm
by Bonne_den_kule
A #PB_Compiler_Build would be nice.
Posted: Sun Apr 22, 2007 7:27 pm
by AND51
I agree. But this can only be done when the source code has been saved. (The number of compilations can be saved at the end of the file by the IDE).
Re: Count the times that the program has been built.
Posted: Sun Apr 22, 2007 7:33 pm
by Derek
Johan_Haegg wrote:Ok, it might get ugly if someone uses the good old trial and error technique, but for those who write serious programs in PureBasic, writeing a few hundred lines of code between the debuging sessions its nice to know (and show) what build the end-user is using.
That's my approach and that means I would be on build 257.42 before my program is released to the one person I wrote it for.

Posted: Sun Apr 22, 2007 7:46 pm
by GeoTrail
I agree, good idea

Posted: Sun Apr 22, 2007 7:53 pm
by Derek
Don't get me wrong, I think it is a good idea and I do wonder where these great 'build 1.03.05' numbers come from.
What confuses me is what constitutes a build?
Is ironing out a few bugs a new build or is implementing a new routine, which has no effect on the overall look of the program at the user level, a new build?