maniootek Posted April 11 Share Posted April 11 Is it possible that SciTE editor will add version number like: ;Version: 1.001 MyFunc() Func MyFunc() MsgBox(0,0,"Hello World!") EndFunc and increase that number every time I edit/save the script? Sometimes I need to compare my backup script file with current version and I want to know how many times it was changed. Link to comment Share on other sites More sharing options...
Nine Posted April 11 Share Posted April 11 #AutoIt3Wrapper_Res_Fileversion=1.0.0.1 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y Compile every time you want the version to change... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
maniootek Posted April 11 Author Share Posted April 11 7 minutes ago, Nine said: Compile every time you want the version to change... thank you but I do not compile scripts. I "run" them, any idea? Link to comment Share on other sites More sharing options...
Nine Posted April 11 Share Posted April 11 #AutoIt3Wrapper_Res_Fileversion=1.0.0.2 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #AutoIt3Wrapper_Run_After=del %out% Compile, it auto-deletes the .exe, you just need run it after...It is like pressing a key to update the version (ctrl-f7) and one other key to run (f5) “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
SOLVE-SMART Posted April 11 Share Posted April 11 30 minutes ago, maniootek said: and increase that number every time I edit/save the script? Sometimes I need to compare my backup script file with current version and I want to know how many times it was changed. My suggestion is to use a version control system like Git instead of creating a backup file. So you could jump back and forth between your commits (versions) and alway could see the different changes which were made. Then you also can use Git TAGs with proper SemVer versions names. Only a suggestion to avoid manual version handling. Best regards Sven Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
Developers Jos Posted April 11 Developers Share Posted April 11 (edited) 58 minutes ago, maniootek said: thank you but I do not compile scripts. I "run" them, any idea? So what exactly would be the trigger to update the variable? ... Save is an option, but that will increment the version very fast. ... and the simple way obviously is to write a small script and update the existing variable, similar to autoit3wrapper.au3 and connect that to a Shortcut so SciTE can run that for any script. ... or write your own LUA function for that in SciTE. Edited April 11 by 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 More sharing options...
Developers Jos Posted April 11 Developers Share Posted April 11 (edited) So just for the heck of it: the full SciTE4AutoIt3 comes with a PersonalTools.lua in the %localappdata%\AutoIt v3\SciTE, so this is an example LUA function how you could update the version on each save, when it is found in the source file: -- Update version of line with this format: -- ;Version: 1.001 -- on each save function PersonalTools:OnBeforeSave(path) if editor.Lexer == SCLEX_AU3 and path ~= "" then local spos, epos = editor:findtext('^\\s*;Version:\\s*[\\d\\.]*', SCFIND_REGEXP, 0) if spos then local dline = editor:textrange(spos, epos) local curversion = dline:match('Version:%s*([%d%.]*)') newversion = curversion + 0.001 editor:SetSel(spos, epos) editor:ReplaceSel(";Version: " .. string.format("%.3f", newversion)) end end end Over to you to modify it to your wishes. Edited April 12 by Jos fixed path maniootek and ioa747 2 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 More sharing options...
maniootek Posted April 12 Author Share Posted April 12 (edited) 16 hours ago, Jos said: So just for the heck of it: the full SciTE4AutoIt3 comes with a PersonalTools.lua in the %localuserdata%\AutoIt v3\SciTE, so this is an example LUA function how you could update the version on each save, when it is found in the source file: -- Update version of line with this format: -- ;Version: 1.001 -- on each save function PersonalTools:OnBeforeSave(path) if editor.Lexer == SCLEX_AU3 and path ~= "" then local spos, epos = editor:findtext('^\\s*;Version:\\s*[\\d\\.]*', SCFIND_REGEXP, 0) if spos then local dline = editor:textrange(spos, epos) local curversion = dline:match('Version:%s*([%d%.]*)') newversion = curversion + 0.001 editor:SetSel(spos, epos) editor:ReplaceSel(";Version: " .. string.format("%.3f", newversion)) end end end Over to you to modify it to your wishes. thank you @Jos for taking the time to help me, I just love you 😍 It works ! by the way, this is the path to that file in my computer (%localuserdata% seems to be not valid environment variable) Quote %localAppData%\AutoIt v3\SciTE\PersonalTools.lua Edited April 12 by maniootek Link to comment Share on other sites More sharing options...
maniootek Posted April 15 Author Share Posted April 15 I have one issue with this feature. Now when I run script from SciTE then my cursor jump to the beginning of the code to change the Version number. Is it possible that cursor stay in the place or jump back? Link to comment Share on other sites More sharing options...
ioa747 Posted April 15 Share Posted April 15 https://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/Lua/SciTE%20Pane%20API.htm My first .lua commands -- Update version of line with this format: -- ;Version: 1.001 -- on each save function PersonalTools:OnBeforeSave(path) if editor.Lexer == SCLEX_AU3 and path ~= "" then local spos, epos = editor:findtext('^\\s*;Version:\\s*[\\d\\.]*', SCFIND_REGEXP, 0) if spos then local dline = editor:textrange(spos, epos) local curversion = dline:match('Version:%s*([%d%.]*)') local cpos = editor.CurrentPos -- Sets the position of the caret. newversion = curversion + 0.001 editor:SetSel(spos, epos) editor:ReplaceSel(";Version: " .. string.format("%.3f", newversion)) editor:GotoPos(cpos) -- Set caret to a position and ensure it is visible. end end end maniootek and mLipok 2 I know that I know nothing Link to comment Share on other sites More sharing options...
Developers Jos Posted April 15 Developers Share Posted April 15 2 hours ago, maniootek said: I have one issue with this feature. This is not a feature, but rather an example for you to play with. So change the script so it does exactly what you want it to do. The documentation about the SciTE LUA functions are in the Helpfle. ... and as you can see by the last reply: Even somebody that never used LUA scripts before can do it when you put your mind to it and do a little bit of searching! 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 More sharing options...
maniootek Posted April 15 Author Share Posted April 15 27 minutes ago, Jos said: This is not a feature, but rather an example for you to play with. So change the script so it does exactly what you want it to do. The documentation about the SciTE LUA functions are in the Helpfle. ... and as you can see by the last reply: Even somebody that never used LUA scripts before can do it when you put your mind to it and do a little bit of searching! Yes. Now I have speficication and example I can work on. Anyway, I don't understand the specification fully (even if I translate it to my language). Lua syntax is also something new for me. Now I tried to fix one more issue with that code. Now my script version is increasing every save and cursor stays in the line I was working on but my code jump as the page is scrolled. I tried to fix it by finding some function which can read the current scroll position and then set that position. local curscrollpos = editor.XOffset editor:LineScroll(curscrollpos, 0) but it does not work Link to comment Share on other sites More sharing options...
Developers Jos Posted April 15 Developers Share Posted April 15 (edited) What about this version: -- Perform before each save function PersonalTools:OnBeforeSave(path) local VersionPrefix = ";Version:" -- define the prefix for version line. needs to be the first string on a line if editor.Lexer == SCLEX_AU3 and path ~= "" then -- find version prefix in sourcecode local spos, epos = editor:findtext('^\\s*' .. VersionPrefix .. '\\s*[\\d\\.]*', SCFIND_REGEXP, 0) -- Update when found if spos then local dline = editor:textrange(spos, epos) -- get the text found local curversion = dline:match(VersionPrefix .. '%s*([%d%.]*)') -- retrive portion containing the number local orgpos = editor.CurrentPos -- save current pos local firstvisible = editor.FirstVisibleLine -- save first visible line of script olen = epos - spos -- calculate length of found version string local newversion = VersionPrefix .. string.format(" %.3f", curversion + 0.001) nlen = newversion:len() -- calculate length of new version string editor:SetSel(spos, epos) -- Set text to replace editor:ReplaceSel(newversion) -- replace old version string with new if epos <= editor.CurrentPos then editor:GotoPos(orgpos) -- set caret back to saved pos when we were before the xhanged text else editor:GotoPos(orgpos + nlen - olen) -- set caret back to saved pos when we were after the changed text end editor.FirstVisibleLine = firstvisible -- reset first visible line of script end end end Edited April 15 by Jos ioa747 and maniootek 2 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 More sharing options...
maniootek Posted April 15 Author Share Posted April 15 6 minutes ago, Jos said: What about this version: YES! This works perfect now! So detailed example, again thank you so much! FirstVisibleLine is the code I needed. ioa747 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now