Search the Community
Showing results for tags 'My brain hurts'.
-
Hi all I've been working around my lack of understanding of arrays for a while now, but it is starting to irk me that I don't know why certain things give me errors. Take the below function from a program I have written. Func _Do_Reporting($type) ; 0 = Screen report ; 1 = Excel report local $arArray[25][14],$iRows,$iColumns for $index = 6 to 0 step -1 if GUICtrlRead($Report[$index])=$GUI_CHECKED Then exitloop EndIf Next if $index = 6 Then $rSQL = "SELECT * FROM et WHERE Sched_imp_date LIKE """ & GUICtrlRead($Date7) & """;" else $rSQL = "SELECT * FROM et WHERE Status = " & $index & ";" EndIf $iRval= _Sql_GetTable2D($hDBHandle,$rSQL,$arArray,$iRows,$iColumns) if $iRval <> $SQL_OK then Msgbox(0 + 16 +262144,"Error","Unable to retrieve audit data") Return EndIf for $cntr = 1 to $iRows $arArray[$cntr][5]=_Fix_Date($arArray[$cntr][5]) for $newcntr = 8 to 12 $arArray[$cntr][$newcntr]=_Fix_Date($arArray[$cntr][$newcntr]) Next $sSQL = "SELECT status " & _ "FROM xstudio_db.table_defect_integrated " & _ "WHERE defect_id = " & $arArray[$cntr][1] & ";" $iRval = _SQL_QuerySingleRow($xDBHandle, $sSQL, $aResult) $arArray[$cntr][13] = $aResult ; <- gets an array out of range error here Next if $type = 0 then _ArrayDisplay($arArray) Else $sFilePath = @TempDir & "\Temp.xls" If Not _FileCreate($sFilePath) Then MsgBox(4096, "Error", " Error Creating File - " & @error) return 1 EndIf _ExcelBookOpen($sFilePath) $oExcel = _ExcelBookAttach("Temp.xls", "FileName") _ExcelWriteSheetFromArray($oExcel, $arArray, 1, 1, 0, 0) EndIf EndFunc (omg, what happened to the formatting!?!? Anway, I shall fix the formatting after I post) I'm confused as to why I get an array error in the line indicated above. I tried locally dimensioning the array via dim $arArray[25][14], but I get the same result. Obviously my understanding of arrays is flawed but I have been unable to figure out where. Previously I just worked around this sort of issue but now I want to really understand it. Clark