skybax Posted July 30, 2013 Share Posted July 30, 2013 I have found this UDF on the forum and works grate but i have hit a brick wall Func _ArrayCombine(ByRef $array1,ByRef $array2) ; Function to combine 2D arrays For $i=0 To Ubound($array2,1)-1 ReDim $array1[Ubound($array1,1)+1][4] $array1[Ubound($array1,1)-1][0]=$array2[$i][0] $array1[Ubound($array1,1)-1][1]=$array2[$i][1] $array1[Ubound($array1,1)-1][2]=$array2[$i][2] $array1[Ubound($array1,1)-1][3]=$array2[$i][3] Next EndFunc i need to combine 5 arrays and i have use this UDF like this and everything is fine till one or more arrays are nulll _ArrayCombine($aResult, $bResult) _ArrayCombine($aResult, $cResult) _ArrayCombine($aResult, $dResult) _ArrayCombine($aResult, $eResult) _ArrayDisplay($aResult) My question is how to combine my 5 arrays ( $aResult,$bResult,$cResult,$dResult,$eResult) if one or more are invalid ? Link to comment Share on other sites More sharing options...
kylomas Posted July 30, 2013 Share Posted July 30, 2013 (edited) skybax, This is one way ... code deleted .. kylomas edit: horse shit response.. Edited July 30, 2013 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
skybax Posted July 30, 2013 Author Share Posted July 30, 2013 (edited) Hi KYLOMAS, that example doesn't seem to work with multiple 2d array (my 5 arrays are 2d) expandcollapse popupCase $arata_raport_1 $SQLCode_raport_tip1 = "SELECT `Sala` , SUM(cantitate) FROM `raspandire` WHERE `data` BETWEEN '"&GUICtrlRead($data_de_la)&"' AND '"&GUICtrlRead($data_pana_la)&"'AND `Tip`=1 GROUP BY `Sala`" $TableContents_tip1 = _Query($SQLInstance,$SQLCode_raport_tip1) Global $aResult[10001][4] = [[10000, 4]] Global $iIndex With $TableContents_tip1 While Not .EOF $aResult[$iIndex][0] = "SIMM" $aResult[$iIndex][1] = .Fields("Sala").value $aResult[$iIndex][2] = .Fields("SUM(cantitate)").value*2 $aResult[$iIndex][3] = GUICtrlRead($curs_valutar)*250 $iIndex = $iIndex + 1 .MoveNext WEnd EndWith If $iIndex <>"" then ReDim $aResult[$iIndex][4] EndIf $SQLCode_raport_tip2 = "SELECT `Sala` , SUM(cantitate) FROM `raspandire` WHERE `data` BETWEEN '"&GUICtrlRead($data_de_la)&"' AND '"&GUICtrlRead($data_pana_la)&"'AND `Tip`=2 GROUP BY `Sala`" $TableContents_tip2 = _Query($SQLInstance,$SQLCode_raport_tip2) Global $bResult[10001][4] = [[10000, 4]] Global $iIndex2 With $TableContents_tip2 While Not .EOF $bResult[$iIndex2][0] = "Selector" $bResult[$iIndex2][1] = .Fields("Sala").value $bResult[$iIndex2][2] = .Fields("SUM(cantitate)").value $bResult[$iIndex2][3] = GUICtrlRead($curs_valutar)*251 $iIndex2 = $iIndex2 + 1 .MoveNext WEnd EndWith If $iIndex2 <>"" then ReDim $bResult[$iIndex2][4] EndIf $SQLCode_raport_tip3 = "SELECT `Sala` , SUM(cantitate) FROM `raspandire` WHERE `data` BETWEEN '"&GUICtrlRead($data_de_la)&"' AND '"&GUICtrlRead($data_pana_la)&"'AND `Tip`=3 GROUP BY `Sala`" $TableContents_tip3 = _Query($SQLInstance,$SQLCode_raport_tip3) Global $cResult[10001][4] = [[10000, 4]] Global $iIndex3 With $TableContents_tip3 While Not .EOF $cResult[$iIndex3][0] = "CF Card" $cResult[$iIndex3][1] = .Fields("Sala").value $cResult[$iIndex3][2] = .Fields("SUM(cantitate)").value $cResult[$iIndex3][3] = GUICtrlRead($curs_valutar)*252 $iIndex3 = $iIndex3 + 1 .MoveNext WEnd EndWith If $iIndex3 <>"" then ReDim $cResult[$iIndex3][4] EndIf $SQLCode_raport_tip4 = "SELECT `Sala` , SUM(cantitate) FROM `raspandire` WHERE `data` BETWEEN '"&GUICtrlRead($data_de_la)&"' AND '"&GUICtrlRead($data_pana_la)&"'AND `Tip`=4 GROUP BY `Sala`" $TableContents_tip4 = _Query($SQLInstance,$SQLCode_raport_tip4) Global $dResult[10001][4] = [[10000, 4]] Global $iIndex4 With $TableContents_tip4 While Not .EOF $dResult[$iIndex4][0] = "Dongle" $dResult[$iIndex4][1] = .Fields("Sala").value $dResult[$iIndex4][2] = .Fields("SUM(cantitate)").value $dResult[$iIndex4][3] = GUICtrlRead($curs_valutar)*253 $iIndex4 = $iIndex4 + 1 .MoveNext WEnd EndWith If $iIndex4 <>"" then ReDim $dResult[$iIndex4][4] EndIf $SQLCode_raport_tip5 = "SELECT `Sala` , SUM(cantitate) FROM `raspandire` WHERE `data` BETWEEN '"&GUICtrlRead($data_de_la)&"' AND '"&GUICtrlRead($data_pana_la)&"'AND `Tip`=5 GROUP BY `Sala`" $TableContents_tip5 = _Query($SQLInstance,$SQLCode_raport_tip5) Global $eResult[10001][4] = [[10000, 4]] Global $iIndex5 With $TableContents_tip5 While Not .EOF $eResult[$iIndex5][0] = "Kernel" $eResult[$iIndex5][1] = .Fields("Sala").value $eResult[$iIndex5][2] = .Fields("SUM(cantitate)").value $eResult[$iIndex5][3] = GUICtrlRead($curs_valutar)*254 $iIndex5 = $iIndex5 + 1 .MoveNext WEnd EndWith If $iIndex5 <>"" then ReDim $eResult[$iIndex5][4] EndIf _ArrayCombine($aResult, $bResult) _ArrayCombine($aResult, $cResult) _ArrayCombine($aResult, $dResult) _ArrayCombine($aResult, $eResult) _ArrayDisplay($aResult) I have pasted the full code to what im trying to do Edited July 30, 2013 by skybax Link to comment Share on other sites More sharing options...
kylomas Posted July 30, 2013 Share Posted July 30, 2013 skybax, Yes, I missed that you were combining 2D arrays. Disregard what I posted... Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
skybax Posted July 30, 2013 Author Share Posted July 30, 2013 Kylomas thank you anyway, if you have anymore ideas i will be glad to hear them Link to comment Share on other sites More sharing options...
water Posted July 30, 2013 Share Posted July 30, 2013 What do you mean by "array is null"? What do you get for ConsoleWrite(IsArray($bResult)) Replace $bResult with the name of an array that is Null. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
skybax Posted July 30, 2013 Author Share Posted July 30, 2013 What do you mean by "array is null"? What do you get for ConsoleWrite(IsArray($bResult)) Replace $bResult with the name of an array that is Null. For every one of the 5 array ($aResult,$bResult,$cResult,$dResult,$eResult) i run this in mysql with diferent values for `Tip` =1 (1 to 5) and if it dosent find anything in sql for `Tip` =1 the return from sql is empty. SELECT `Sala` , SUM( cantitate ) FROM `raspandire` WHERE `data` BETWEEN '2013-07-29' AND '2013-07-29' AND `Tip` =1 GROUP BY `Sala` So i cant figure out how to combine them when a result is empty from mysql. example if $aResult and $cResult are empty i want to be able to combine just the rest of them Link to comment Share on other sites More sharing options...
water Posted July 30, 2013 Share Posted July 30, 2013 Again: What is empty? A 2D array with 0 rows, an empty string? Please do the test as a posted above. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
skybax Posted July 30, 2013 Author Share Posted July 30, 2013 (edited) Again: What is empty? A 2D array with 0 rows, an empty string? Please do the test as a posted above. If i run the code and it dosent find anything in SQL if crashes the program with this error $SQLCode_raport_tip2 = "SELECT `Sala` , SUM(cantitate) FROM `raspandire` WHERE `data` BETWEEN '"&GUICtrlRead($data_de_la)&"' AND '"&GUICtrlRead($data_pana_la)&"'AND `Tip`=2 GROUP BY `Sala`" $TableContents_tip2 = _Query($SQLInstance,$SQLCode_raport_tip2) Global $bResult[10001][4] = [[10000, 4]] Global $iIndex2 With $TableContents_tip2 While Not .EOF $bResult[$iIndex2][0] = "Selector" $bResult[$iIndex2][1] = .Fields("Sala").value $bResult[$iIndex2][2] = .Fields("SUM(cantitate)").value $bResult[$iIndex2][3] = GUICtrlRead($curs_valutar)*251 $iIndex2 = $iIndex2 + 1 .MoveNext WEnd EndWith ReDim $bResult[$iIndex2][4] ConsoleWrite(IsArray($bResult)) Error ReDim $bResult[$iIndex2][4] ReDim $bResult[^ ERROR But if i run the same code without ReDim $bResult[$iIndex2][4] it post in console " 11 " I have made a printscreen of what sql returs for a emply sellection Edited July 30, 2013 by skybax Link to comment Share on other sites More sharing options...
water Posted July 30, 2013 Share Posted July 30, 2013 You need to initialize $iIndex2. Change Global $iIndex2 to Global $iIndex2 = 0 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted July 30, 2013 Share Posted July 30, 2013 For this to work you need to run one of the 3.3.9.x betas of AutoIt. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
skybax Posted July 30, 2013 Author Share Posted July 30, 2013 (edited) I have runed the code like this $SQLCode_raport_tip2 = "SELECT `Sala` , SUM(cantitate) FROM `raspandire` WHERE `data` BETWEEN '"&GUICtrlRead($data_de_la)&"' AND '"&GUICtrlRead($data_pana_la)&"'AND `Tip`=2 GROUP BY `Sala`" $TableContents_tip2 = _Query($SQLInstance,$SQLCode_raport_tip2) Global $bResult[10001][4] = [[10000, 4]] Global $iIndex2 = 0 With $TableContents_tip2 While Not .EOF $bResult[$iIndex2][0] = "Selector" $bResult[$iIndex2][1] = .Fields("Sala").value $bResult[$iIndex2][2] = .Fields("SUM(cantitate)").value $bResult[$iIndex2][3] = GUICtrlRead($curs_valutar)*251 $iIndex2 = $iIndex2 + 1 .MoveNext WEnd EndWith ConsoleWrite(IsArray($bResult)) and i get 1 in console LE: im on v3.3.8.1 shoud i update ? Edited July 30, 2013 by skybax Link to comment Share on other sites More sharing options...
Solution water Posted July 30, 2013 Solution Share Posted July 30, 2013 Or try this one: Case $arata_raport_1 $SQLCode_raport_tip1 = "SELECT `Sala` , SUM(cantitate) FROM `raspandire` WHERE `data` BETWEEN '"&GUICtrlRead($data_de_la)&"' AND '"&GUICtrlRead($data_pana_la)&"'AND `Tip`=1 GROUP BY `Sala`" $TableContents_tip1 = _Query($SQLInstance,$SQLCode_raport_tip1) Global $aResult[10001][4] = [[10000, 4]] Global $iIndex = 0 With $TableContents_tip1 While Not .EOF $aResult[$iIndex][0] = "SIMM" $aResult[$iIndex][1] = .Fields("Sala").value $aResult[$iIndex][2] = .Fields("SUM(cantitate)").value*2 $aResult[$iIndex][3] = GUICtrlRead($curs_valutar)*250 $iIndex = $iIndex + 1 .MoveNext WEnd EndWith If $iIndex > 0 then ReDim $aResult[$iIndex][4] Else $aResult = "" EndIf ; Rest of your queries go here If IsArray($bResult) Then _ArrayCombine($aResult, $bResult) If IsArray($cResult) Then _ArrayCombine($aResult, $cResult) If IsArray($dResult) Then _ArrayCombine($aResult, $dResult) If IsArray($eResult) Then _ArrayCombine($aResult, $eResult) _ArrayDisplay($aResult) What is still missing is what needs to be done if $aResult is empty. skybax 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
skybax Posted July 30, 2013 Author Share Posted July 30, 2013 (edited) Yes it works if $aResult is not empty Any idea how can i get rid of the dependence for $aResult ? Edited July 30, 2013 by skybax Link to comment Share on other sites More sharing options...
czardas Posted July 30, 2013 Share Posted July 30, 2013 (edited) Looking at this, I see you are selecting a row and filling four columns. Loop through the columns as you go to make sure at least one array element (or the minimum required) contains data. As soon as you find sufficient data stop testing. If by the end of the array no data was encountered then skip to the next array. You need to set a flag, and only test when the flag is TRUE. Change the flag's status to FALSE once the array has been verified as containing data. Edited July 30, 2013 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
skybax Posted July 30, 2013 Author Share Posted July 30, 2013 (edited) Looking at this, I see you are selecting a row and filling four columns. Loop through the columns as you go to make sure at least one array element (or the minimum required) contains data. As soon as you find sufficient data stop testing. If by the end of the array no data was encountered then skip to the next array. You need to set a flag, and only test when the flag is TRUE. Change the flag's status to FALSE once the array has been verified as containing data. I have came up with this but im not sure if its the best way to do this because of the multiple combination posible Local $flag =0 If IsArray($aResult) Then $flag = 10000 If IsArray($bResult) Then $flag = $flag + 1000 If IsArray($cResult) Then $flag = $flag + 100 If IsArray($dResult) Then $flag = $flag + 10 If IsArray($eResult) Then $flag = $flag + 1 MsgBox(-1,"TEST",""&$flag) If $flag = 10000 then _ArrayDisplay($aResult) EndIf If $flag = 1000 then _ArrayDisplay($cResult) EndIf If $flag = 100 then _ArrayDisplay($cResult) EndIf If $flag = 10 then _ArrayDisplay($dResult) EndIf If $flag = 1 then _ArrayDisplay($eResult) EndIf Edited July 30, 2013 by skybax Link to comment Share on other sites More sharing options...
water Posted July 30, 2013 Share Posted July 30, 2013 (edited) You could put everything into a single array from the start: expandcollapse popupGlobal $aTotalResult[1][4] = [[0, 4]] Global $iTotalIndex = 1 Case $arata_raport_1 $SQLCode_raport_tip = "SELECT `Sala` , SUM(cantitate) FROM `raspandire` WHERE `data` BETWEEN '" & GUICtrlRead($data_de_la) & "' AND '" & GUICtrlRead($data_pana_la) & "'AND `Tip`=1 GROUP BY `Sala`" $TableContents_tip = _Query($SQLInstance, $SQLCode_raport_tip) With $TableContents_tip If .RecordCount > 0 Then ReDim $aTotalResult[UBound($aTotalResult, 1) + .RecordCount][4] $aTotalResult[0][0] = $aTotalResult[0][0] + .RecordCount While Not .EOF $aTotalResult[$iTotalIndex][0] = "SIMM" $aTotalResult[$iTotalIndex][1] = .Fields("Sala").value $aTotalResult[$iTotalIndex][2] = .Fields("SUM(cantitate)").value * 2 $aTotalResult[$iTotalIndex][3] = GUICtrlRead($curs_valutar) * 250 $iTotalIndex = $iTotalIndex + 1 .MoveNext WEnd EndIf EndWith ; Report 2 Case $arata_raport_2 $SQLCode_raport_tip = "SELECT `Sala` , SUM(cantitate) FROM `raspandire` WHERE `data` BETWEEN '"&GUICtrlRead($data_de_la)&"' AND '"&GUICtrlRead($data_pana_la)&"'AND `Tip`=2 GROUP BY `Sala`" $TableContents_tip = _Query($SQLInstance,$SQLCode_raport_tip) With $TableContents_tip1 If .RecordCount > 0 Then ReDim $aTotalResult[UBound($aTotalResult, 1) + .RecordCount][4] $aTotalResult[0][0] = $aTotalResult[0][0] + .RecordCount While Not .EOF $aTotalResult[$iTotalIndex][0] = "SIMM" $aTotalResult[$iTotalIndex][1] = .Fields("Sala").value $aTotalResult[$iTotalIndex][2] = .Fields("SUM(cantitate)").value $aTotalResult[$iTotalIndex][3] = GUICtrlRead($curs_valutar) * 251 $iTotalIndex = $iTotalIndex + 1 .MoveNext WEnd EndIf EndWith ; Etc. ; Put all other SQL queries here _ArrayDisplay($aTotalResult) Edited July 30, 2013 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
skybax Posted July 30, 2013 Author Share Posted July 30, 2013 You could put everything into a single array from the start: Global $aTotalResult[1][4] = [[0, 4]] Global $iTotalIndex = 1 Case $arata_raport_1 $SQLCode_raport_tip1 = "SELECT `Sala` , SUM(cantitate) FROM `raspandire` WHERE `data` BETWEEN '" & GUICtrlRead($data_de_la) & "' AND '" & GUICtrlRead($data_pana_la) & "'AND `Tip`=1 GROUP BY `Sala`" $TableContents_tip1 = _Query($SQLInstance, $SQLCode_raport_tip1) With $TableContents_tip1 If .RecordCount > 0 Then ReDim $aTotalResult[UBound($aTotalResult, 1) + .RecordCount][4] $aTotalResult[0][0] = $aTotalResult[0][0] + .RecordCount While Not .EOF $aTotalResult[$iTotalIndex][0] = "SIMM" $aTotalResult[$iTotalIndex][1] = .Fields("Sala").value $aTotalResult[$iTotalIndex][2] = .Fields("SUM(cantitate)").value * 2 $aTotalResult[$iTotalIndex][3] = GUICtrlRead($curs_valutar) * 250 $iTotalIndex = $iTotalIndex + 1 .MoveNext WEnd EndIf EndWith ; Put all other SQL queries here _ArrayDisplay($aTotalResult) I cant really do that because i need to run 5 different $SQLCode_raport_tip1 because `Tip`=1 goes from 1 to 5 and for each of them i need to have a different value for $bResult[$iIndex2][0] Link to comment Share on other sites More sharing options...
skybax Posted July 30, 2013 Author Share Posted July 30, 2013 This is how the code looks right now expandcollapse popupCase $arata_raport_1 $SQLCode_raport_tip1 = "SELECT `Sala` , SUM(cantitate) FROM `raspandire` WHERE `data` BETWEEN '"&GUICtrlRead($data_de_la)&"' AND '"&GUICtrlRead($data_pana_la)&"'AND `Tip`=1 GROUP BY `Sala`" $TableContents_tip1 = _Query($SQLInstance,$SQLCode_raport_tip1) Global $aResult[10001][4] = [[10000, 4]] Global $iIndex = 0 With $TableContents_tip1 While Not .EOF $aResult[$iIndex][0] = "SIMM" $aResult[$iIndex][1] = .Fields("Sala").value $aResult[$iIndex][2] = .Fields("SUM(cantitate)").value*2 $aResult[$iIndex][3] = GUICtrlRead($curs_valutar)*250 $iIndex = $iIndex + 1 .MoveNext WEnd EndWith If $iIndex > 0 then ReDim $aResult[$iIndex][4] Else $aResult = "" EndIf $SQLCode_raport_tip2 = "SELECT `Sala` , SUM(cantitate) FROM `raspandire` WHERE `data` BETWEEN '"&GUICtrlRead($data_de_la)&"' AND '"&GUICtrlRead($data_pana_la)&"'AND `Tip`=2 GROUP BY `Sala`" $TableContents_tip2 = _Query($SQLInstance,$SQLCode_raport_tip2) Global $bResult[10001][4] = [[10000, 4]] Global $iIndex2 = 0 With $TableContents_tip2 While Not .EOF $bResult[$iIndex2][0] = "Selector" $bResult[$iIndex2][1] = .Fields("Sala").value $bResult[$iIndex2][2] = .Fields("SUM(cantitate)").value $bResult[$iIndex2][3] = GUICtrlRead($curs_valutar)*251 $iIndex2 = $iIndex2 + 1 .MoveNext WEnd EndWith If $iIndex2 > 0 then ReDim $bResult[$iIndex2][4] Else $bResult = "" EndIf $SQLCode_raport_tip3 = "SELECT `Sala` , SUM(cantitate) FROM `raspandire` WHERE `data` BETWEEN '"&GUICtrlRead($data_de_la)&"' AND '"&GUICtrlRead($data_pana_la)&"'AND `Tip`=3 GROUP BY `Sala`" $TableContents_tip3 = _Query($SQLInstance,$SQLCode_raport_tip3) Global $cResult[10001][4] = [[10000, 4]] Global $iIndex3 = 0 With $TableContents_tip3 While Not .EOF $cResult[$iIndex3][0] = "CF Card" $cResult[$iIndex3][1] = .Fields("Sala").value $cResult[$iIndex3][2] = .Fields("SUM(cantitate)").value $cResult[$iIndex3][3] = GUICtrlRead($curs_valutar)*252 $iIndex3 = $iIndex3 + 1 .MoveNext WEnd EndWith If $iIndex3 > 0 then ReDim $cResult[$iIndex3][4] Else $cResult = "" EndIf $SQLCode_raport_tip4 = "SELECT `Sala` , SUM(cantitate) FROM `raspandire` WHERE `data` BETWEEN '"&GUICtrlRead($data_de_la)&"' AND '"&GUICtrlRead($data_pana_la)&"'AND `Tip`=4 GROUP BY `Sala`" $TableContents_tip4 = _Query($SQLInstance,$SQLCode_raport_tip4) Global $dResult[10001][4] = [[10000, 4]] Global $iIndex4 = 0 With $TableContents_tip4 While Not .EOF $dResult[$iIndex4][0] = "Dongle" $dResult[$iIndex4][1] = .Fields("Sala").value $dResult[$iIndex4][2] = .Fields("SUM(cantitate)").value $dResult[$iIndex4][3] = GUICtrlRead($curs_valutar)*253 $iIndex4 = $iIndex4 + 1 .MoveNext WEnd EndWith If $iIndex4 > 0 then ReDim $dResult[$iIndex4][4] Else $dResult = "" EndIf $SQLCode_raport_tip5 = "SELECT `Sala` , SUM(cantitate) FROM `raspandire` WHERE `data` BETWEEN '"&GUICtrlRead($data_de_la)&"' AND '"&GUICtrlRead($data_pana_la)&"'AND `Tip`=5 GROUP BY `Sala`" $TableContents_tip5 = _Query($SQLInstance,$SQLCode_raport_tip5) Global $eResult[10001][4] = [[10000, 4]] Global $iIndex5 = 0 With $TableContents_tip5 While Not .EOF $eResult[$iIndex5][0] = "Kernel" $eResult[$iIndex5][1] = .Fields("Sala").value $eResult[$iIndex5][2] = .Fields("SUM(cantitate)").value $eResult[$iIndex5][3] = GUICtrlRead($curs_valutar)*254 $iIndex5 = $iIndex5 + 1 .MoveNext WEnd EndWith If $iIndex5 > 0 then ReDim $eResult[$iIndex5][4] Else $eResult = "" EndIf If IsArray($bResult) Then _ArrayCombine($aResult, $bResult) If IsArray($cResult) Then _ArrayCombine($aResult, $cResult) If IsArray($dResult) Then _ArrayCombine($aResult, $dResult) If IsArray($eResult) Then _ArrayCombine($aResult, $eResult) _ArrayDisplay($aResult) Link to comment Share on other sites More sharing options...
water Posted July 30, 2013 Share Posted July 30, 2013 I cant really do that because i need to run 5 different $SQLCode_raport_tip1 because `Tip`=1 goes from 1 to 5 and for each of them i need to have a different value for $bResult[$iIndex2][0] If at the end you need a single Array with all the records then this is the fastest and easiest way. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki 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