#2125 closed Bug (Fixed)
_FileWriteFromArray crashes when writing a 2D array
| Reported by: | water | Owned by: | guinness |
|---|---|---|---|
| Milestone: | 3.3.9.1 | Component: | Standard UDFs |
| Version: | 3.3.8.0 | Severity: | None |
| Keywords: | _FileWriteFromArray | Cc: |
Description
When writing a 2D array the script crashes with error message:
Array variable has incorrect number of subscripts or subscript dimension range exceeded.
Reproducer Script:
#include <file.au3>
#include <array.au3>
Global $aTest[2][2] = 1,2],[2,3
_ArrayDisplay($aTest)
_FileWriteFromArray("C:\temp\test.log", $aTest)
The array is displayed correctly as a 2D array. But then the script crashes with:
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
Solution:
Replace line 271: For $y = 1 To $iDims
with
For $y = 0 To $iDims-1
Attachments (0)
Change History (6)
comment:1 by , 14 years ago
comment:3 by , 14 years ago
| Milestone: | → 3.3.9.1 |
|---|---|
| Owner: | set to |
| Resolution: | → Fixed |
| Status: | new → closed |
Fixed by revision [6784] in version: 3.3.9.1
comment:4 by , 13 years ago
It should be:
For $y = 0 To Ubound($a_Array)-1
otherwise not all elements of second dimension are written to the file.
comment:5 by , 13 years ago
actually this fix is more correct, because there is $s_Temp = $a_Array[$x][0]...
For $y = 1 To Ubound($a_Array)-1

Sorry, the correct solution would be: "For $y = 1 To $iDims-1"