dave12077 Posted May 31, 2018 Share Posted May 31, 2018 Just curious to see if any one else has run into this issue. When creating list of index, to insert items at in _ArrayInsert, all the indexes have to be the same number of digits or i.t fails with @error = 3 If you set the range to 3;5;7 it works, if its set to 10,15,17 it works, if you set it to 3;15;17 fails if you set it to 03,15,17 it works. Here is an example that shows this. expandcollapse popup; have the same issues when running on ; AutoIT Version 3.3.14.5 ; AutoIT Beta Version 3.3.15.0 #include <Array.au3> Local $aTest[151]=[] For $i = 0 To 150 $aTest[$i] = 'Line_' & $i Next ; this works - @error = 0 Local $sIdx = '3;5;7;9' _ArrayInsert($aTest, $sIdx, 'Added Item 1|Added Item 2|Added Item 3|Added Item 4') MsgBox($MB_OK, 'Example 1', '_ArrayInsert returned error : ' & @error & @CRLF & 'with $sIdx = ' & $sIdx) ; this works - @error = 0 $sIdx = '13;15;17;19' _ArrayInsert($aTest, $sIdx, 'Added Item 1|Added Item 2|Added Item 3|Added Item 4') MsgBox($MB_OK, 'Example 2', '_ArrayInsert returned error : ' & @error & @CRLF & 'with $sIdx = ' & $sIdx) ; this does not work - @error = 3 $sIdx = '3;5;17;19' _ArrayInsert($aTest, $sIdx, 'Added Item 1|Added Item 2|Added Item 3|Added Item 4') MsgBox($MB_OK, 'Example 3', '_ArrayInsert returned error : ' & @error & @CRLF & 'with $sIdx = ' & $sIdx) ; this works - @error = 0 $sIdx = '03;05;17;19' _ArrayInsert($aTest, $sIdx, 'Added Item 1|Added Item 2|Added Item 3|Added Item 4') MsgBox($MB_OK, 'Example 4', '_ArrayInsert returned error : ' & @error & @CRLF & 'with $sIdx = ' & $sIdx) ; this does not work - @error = 3 $sIdx = '13;15;107;109' _ArrayInsert($aTest, $sIdx, 'Added Item 1|Added Item 2|Added Item 3|Added Item 4') MsgBox($MB_OK, 'Example 5', '_ArrayInsert returned error : ' & @error & @CRLF & 'with $sIdx = ' & $sIdx) ; this works - @error = 0 $sIdx = '013;015;107;109' _ArrayInsert($aTest, $sIdx, 'Added Item 1|Added Item 2|Added Item 3|Added Item 4') MsgBox($MB_OK, 'Example 6', '_ArrayInsert returned error : ' & @error & @CRLF & 'with $sIdx = ' & $sIdx) ; this does not work - @error = 3 $sIdx = '3;15;107;109' _ArrayInsert($aTest, $sIdx, 'Added Item 1|Added Item 2|Added Item 3|Added Item 4') MsgBox($MB_OK, 'Example 7', '_ArrayInsert returned error : ' & @error & @CRLF & 'with $sIdx = ' & $sIdx) ; this works - @error = 0 $sIdx = '003;015;107;109' _ArrayInsert($aTest, $sIdx, 'Added Item 1|Added Item 2|Added Item 3|Added Item 4') MsgBox($MB_OK, 'Example 8', '_ArrayInsert returned error : ' & @error & @CRLF & 'with $sIdx = ' & $sIdx) Xandy 1 Link to comment Share on other sites More sharing options...
TheXman Posted May 31, 2018 Share Posted May 31, 2018 (edited) I think you may have found a bug. The @error = 3, in this case, is because it thinks that the indexes are out of order. It thinks that because it is doing string compares instead of numeric compares. If line #623, in the array.au3, is changed to look like the line below, it works fine. If Number($vRange[$i]) < Number($vRange[$i - 1]) Then Return SetError(3, 0, -1) Edited May 31, 2018 by TheXman Xandy 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 31, 2018 Moderators Share Posted May 31, 2018 dave12077, TheXman is correct - the dreaded "different datatype comparison" bug strikes again! I cannot believe that no-one has run into this problem before - it seems very few people ever use this function with multiple range elements. M23 Xandy 1 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...
dave12077 Posted May 31, 2018 Author Share Posted May 31, 2018 Thanks guys, I made had already made a work around by padding the number with the proceeding 0's. I will also make the change in array.au3 file. I have used _ArrayInsert before to insert a single items with no issues I just happened to run across it because I have an array of data, that the user as the option to save to a file using _FileWriteFromArray, and i wanted to add some blank lines at certain locations to make the output file easier to read. so i had a loop that went through the data and if certain conditions were met to build a string like 3;5;7;9 ... etc so i could add the blank lines before writing it to a file. I thought there for a minute I was going crazy, when it was telling me that 3;5;11 was not in order. lol. Glad it is something easily fixed in one line of code. Thanks again guys. 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