computergroove Posted August 10, 2014 Share Posted August 10, 2014 (edited) Ini file: 12345=file1.avi 23456=file2.avi 34567=file3.avi My current code: _FileReadToArray($DBLocation,$DBArray,4);Reads ini file to to 1d array seperated line by line with a crlf For $i = 1 To Ubound($DBArray) $Temp = StringSplit($DBArray[$i],"=",1) _ArrayAdd($DB2DArray,$Temp[$i]) _ArrayDisplay($DB2DArray) Next I want to put the splitstring from the ini file into the top line of the array. So the top line of $DB2DArrray[1] will be 12345 in the first column and file1.avi in the second column Whats the best way to do this? Edited August 10, 2014 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 10, 2014 Moderators Share Posted August 10, 2014 computergroove,As long as the file only contains lines in the "xxx=yyy" format you can do it very easily: #include <Array.au3> #include <File.au3> ; Define variable Local $aSplitArray ; Split array when reading - define delimiter to use _FileReadToArray($sIni, $aSplitArray, $FRTA_NOCOUNT, "=") ; Display result _ArrayDisplay($aSplitArray, "Split", Default, 8)If there are other lines in the file you will need to take another route. 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...
computergroove Posted August 10, 2014 Author Share Posted August 10, 2014 (edited) What is $sIni? I have between 1 and 5000 lines like 12345=file1.avi. I want them all to be read into an array. Column 1 will be 12345 and column 2 will be file1.avi. Edited August 10, 2014 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 10, 2014 Moderators Share Posted August 10, 2014 computergroove,$sIni is the path to the ini file you said you wanted to read. I have between 1 and 5000 linesThat is not the question I asked. The code I suggested will only work if there all lines in the file are in the "xxx=yyy" format - the number of lines does not matter. If you have any lines which do not have that format then you will have to use another technique - most probably something along the lines of the code in the OP. 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...
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