Moderators Melba23 Posted April 17, 2011 Moderators Share Posted April 17, 2011 JAFN,Here is your original code:$FileLines = _FileCountLines($DataFileName) Global $Data[$FileLines][4] _FileReadToArray($DataFileName, $Data) ... $TempRow = StringSplit($Data[$a],"*") $Data[$a][1] = $TempRow[1]You find the number of lines and then create a 2D array $Data. But as soon as you use the same array in _FileReadToArray, AutoIt changes this to a 1D array. You then StringSplit this 1D array with the correct syntax (so it works) but then try to put the result into the original 2D array, which no longer exists.Can you see the logical fallacy in using StringSplit on $Data[$a] (1D) and then expecting to access the same array with $Data[$a][1] (2D)?Now look at the code I suggested:_FileReadToArray($DataFileName, $Lines) Global $Data[$Lines[0] + 1][4] ; Now you can declare the 2D array using the count - no need for _FileCountLines ;... $TempRow = StringSplit($Lines[$a], "*") $Data[$a][0] = $TempRow[1]Here we get our 1D $Lines array back from _FileReadToArray and then create another 2D array $Data. Now we use StringSplit on the 1D array, but put the results into the other 2D array.There are 2 arrays and so there is no problem.Has that made it clearer? Please ask if not becauue understanding arrays is fundamental to coding of any degree of complexity. Perhaps a look at the Arrays tutorial in the Wiki might be of use as well. 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...
JAFN Posted April 17, 2011 Author Share Posted April 17, 2011 *ping* I see it all now! Thanks. And on to ListViews. [size="2"]The second mouse gets the cheese[/size] 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