Modify

Opened 13 years ago

Closed 13 years ago

#2150 closed Bug (Duplicate)

_FileWriteFromArray() 2d array bug

Reported by: i2c Owned by:
Milestone: Component: Standard UDFs
Version: 3.3.8.0 Severity: None
Keywords: _FileWriteFromArray Cc:

Description

Dim $aArray[2][2] = [[1, 2],[3, 4]]
_FileWriteFromArray(@ScriptDir & "\aArray.txt", $aArray, 0, 0, "|")
C:\Program Files (x86)\AutoIt3\Include\File.au3 (272) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$s_Temp &= $s_Delim & $a_Array[$x][$y]
$s_Temp &= $s_Delim & ^ ERROR

Line 271 to 274 of File.au3:

For $y = 1 To $iDims
					$s_Temp &= $s_Delim & $a_Array[$x][$y]
				Next

In case we want to write a 2d array to a file, we already know, that we have 2 dimensions at this point cause the dimension count is saved in $iDims. It's not necessary to run this for loop cause $y can only be 1 furthermore $iDims is 2 so we will run into an error.

Solution:

For $y = 1 To $iDims - 1
					$s_Temp &= $s_Delim & $a_Array[$x][$y]
				Next

or better remove the loop and do the following

 For $x = $i_Base To $i_UBound
                $s_Temp = $a_Array[$x][0] & $s_Delim & $a_Array[$x][1]
                If FileWrite($hFile, $s_Temp & @CRLF) = 0 Then

Attachments (0)

Change History (2)

comment:2 Changed 13 years ago by Valik

  • Resolution set to Duplicate
  • Status changed from new to closed

Closing as a duplicate of #2125.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.