Auto increment version string

Auto increment version string

1
NewbieNewbie
1

    May 04, 2011#1

    hello there,

    is there a way so that UE will insert an autoincrement version string into my code and keep incrementing it each time I save the file ... but I would need that feature to be working from multiple hosts ... be it via a .ini file within the same directory keeping track of the filename->version mappings or whatever ...

    6,606548
    Grand MasterGrand Master
    6,606548

      May 04, 2011#2

      That can be down either with a script or a macro.

      There is the possibility to set a macro to be executed on every save. The name of the macro file and the name of the macro to be executed on every save is stored in uedit32.ini.

      Disadvantages of macro solution: No support for variables and therefore the version increment is harder to implement. Macros can't remember current position of the caret to restore it after updating the version string before saving the file. So on every file save the current caret position is lost and caret is at version string. A workaround would be to temporarily insert a special string at current position in file, insert/update the version string and use a single replace command to remove the special string and set caret back to the previous position. But that workaround results in additional undo steps.

      Advantage of macro solution: Macro is executed on every file Save and Save As and Save All, even when saving a file on close.


      A script can't be executed on every file save. Therefore using a script to insert or auto increment a version string requires that saving of files is always done by hotkey, the hotkey for the script. Save As with inserting a version string or resetting current version string to initial value requires also the execution of another script by hotkey making this change on file content before opening the Save As dialog. And last a third script would be necessary as replacement for Save All command.

      Disadvantages of script solution: Requires 3 scripts to replace Save, Save As and Save All commands. Requires the usage of hotkeys instead of saving the files on close, or with built-in Save, Save As or Save All commands. Closing files and confirming to save modifications does not result in updating version string.

      Advantages of script solution: Support for variables and therefore easier to realize the version increment. Can remember and restore position of caret in the file after inserting, resetting or updating the version string. Can check editing mode and restore the editing mode if necessary. You may not want to execute the version increment on modified binary files opened in hex edit mode on save. It is maybe also required for correct inserting a version string with initial value to switch from overwrite column editing mode to insert normal editing mode and you want current editing mode restored after save (script execution).


      In general it is better to use a script or macro executed by hotkey manually for updating version information and not automatically on every save. With a manually executed script/macro you have always the total control when and for which files the action is done, but of course that could mean also that you can forget to execute once the script/macro although the version string should be updated.