Automatic versioning

Everything else that doesn't fall into one of the other PB categories.
User avatar
jacdelad
Enthusiast
Enthusiast
Posts: 418
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Automatic versioning

Post by jacdelad »

Hello,
ist there a feature or tool for automatic versioning the file attributes? I can set them manually in the project options, but I need to do this for every release...and every build (x86,x64 and again with the c compiler), which is a bit annoying.
PureBasic 6.0/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800+/32GB RAM/Radeon 7770 OC/3TB SSD/70TB HDD
Synology DS920+/20GB RAM/38TB
User avatar
Tenaja
Addict
Addict
Posts: 1890
Joined: Tue Nov 09, 2010 10:15 pm

Re: Automatic versioning

Post by Tenaja »

There's a constant that automatically increments if you use a project. I don't recall if it's also saved in non-project files. (There's some data appended to your file that's visible if you open it in e.g. notepad.)

I think if you search version in help you might find it. Otherwise, look for the list of constants.
User avatar
jacdelad
Enthusiast
Enthusiast
Posts: 418
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: Automatic versioning

Post by jacdelad »

Yeah, I know that and can use them both in my program, but I mean the version information that I put into "compiler options" -> "version info" on the project tab.

Edit: I just saw, that it support %compilecount and %buildcount, but I still have to enter the version information (e.g. "1.1") 5 times.
PureBasic 6.0/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800+/32GB RAM/Radeon 7770 OC/3TB SSD/70TB HDD
Synology DS920+/20GB RAM/38TB
Axolotl
Enthusiast
Enthusiast
Posts: 191
Joined: Wed Dec 31, 2008 3:36 pm

Re: Automatic versioning

Post by Axolotl »

This information are stored at the end of a pb file (as comments or a separate cfg file, or ...) this depends on your preference settings.
I am pretty sure that you can read this information with i.e. an different editor (notepad2, notepad++).
Maybe you can copy paste them to your new files....
If that works with the notepad's you can create a small tool for doing the trick as you like it...
just some thought on it
Mostly running PureBasic <latest stable version and current alpha/beta> (x64) on Windows 10 Home
Marc56us
Addict
Addict
Posts: 1292
Joined: Sat Feb 08, 2014 3:26 pm

Re: Automatic versioning

Post by Marc56us »

jacdelad wrote: Thu Aug 04, 2022 3:55 pm Yeah, I know that and can use them both in my program, but I mean the version information that I put into "compiler options" -> "version info" on the project tab.
As long as you have entered the information (in cCompiler/Projet options), you can retrieve it.

Code: Select all

Debug "#PB_Editor_BuildCount                : " + #PB_Editor_BuildCount 
Debug "#PB_Editor_CompanyName               : " + #PB_Editor_CompanyName        
Debug "#PB_Editor_CompileCount              : " + #PB_Editor_CompileCount       
Debug "#PB_Editor_Email                     : " + #PB_Editor_Email              
Debug "#PB_Editor_FileDescription           : " + #PB_Editor_FileDescription
Debug "#PB_Editor_FileVersion               : " + #PB_Editor_FileVersion        
Debug "#PB_Editor_FileVersionNumeric        : " + #PB_Editor_FileVersionNumeric
Debug "#PB_Editor_InternalName              : " + #PB_Editor_InternalName       
Debug "#PB_Editor_LegalCopyright            : " + #PB_Editor_LegalCopyright     
Debug "#PB_Editor_LegalTrademarks           : " + #PB_Editor_LegalTrademarks
Debug "#PB_Editor_OriginalFilename          : " + #PB_Editor_OriginalFilename
Debug "#PB_Editor_PrivateBuild              : " + #PB_Editor_PrivateBuild       
Debug "#PB_Editor_ProductName               : " + #PB_Editor_ProductName        
Debug "#PB_Editor_ProductVersion            : " + #PB_Editor_ProductVersion     
Debug "#PB_Editor_ProductVersionNumeric     : " + #PB_Editor_ProductVersionNumeric
Debug "#PB_Editor_ReadOnly                  : " + #PB_Editor_ReadOnly   
Debug "#PB_Editor_SpecialBuild              : " + #PB_Editor_SpecialBuild       
Debug "#PB_Editor_Website                   : " + #PB_Editor_Website    
Debug "#PB_Editor_WordWrap                  : " + #PB_Editor_WordWrap   
But as they are constants, the reverse is (unfortunately) not possible.

In project mode, it is possible to modify them because the Project file (*.pbp) is an XML, but I did not test if it is possible to modify it when it is already opened by the IDE
I will test it, because I'm interested and I also tend to write my version information at the top of the main source code.
(Just before the indispensable, great EnableExplicit that doesn't waste hours anymore because of a typing error.)

:wink:
English is not my native language.
PB Latest version - Win 10 family x64 - Linux Debian, Slackware (VirtualBox & WSL) / W10 - Raspberry Raspbian
Intel i7-8700 CPU @ 3.20GHz - 48 GB - Nvidia RTX 3050 OC 8GB - Asus VP348 3440 x 1440 - DPI 100%
User avatar
blueb
Addict
Addict
Posts: 963
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: Automatic versioning

Post by blueb »

jacdelad wrote: Thu Aug 04, 2022 3:38 pm Hello,
ist there a feature or tool for automatic versioning the file attributes? I can set them manually in the project options, but I need to do this for every release...and every build (x86,x64 and again with the c compiler), which is a bit annoying.
I think you might be looking for this... I found it a long time ago (JackWebb's info) and it works for what I need:

Code: Select all

;==================================================================
; VersionTest.pb
; ------------------
; Author:    JackWebb     
; Date:      March 17th, 2014, 9:25 am
;
; Explain:   Add file VERSION information to your programs       
;==================================================================

;  First - go to Compiler Options > Contants tab

;  Then  - Check #PB_Editor_CompileCount and #PB_Editor_BuildCount

;  Got to 'Custom Constant' and add:  #Version = 1.0.   and set it (note: including the period at the end).
;  Make sure your new constant is checked.

; --------------------- <<< Optional >>> ----------------------------------------------------------------------------

; Add #version (as above) but leave it blank
; Add name of your program here (with space behind it) as in:
;   #version = "myMasterpiece "  

MessageRequester("Version Numbers", #version + Str(#pb_editor_buildcount) + "." + Str(#pb_editor_compilecount), #PB_MessageRequester_Ok )
- It was too lonely at the top.

Current Machine: Win 10 Pro 64-bit, AMD Ryzen 9 5900X, 64 gigs ram, Geforce GTX 1660 Ti w/6 gigs ram
Axolotl
Enthusiast
Enthusiast
Posts: 191
Joined: Wed Dec 31, 2008 3:36 pm

Re: Automatic versioning

Post by Axolotl »

You can do this for any new file you are creating by the following steps:
Use Menu "File | Preferences ..."
In Dialog "Preferences" look at "Compiler - Defaults"

Default Settings for new Files
[X] #PB_Editor_CompileCount
[X] #PB_Editor_BuildCount

imho #PB_Editor_CreateExecutable not necessary, because NOT #PB_Compiler_Debugger supports the same behavior.

Here is how I do it most of the time...

I define this constants in my main source code file.

Code: Select all

#ProgramName           = "__Program_Template_Name__" 
;ProgramDescription    = "__A_brief_description_of_the_application__" 
;ProgramMajorVer       = "1."              ; "" is possible -- Major Version number ==>  <MajorVer>.<BuildCount>.<CompileCount> 
;ProgramAuthor         = "AHa" 
;ProgramType           = "Freeware"       ; PizzaWare, BeerWare, etc.  
;ProgramRelease        = ""               ; "alpha beta gamma delta omega " 

; next two constants must be defined in the main source file 
; internally used in INCLUDE files according to the specific main source file 
#MainSourcePath        = #PB_Compiler_FilePath ; this kept the file directory (path) of the main source 
#MainSourceName        = #PB_Compiler_Filename ;  -"-          file name  -"- 
I use a CommonCode.pbi file with a lot of little helper functions and this contants (related to the topic)
As you can see, i define my own constants for file-dependent constants, so that I can access my main file in the included files.

Code: Select all

; --- Define some default constant values --- 
CompilerIf Not Defined(ProgramDescription, #PB_Constant) : #ProgramDescription = "App in Test Mode" : CompilerEndIf 
CompilerIf Not Defined(ProgramMajorVer, #PB_Constant)    : #ProgramMajorVer    = "0."               : CompilerEndIf 
CompilerIf Not Defined(ProgramAuthor, #PB_Constant)      : #ProgramAuthor      = "AHa"              : CompilerEndIf 
CompilerIf Not Defined(ProgramType, #PB_Constant)        : #ProgramType        = "Noneware"         : CompilerEndIf 
CompilerIf Not Defined(ProgramRelease, #PB_Constant)     : #ProgramRelease     = "test"             : CompilerEndIf 

;/---------------------------------------------------------------------------------------------------------------------
;| Fix Program Constants -- based on #ProgramXxxx from Main Source 
;\---------------------------------------------------------------------------------------------------------------------
#ProgramVersion        = #ProgramMajorVer + #PB_Editor_BuildCount + "." + #PB_Editor_CompileCount  ; #PB_Editor_BuildCount, #PB_Editor_CompileCount from main source 
#ProgramCompiled       = 1970 + (#PB_Compiler_Date / 31536000)                                     ; works for the YEAR 
#ProgramCopyright      = "Copyright (c) " + #ProgramCompiled + " by " + #ProgramAuthor             ; 

#Caption               = #ProgramName + " " 
#MainCaption           = #Caption + #ProgramVersion + " " 
#ToolCaption           = "[" + Chr($2261) + "] " + #ProgramName + " "  ; [≡] .. Hamburger style // nice Idea for ToolWindows (without Icons in the Titlebar 

;// Single Application 
#ProgramInstance       = "Mx" + #ProgramName + #PB_Editor_CompileCount  ; make a precise mutex name, #PB_Editor_CompileCount from main source 
;// Application specific Hotkey 
#ProgramHotkeyPrefix   = "Hk" + #ProgramName   ; Prefix for global program hotkey 

;;#CurrentCompilerVersion = 600    ; set to the compiler you use ( 
Mostly running PureBasic <latest stable version and current alpha/beta> (x64) on Windows 10 Home
User avatar
jacdelad
Enthusiast
Enthusiast
Posts: 418
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: Automatic versioning

Post by jacdelad »

I may be blind, but all these ideas don't solve my problem.
I have this tab in the compiler settings in the project:
Image
and I want to automatically set file version, product version (both twice) and file description. These information is also displayed in the Windows Explorer when using tileview. I have to change it every time I update the program (4 times) or the explorer will show an old version. I can use placeholders, but they are very limited.
PureBasic 6.0/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800+/32GB RAM/Radeon 7770 OC/3TB SSD/70TB HDD
Synology DS920+/20GB RAM/38TB
Axolotl
Enthusiast
Enthusiast
Posts: 191
Joined: Wed Dec 31, 2008 3:36 pm

Re: Automatic versioning

Post by Axolotl »

Have you tried my ideas from my first anwer?
Change the stored settings and check results in Dialog. Maybe I try it next time, when i am back at my computer.
Last edited by Axolotl on Sat Aug 06, 2022 12:42 pm, edited 1 time in total.
Mostly running PureBasic <latest stable version and current alpha/beta> (x64) on Windows 10 Home
Axolotl
Enthusiast
Enthusiast
Posts: 191
Joined: Wed Dec 31, 2008 3:36 pm

Re: Automatic versioning

Post by Axolotl »

As promised, here are my further findings that confirm what I have written so far.
The file related settings including the Versions-Info can be stored in different places.
You can change this location by doing the following changes on the settings.

Code: Select all

;| Settings : Menu "File|Preferences..." 
;| Preferences 
;|   Editor 
;|   Save Settings to [The end of the Source file] 
;|                    [The file <filename>.pb.cfg] 
;|                    [A common file project.cfg for erery directory] 
;|                    [Dont't save anything] 
The <filename>.pb.cfg is an ASCII file with windows ini syntax (key = value).
With 'The end of the Source file' the IDE is cutting these information off. Any other editor is showing the comment lines.
Editing this information leads to new information in the ide after reload the file.
You can do it on the temp output file with the help of an IDE-tool for example. Help says that the settings information are always stored in the tempfile even if the preferences are set to different option
Further information you will find in the open source ide code. Especially SourceManagement.pb will show you the way it is done.

Anyways, this is a small code (proof of concept) to show the settings at the end of the specified file.

Code: Select all

EnableExplicit 
Define Source$ ; use this file 
Define Line$, Found, bom  ; helper 

If OpenConsole() 
  If Source$ = "" : Source$ = ProgramParameter() : EndIf 
; If Source$ = "" : Source$ = "" : EndIf 
  Debug Source$ 
  PrintN("Show Settings of '" + Source$ + "'")  
  If Source$ And ReadFile(1, Source$) 
    If ReadStringFormat(1) = #PB_Ascii : bom = #PB_Ascii 
    Else                               : bom = #PB_UTF8 
    EndIf
    Found = #False 
    While Not Eof(1)  
      Line$ = ReadString(1, bom) 
      If Not Found And Left(Line$, 26) = "; IDE Options = PureBasic " ; 6.00 LTS (Windows - x64) 
        Found = #True 
      EndIf 
      If Found 
        PrintN(Line$) 
      EndIf
    Wend 
    CloseFile(1) 
  EndIf
  PrintN("") 
  PrintN("Press ENTER to exit the console.") 
  Input() 
  CloseConsole() 
EndIf

BTW: I love the simplicity of the pb implementation so far and I hope it stays that way.
Happy coding and stay heathy.
Mostly running PureBasic <latest stable version and current alpha/beta> (x64) on Windows 10 Home
Post Reply