d0n Posted July 22, 2009 Share Posted July 22, 2009 When i run the script, it will show me the array when it hits arraydisplay, but when i try to write the array into a txt file i get this error C:\Program Files\AutoIt3\Include\File.au3 (279) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: If FileWrite($hFile, $a_Array[$x] & @CRLF) = 0 Then If FileWrite($hFile, ^ ERROR Dim $aINI = IniReadSection($Log, 'Name') For $i = 1 To $aINI[0][0] For $j = 1 To $aINI[0][0]-$i If Int($aINI[$j+1][1]) > Int($aINI[$j][1]) Then Local $sTemp = $aINI[$j][1] $aINI[$j][1] = $aINI[$j+1][1] $aINI[$j+1][1] = $sTemp Local $sTemp1 = $aINI[$j][0] $aINI[$j][0] = $aINI[$j+1][0] $aINI[$j+1][0] = $sTemp1 EndIf Next Next _ArrayDisplay($aINI) _FileCreate(@ScriptDir&"\Output.txt") _FileWriteFromArray(@ScriptDir&"\Output.txt", $aINI, 1) MsgBox("","",@error) Link to comment Share on other sites More sharing options...
Developers Jos Posted July 22, 2009 Developers Share Posted July 22, 2009 What are your expectations of the outcome of this: $a_Array[$x] & @CRLF ? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
d0n Posted July 22, 2009 Author Share Posted July 22, 2009 something like this, i used the copy selected from _ArrayDisplay [0]|22| [1]|Fire |185927 [2]|You |145960 [3]|Dragon Frost |65 Link to comment Share on other sites More sharing options...
Beege Posted July 22, 2009 Share Posted July 22, 2009 _Filewritefromarray() doesn't support multi-dimensional arrays. Heres two functions I use when reading and writing 2 dimensional arrays to file. Try using them. Func _FileWriteFrom2dArray($sFilePath, ByRef $avArray) Local $sStr, $hFile, $iRow, $iCol For $iRow = 0 To (UBound($avArray, 1) - 1) For $iCol = 0 To UBound($avArray, 2) - 1 $sStr &= $avArray[$iRow][$iCol] & '|' Next $sStr = StringTrimRight($sStr, 1) $sStr &= @CRLF Next $hFile = FileOpen($sFilePath, 2) FileWrite($hFile, $sStr) FileClose($hFile) Return EndFunc ;==>_Filewritefrom2dArray Func _FileReadTo2dArray($sFilePath, ByRef $aArray) Local $hFile, $iRow, $iCol, $aLocal[1], $aStr _FileReadToArray($sFilePath, $aLocal) If UBound($aLocal) = 1 Then SetError(1) Return EndIf $aStr = StringSplit($aLocal[1], "|") ReDim $aArray[$aLocal[0]][$aStr[0]] For $iRow = 1 To $aLocal[0] $aStr = StringSplit($aLocal[$iRow], "|") For $iCol = 1 To UBound($aArray, 2) $aArray[$iRow - 1][$iCol - 1] = $aStr[$iCol] Next Next Return EndFunc ;==>_FileTo2dArray Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator 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