AndyS01

_ArrayAdd() function not compatable with old version

8 posts in this topic

I just updated to the newest version of AutoIT and when I add a line of text containing "|" characters to my array using _ArrayAdd(), the array ends up with each element containing a part of my string broken at "|".
 
So, if I had a string like "A|B|C|D", and I did an _arrayAdd($ar, "A|B|C|D), my array then contains 6 elements:
[0] = 5
[1] = A
[2] = B
[3] = C
[4] = D
 
I see that the calling syntax in the old AutoIT version is quite different than the new syntax:
old:
_ArrayAdd(ByRef $avArray, $vValue)
 
new:
_ArrayAdd ( ByRef $aArray, $vValue [, $iStart = 0 [, $sDelim_Item = "|" [, $sDelim_Row = @CRLF [, $hDataType = 0]]]] )
 
The new syntax is not backwards compatible.
 
Sample code:
#include <Array.au3>
global $ar, $str, $outstr = ""

$str = "A|B|C|D"
$ar = stringsplit("","")

_ArrayAdd($ar, $str)

$outstr &= ubound($ar) & @crlf
for $x = 0 to ubound($ar) - 1
     $outstr &= $ar[$x] & @CRLF
Next

msgbox(0, "INFO", $outstr)
New Version info: Version 3.4.4   Jul 13 2014 20:07:38
 
Old Version info: Version 3.3.6    Dec 30 2013 15:53:31

 

Share this post


Link to post
Share on other sites



What you posted is the version of SciTE.

I assume you installed the latest AutoIt version 3.3.12.0.

The Array UDF has been rewritten, the following page describes the (script breaking) changes that have been made.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

AndyS01,

This has been brought up and discussed before. We write the change logs to help when updating, so it pays to read them - especially when we advise that the changes are "script-breaking". :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
I did read the release notes.  I saw that it was a script breaker but it looked like it just had additional parameters, but this is more than that.  The problem is that I have lots of source files in my library that are now broken.  I thought of creating a wrapper around _ArrayAdd() where I do a string replace of "|" characters with another replacement character/string, but the replacement character might be in the caller's string.   Also, the function hardcodes the delim char as "|", but if the system default char is something else(Opt("GUIDataSeparatorChar")), the function fails. You can't really depend on not having a string that might have several special characters.
 
(Please look at BrewManNH's comments (Posted 02 June 2014 - 04:29 PM) about this here: '?do=embed' frameborder='0' data-embedContent>>)
 
Further checking of the new library UDFs, I see more things that are deal breakers.  The real deal breaking problem is that the compiler doesn't get an error when calling _ArrayAdd(), _ArrayInsert(), etc. with old syntax.  If the delim parameters were made to be required, then I would get compiler errors if I try to use them with the old parameters.
 
My only resolution is to go back to 3.3.10.2.  It's a bummer because I won't be able to use 3.3.12.0 and above, so I'll miss out on any fixes from now on.
 
I don't understand the cavalier attitude with "script breaker" code.  If I were coding these new UDFs, if there were additional parameters and not using them would make the function produce unexpected behavior, I would make the new parameters mandatory so the user would get errors when using the old function calls.
 

Share this post


Link to post
Share on other sites
My only resolution is to go back to 3.3.10.2.

 

 

you can also just keep an old version of the array UDF...   I keep it because I have a boner for arrayswap


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

AndyS01,

We had 2 threads running when the Array library was being rewritten - no-one mentioned any problem with the new parameters at any time. We wrote a detailed changelog when the new code was released and explained carefully that certain functions in the library had been seriously amended - we even added a specific page to the Help file to detail these changes. So I totally reject the "cavalier attitude" insult you threw at us (or rather me since I rewrote this particular library) - where were you when all the public consultation was happening?. :huh:

The Array library has become much more flexible, and able to deal with 1D and 2D arrays, and all it requires is small amount of re-coding to make old scripts compatible. And if you think this is a disaster, how on earth did you manage when all the includes were split in 3.2.12.0? Anyway, if you are going to revert to an earlier AutoIt version because of this pretty small change, then you do not deserve to benefit from any future improvements and certainly have no sympathy from me. ;)

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
I apologize, perhaps cavalier was a little too strong.  I appreciate the time that you took to do all of this work :)   However, these changes marked "SCRIPT BREAKING" are not small changes.  For instance, in order to use my functions that use _ArrayAdd(), I'm going to have to write a 'wrapper' function that adds a dummy string to the caller's array, then replaces that added element with the caller's string.
like this:
func _myArrayAdd(byref $ar, $sStr)
    _ArrayAdd($ar, "~HELLOWWORLD~")
    $ar[UBound($ar)-1] = $sStr
endfunc

Then I would have to change every occurrence of _ArrayAdd in my source files, with calls to _myArrayAdd().  I searched all of my AutoIT source files and there were more than 780 files with 1 or more calls to _ArrayAdd()!!

I have not checked how many of my files contain the other calls to "SCRIPT BREAKING" changes

 
As a developer, it would make sense that if a UDF has "SCRIPT BREAKING" changes, the function would make the first added parameter mandatory. Then I would get compile errors when using these functions, forcing me to fix my code.  That way, I would not have to fix my already released scripts until I'm actually going to change them to fix bugs or add features.
 
I started using AutoIT with version 3.3.10.2, so 3.3.12.0 is the first update I had to do.  Now that I know how to adjust for new releases, it will be a lot easier.
 
As to "where were you when all the public consultation was happening?", how do I know when these changes were out for review?  Is there a mailing list?

Share this post


Link to post
Share on other sites

This changes have been discussed on this forum.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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

  • Similar Content

    • kcvinu
      By kcvinu
      Hi all,
      How to add 2 elements to a 2D array. This is my code, But not working.
      Local $ResArray[0][1] ; Declaring an empty array Local $Elem1 = 10 Local $Elem2 = 20 _ArrayAdd($ResArray, $Elem1, 0) ; Trying to add first column _ArrayAdd($ResArray, $Elem2, 1) ; Trying to add second column _ArrayDisplay($ResArray) This will only add the first element. 
    • Tardis
      By Tardis
      Hi all Im still New To Autoit and would realy like some help ...

      I have gone through some examples and other code on the forum but now I am stuck
      see comments on what I want to do .
      #RequireAdmin #include <IE.au3> #include <MsgBoxConstants.au3> #include <File.au3> #include <String.au3> #include <Array.au3> Global $oIE = _IECreate("https://www.harryhomers.org/et/forum/viewtopic.php?f=89&t=4309", 0, 0, 1, 0) Global $oElements = _IETagNameAllGetCollection($oIE) Global $oID = _IEGetObjById($oIE, "p41827") Global $ListArray[1] #cs ; the list I want to get is 1 - 20 max 30 and there names . The DIV ID is p41827 <div class="content">HarryHomers can be found at 85.236.100.205:<span style="font-weight: bold">27960</span><br /><br /><ul>HH Bot Multi campaign **<br /><br />1. NAME 1<br />2. NAME 2<br />3. NAME 3<br />4. NAME 4<br /> 5. NAME 5<br />6. NAME 6<br />7. NAME 7<br />8. NAME 8<br />9. NAME 9<br />10. NAME 10<br />11. NAME 11<br />12. NAME 12<br />13. NAME 13<br />14. NAME 14<br /> 15. NAME 15<br />16. NAME 16<br />17. NAME 17<br />18. NAME 18<br />19. NAME 19<br />20. NAME 20<br /> </ul> #ce For $oElement in $oElements     Local $_sSourceTAG = $oElement.tagname     Local $_sSourceTEXT = $oElement.innerText     Local $_sSourceID = $oElement.id     Local $_sSourceHTML = $oElement.innerhtml     If $_sSourceID = "p41827" Then ;Test message box                 MsgBox($MB_SYSTEMMODAL, "MY TAG ID", "Innertext: "  & $_sSourceTAG & @CRLF & "id: " & $_sSourceID & @CRLF & "innerText: " & $_sSourceTEXT)                 MsgBox($MB_SYSTEMMODAL, "MY HTML", "Innerhtml: "  & "id: " & $_sSourceID & $_sSourceHTML)         $oData = _IEPropertyGet($oIE, "strong")         $Check = StringRight($oData, 11)         If $Check = "ohnDory</A>" Then ;Test message box             MsgBox($MB_SYSTEMMODAL, "SEARCH FOUND", "The characters are: " & $Check )             $ArraySplit1 = StringSplit($oData, ".")             For $ArrayItem in $ArraySplit1                 $ArrayItem = StringSplit($ArrayItem, "<BR>", 1)                 If $ArrayItem[0] > 1 Then                     If $ArrayItem[2] > 0 Then                         $ArrayItem[1] = StringStripWS($ArrayItem[1], 3)                         _ArrayAdd($ListArray, $ArrayItem[1])                     EndIf                 EndIf                 If StringInStr($ArrayItem[1], "</UL>") Then                     $POS = StringInStr($ArrayItem[1], "</UL>") - 1                     $String = StringLeft($ArrayItem[1], $POS)                     $String = StringStripWS($String, 3)                     _ArrayAdd($ListArray, $String)                 EndIf             Next         Else ; Not correct so ignore         MsgBox($MB_SYSTEMMODAL, "NOT FOUND", "The characters are: " & $Check )         EndIf     EndIf     Next     _ArrayDisplay($ListArray)     _ArrayReverse($ListArray)     _ArrayPop($ListArray)     _ArrayReverse($ListArray)     _ArrayDisplay($ListArray, "Map List Array Final View")     sleep(2500) _IEQuit($oIE) #cs ; note the html (map names) does change once a month ; save txt file #ce ;_FileWriteLog(@TempDir & "\list.txt", $ListArray)