GordonFreeman Posted March 5, 2014 Share Posted March 5, 2014 Hi guys! I need to copy the array returned by inireadsection to another array that will keep all information IniFile looks (test.ini): [test1] 1=test11 2=test12 3=test13 [test2] 1=test21 2=test22 3=test23 How can i do it? I think the other array like how: Global $aData[2][3] Frabjous Installation Link to comment Share on other sites More sharing options...
kylomas Posted March 6, 2014 Share Posted March 6, 2014 Are you saying that you want to copy each section as a row and each key as a column of each row? Like... col[0] col[1] col[2] row [0] - test1 test11 test12 test13 row [1] - test2 test21 test22 test23 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
GordonFreeman Posted March 6, 2014 Author Share Posted March 6, 2014 (edited) Yes. but col 0 start with test1 and test2 / in row 0 & 1 by example: Global $aData[2][3]=[["test11","test12","test13"],["test21","test22","test23"]] I can do it with for but i not think if is a fatest / better way Edited March 6, 2014 by GordonFreeman Frabjous Installation Link to comment Share on other sites More sharing options...
kylomas Posted March 6, 2014 Share Posted March 6, 2014 (edited) Using an ini file that looks like this... [test1] 1=test11 2=test12 3=test13 [test2] 1=test21 2=test22 3=test23 [test3] 1=test31 2=test32 3=test33 4=test34 5=test35 I'm using "for..to" loops like this... #include <array.au3> local $inifile = @scriptdir & '\test.ini' local $aSect = inireadsectionnames($inifile), $aTmp ; defiine result array - rows = number of sections, columns = 1 local $aData[ubound($aSect)-1][1] ; loop through sections reading each for $1 = 1 to $aSect[0] $aTmp = inireadsection($inifile,$aSect[$1]) if @error then ConsoleWrite('ini file read section error = ' & @error & @LF) Exit endif ; redefine # of columns if section contains more than currently defined if ubound($aTmp) > ubound($aData,2) then redim $aData[ubound($aData)][ubound($aTmp)] ; set row to section name $aData[$1-1][0] = $aSect[$1] ; loop through section key/values pairs populating result array with "value" for $2 = 1 to $aTmp[0][0] $aData[$1-1][$2] = $aTmp[$2][1] next Next _arraydisplay($aData) Are you saying that this is not fast enough? kylomas edit: ambiguous comment Edited March 6, 2014 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
jchd Posted March 6, 2014 Share Posted March 6, 2014 Just copy the array by assigning it to another variable: Local $aSectionread = IniReadSection(...) Local $aSDup = $aSectionRead 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...
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