Iczer Posted September 21, 2014 Share Posted September 21, 2014 (edited) Script Breaking Changes is the pain especially when you scripts are big. I wanted some automation to process 3.3.10.2 --> 3.3.12.0+ so i write this. I'm do not use Excel UDF, but other than it, function that needed correction was only "_ArrayUnique" from Array UDF... Am I right? Or there are more to it? Also maybe someone can make additions to script expandcollapse popup;============================================================================================== ;#AutoIt3Wrapper_Autoit3Dir=C:\Program Files (x86)\AutoIt3\autoit-v3.3.13.19-beta #AutoIt3Wrapper_Autoit3Dir=C:\Program Files (x86)\AutoIt3\autoit-v3.3.12.0 ;#AutoIt3Wrapper_Autoit3Dir=C:\Program Files (x86)\AutoIt3\autoit-v3.3.10.2 ;============================================================================================== #include <Array.au3> #include <File.au3> ;============================================================================================== Local $sFunctionNames = "_ArrayUnique" Global $aFunctionNames = StringSplit($sFunctionNames,"|") Local $aOriginalScript, $n = 0,$sSuggestedChange = " --- " ;============================================================================================== Local $sOriginalScriptPath, $aOriginalScriptPath $sOriginalScriptPath = FileOpenDialog("Choice file to scan","","(*.au3)",3) $aOriginalScriptPath = StringSplit($sOriginalScriptPath,"|") ;============================================================================================== For $m = 1 To $aOriginalScriptPath[0] $sOriginalScriptPath = $aOriginalScriptPath[$m] ConsoleWrite("*au3 file : "&StringRegExpReplace($sOriginalScriptPath,'^.*\\',"")& @crlf) $sOriginalScriptEncoding = FileGetEncoding($sOriginalScriptPath) $hOriginalScript = FileOpen($sOriginalScriptPath,$sOriginalScriptEncoding) $aOriginalScript = FileReadToArray($hOriginalScript) FileClose($hOriginalScript) ;============================================================================================== For $i = 0 To UBound($aOriginalScript)-1 If StringRegExp($aOriginalScript[$i],StringReplace($sFunctionNames,"|","\h*?\(|")&"\h*?\(",0) And Not StringRegExp($aOriginalScript[$i],"\h*?\;.+",0) Then ConsoleWrite("String Number = "&$i+1& @crlf) SubFunction__GetCorrection($aOriginalScript[$i],$sSuggestedChange) ConsoleWrite("Original String : "&StringStripWS($aOriginalScript[$i],3)& @crlf) ConsoleWrite("Suggested change : "&StringStripWS($sSuggestedChange,3)& @crlf&@crlf&@crlf) $n += 1 EndIf Next ;---------------------------------------------------------------------------------------------- ConsoleWrite("*au3 file : ----------------------------------------------------------------------------------------------"& @crlf) Next ConsoleWrite("Number of changes = "&$n& @crlf) Exit ;============================================================================================== Func SubFunction__GetCorrection($sOriginalScriptLine, ByRef $sSuggestedChange) $sSuggestedChange = "" For $i = 1 To $aFunctionNames[0] If StringRegExp($sOriginalScriptLine,$aFunctionNames[$i],0) Then $sSuggestedChange = Call("SubFunction_GetCorrection_"&$aFunctionNames[$i],$sOriginalScriptLine) Return EndIf Next EndFunc ;---------------------------------------------------------------------------------------------- Func SubFunction_GetCorrection__ArrayUnique($sOriginalScriptLine) Local $sNewFunc = "" If Not StringRegExp($sOriginalScriptLine,"_ArrayUnique\h?\([^\(\)]+?\)",0) Then Return " -???- " Local $sOrigFunc = StringRegExpReplace($sOriginalScriptLine,"(.*?_ArrayUnique\h?\()([^\(\)]+?)(\).*)","$2") ConsoleWrite("$sOrigFunc Arguments = "&$sOrigFunc& @crlf) Local $aOrigFunc = StringSplit($sOrigFunc,",") If $aOrigFunc[0] > 1 Then $aOrigFunc[2] &= " - 1" For $i = 1 To $aOrigFunc[0] $sNewFunc &= $aOrigFunc[$i] & "," Next $sNewFunc = StringTrimRight($sNewFunc,1) ConsoleWrite("$sNewFunc Arguments = "&$sNewFunc& @crlf) $sNewScriptLine = StringReplace($sOriginalScriptLine,$sOrigFunc,$sNewFunc) Return $sNewScriptLine EndFunc ;---------------------------------------------------------------------------------------------- Edited September 21, 2014 by Iczer Link to comment Share on other sites More sharing options...
cal Posted September 23, 2014 Share Posted September 23, 2014 I have not looked at your code. Just want to comment then wait for the powers that be to comment. A script that fixes others with your intent has been done before several years back on a major update and it was a godsend. So I hope this goes just as well if needed. I just updated autoit last night, I was not aware of the script breaking stuff. Hm... I've peeked at it just now and it seems extensive. I have a couple major Excel scripts for work but its only a small handful. I was also still learning it so I'm not to concerned about looking them over. I'm sure the new stuff will help with alot of the limitations I had run into. The Array UDF on the other hand. ......... really. I think every 4th line in pretty much all my scripts deal with arrays in some way or another. Everything will be broken. I'm just glad I only updated my home computer so far. That would have been bad if I had done the work one. I'll have to compile a bunch of existing stuff so things still work on it and then I will make mods as I go. I agree that 2D stuff was missing from most things. To the point where I have a couple UDFs that I wrote that have several functions to deal with 2D stuff that I use all the time. Having the experts redo that stuff is good. I just hope I survive the changeover. But before I go looking through all my scripts I want to ask a quick question. I looked at the list of functions that have had changes to them but it does not tell me if its a script breaking change or not. Is there a list of functions that are broken if unchanged in our scripts. For example the first one on the list says. _ArrayAdd Now supports 2D arrays and can add multiple lines in one call. This tells me it has new functionality. But does it still work as it was? I can learn the new stuff as I go. But what I think would be useful for people is a list of functions that we need to go look at right now to make our scripts work again. If the new functionality is from new parameters on the end but the existing ones still work as is, then this function is not broken, its just better. I can check out the new stuff as needed. If on the other hand, the order of the existing parameters has changed, or one is inserted/removed in the existing parameters then this is a function that will break my scripts and I need to go look at it first. Looking at the script above its just _ArrayUnique as far as the array UDF is concerned. But I doubt that's the case or there would not be all the warnings I now see. It would have been just a "hey look out for this one function" note instead. Is there a short list of functions that will break existing scripts that we should be looking at first? ... My first note that something was wrong tonight. A warning mesg that a file did not properly delete and that it would wait till the file was no longer in use before continuing. Nothing odd till I realized that usually this is caused by my backup kicking in and locking the file. However, I set the backup to run later at night instead of continuously a few days ago. It should not have the file in use at the moment. I discovered a couple of archive directories for tvshows suddenly got emptied. A bit of further looking and it seems I have a script where _ArrayUnique should be retuning a list of files to delete from a source directory is instead returning the list of destination directories where the files should have been moved to. A list that then got used by a delete command. It removed the files fine but could not remove the directory, so it thought my backup was currently using it and patiently kept trying. Thank goodness for backups so I was able to restore the missing files. Another example. I'm guessing _arraydisplay has changed but not in a breaking way. I have a function that calls _arraydisplay and then resizes the internal cols and window size to center and display a nicer layout based on content. Sort of calling itself as well to get around the fact that _arraydisplay halts the original script while its showing. This still works, but it now has a couple extra buttons on the bottom. so this would be an example of a changed but non script breaking function and so NOT on the short list I'm looking for. Link to comment Share on other sites More sharing options...
jchd Posted September 23, 2014 Share Posted September 23, 2014 Is it really that hard to read the script-breaking part of the release notes? Help file > Appendix > History / ChangeLog > hit link History IMPORTANT: See here for recent script-breaking changes. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 23, 2014 Moderators Share Posted September 23, 2014 cal, The Array UDF on the other hand. ......... really.In the Help file for v3.3.12.0 we tell you straight off (you even get shown this during the install):Changed: Re-wrote Array UDF to add 2D support and add some functions. THIS IS A SCRIPT BREAKING CHANGE.And then you can find on the History page: Script Breaking Changes in Recent VersionsThis page contains a list of all changes made in recent updates that will almost certainly break existing scripts. Please read this list carefully when upgrading if you have not been keeping up with developments in the beta versions. If any of these issues affect you then you will need to modify your scripts.1st June, 2014 - v3.3.12.0UDFs:[...]•Array UDF was re-written. Functions and/or parameters have been changed, removed or added. A detailed list can be found here.[...]Clicking on the link takes you to this page which sets out in detail exactly what changed.How much more do you expect us to do? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 23, 2014 Moderators Share Posted September 23, 2014 I will never understand the complaining that goes along with each release. Changes to the core language (any language), always come with growing pains. Don't like the changes? Stick with Java 1.3.1_08, C# 3.0, or AutoIt 3.3.8.1. But your unwillingness to put forth the effort to keep up to speed hurts only yourself and your own efforts at coding. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
cal Posted September 23, 2014 Share Posted September 23, 2014 (edited) Wow. ok. I think you guys misread my intent. Whos complaining? I even say more then once that I'm sure the updates will be a good thing. I did read those pages. My example was even from that page. That page may say script breaking changes across the top but a quick look shows that is not the case with every function listed. Its a page of all the changes we need to be aware of. I was simply wondering if there was a short list of just the actual breaking ones. Now that I'm at work and have my old help file let me look at that same one using my old help file vs the new help file thats online I will try to be more clear as obviously I was not the first time. for example. _arrayadd. looking at both help files. I see it returns the index of the last added item. the First parameter is a reference array and the second parameter is a value. This is the same for both versions. The error codes are different but I'm not concerned about that at the moment. The new ones value can still be a single value like the old version so there is nothing breaking there. The new ones value can also be a delimited string or an array. Great. thats new but has no effect on a script expecting a single value. The new one can also take additional parameters to do other things. Great.... I'd call that an enhanced function. Not a script breaking one. I'm all for it. As an enhanced but not script breaking, this function would not be on the short list I was asking about. If there is no such list then that is fine. I will create it so I know what I need to fix to make my old scripts work before I go back and look at the full list and the enhancements. Of course thats just the first one and I'm gong by just the help notes. I will have to test that before I add or do not add it to my short list. Again.... Updates are good. It was a simple question that I think was misunderstood. No complains here. As far as effort..... so I don't post my stuff here often. I'm not known here. There are people who do know my work. Lack of effort is not an issue. Cal. Edited September 23, 2014 by cal 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