Jump to content

Auto Increment file version value each time when Scite "Go" script


Recommended Posts

Ok I see. I will share my story why I need it.

I never compile my scripts to exe because my scripts are shared via google drive with others. If I would use compiled exe file then I would have problems with synchronization when I want to modify it as some others could use that file at the time. This is why I use some exe launcher instead which use AutoIt3.exe and au3 file as a parameter to run. This way I always can modify au3 file without synchronization issues.

For now I use variable "Global $g_ScripVersion = 1.0" but I forget to increase it when I making some changes

Edited by maniootek
Link to comment
Share on other sites

9 minutes ago, Subz said:

After you've made changes, just compile the script, it will change the version number in the script, you then just upload the au3 script to Google Drive.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Fileversion=1.0.0.1
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

 

Yes I know this option and I have tried it but it's not what I mean. This way I have to remember to compile a script that I never normally do.

Link to comment
Share on other sites

Don't really understand since if others run the script it will also auto increment the count, the only way I can think of doing it, would be something like:

Global $g_ScripVersion = 1.1
_VersionUpdate()

Func _VersionUpdate()
    If @UserName = "maniootek" Then
        ;~ Backup your script first
        FileCopy(@ScriptFullPath, @ScriptDir & "\Backup\" & @YEAR & @MON & @MDAY & "_" & @ScriptName, 9)
        ;~ Replace the version number
        $sScript = StringReplace(FileRead(@ScriptFullPath), "$g_ScripVersion = " & Round($g_ScripVersion, 1), "$g_ScripVersion = " & Round($g_ScripVersion + .1, 1))
        ;~ Open the Script
        FileOpen(@ScriptFullPath, 2)
        ;~ Rewrite the updated Script
        FileWrite(@ScriptFullPath, $sScript)
        FileClose(@ScriptFullPath)
    EndIf
EndFunc

 

Link to comment
Share on other sites

  • Developers

Something like this could do that for you:

#AutoIt3Wrapper_Icon=test.gif
#AutoIt3Wrapper_Res_Fileversion=1.2.3.11
OnAutoItExitRegister("Update_Version")

ConsoleWrite("...end of script" & @CRLF)

Func Update_Version()
    $ToTalFile = FileRead(@ScriptFullPath)
    $CurVersion = StringRegExpReplace($ToTalFile, '(?ims).*?#AutoIt3Wrapper_Res_Fileversion\h*?=\h*?(\S*).*+', '$1')
    $verseg = StringSplit($CurVersion, ".")
    $NewVersion = ""
    For $x = 1 To $verseg[0]
        ; add 1 to last number in version
        If $x = $verseg[0] Then $verseg[$x] += 1
        If $x > 1 Then $NewVersion &= "."
        $NewVersion &= $verseg[$x]
    Next
    $ToTalFile = StringRegExpReplace($ToTalFile, '(?i)#AutoIt3Wrapper_Res_Fileversion\h*?=\h*?' & $CurVersion, '#AutoIt3Wrapper_Res_Fileversion=' & $NewVersion)
    $H_Outf = FileOpen(@ScriptFullPath, 2)
    FileWrite($H_Outf, $ToTalFile)
    FileClose($H_Outf)
EndFunc   ;==>Update_Version

 

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

22 hours ago, Subz said:

Don't really understand since if others run the script it will also auto increment the count

Yes, you are right. This is why I am looking for other solution than you and @Jos suggested.

Users who use my scripts don't use Scite but the launcher. I am also using scripts with the launcher.
I want increase the script version only when I modify the code with Scite for example.

Link to comment
Share on other sites

  • Developers
21 minutes ago, maniootek said:

Yes, you are right. This is why I am looking for other solution than you and @Jos suggested.

Users who use my scripts don't use Scite but the launcher. I am also using scripts with the launcher.
I want increase the script version only when I modify the code with Scite for example.

Just add a test to the logic for something that identifies it is you ...  this really can't be that hard. ;) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

22 minutes ago, Danp2 said:

Maybe you could check the parent process that launched Autoit. If your launcher app, do nothing. If Scite, then increment your script version.

I know what you mean. This is good idea. Later I will check it

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...