Opened on Feb 6, 2012 at 2:36:50 PM
Closed on Feb 7, 2012 at 6:29:51 PM
Last modified on Jun 5, 2013 at 8:12:12 AM
#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:3 by , on Feb 7, 2012 at 6:29:51 PM
| 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 , on Jun 3, 2013 at 8:15:44 PM
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 , on Jun 3, 2013 at 8:30:49 PM
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"