Jump to content

_ArrayCombine multiple arrays


Go to solution Solved by water,

Recommended Posts

I tried to modify the code examples here, but I don't have beta installed, part of the script is missing and I'm not accustomed to using SQL functions, so I decided it would make more sense to show you an example of what I was referring to. Whether it is easy for you to use this method is unclear to me. It depends on the functions you are using to get the data. Here's my example anyway. It might give you an idea.

;

Global $g_IsEmpty ; Flag for testing array elements

Local $aArray[2][4] ; Array

Local $sData1 = "", $sData2 = "", $sData3 = "", $sData4 = Chr(0) ; Change values to see the difference

$g_IsEmpty = True ; Reset for every new array
For $i = 0 To UBound($aArray) -1
    $aArray[$i][0] = $sData1 ; The array elements get filled or not
    $aArray[$i][1] = $sData2
    $aArray[$i][2] = $sData3
    $aArray[$i][3] = $sData4

    ; Test what is happening as we go
    If $g_IsEmpty Then ; If False the next lines are skipped
        For $j = 0 To 3 ; We have not found any data yet.
            If $aArray[$i][$j] And $aArray[$i][$j] <> Chr(0) Then ; Data exists - null character is ignored
                $g_IsEmpty = False ; Change the flag
                ExitLoop ; Get out of here
            EndIf
        Next
    EndIf
Next

If $g_IsEmpty Then MsgBox(0, "", "Array is empty")

;

Although I agree with Water that a single array would be better. No need to combine the results: just add the information from each query to the end of the array and allow it to grow in size (using ReDim) if needed..

Edited by czardas
Link to post
Share on other sites

Give it a try and see what you get.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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 post
Share on other sites

I have made this 

Global $iResult[1][4] = [[0, 0, 0, 0]]
        If IsArray($aResult) Then _ArrayCombine($iResult, $aResult)
        If IsArray($bResult) Then _ArrayCombine($iResult, $bResult)
                    If IsArray($cResult) Then _ArrayCombine($iResult, $cResult)
                    If IsArray($dResult) Then _ArrayCombine($iResult, $dResult)
                    If IsArray($eResult) Then _ArrayCombine($iResult, $eResult)
                    _ArrayDisplay($iResult)

It adds a "buffer" array in which i can write the results from the mysql queries the only problem is that now i have  useless first row of data, but now all of the array can be null .

Dose anyone know how can i delete the first row of the final $iResult  with the condition that $iResult  has a minimum of 2 rows.

Link to post
Share on other sites

You could use _ArrayDelete but that is rather slow.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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 post
Share on other sites

You could use _ArrayDelete but that is rather slow.

Global $iResult[1][4] = [[0, 0, 0, 0]]
                    If IsArray($aResult) Then _ArrayCombine($iResult, $aResult)
                    If IsArray($bResult) Then _ArrayCombine($iResult, $bResult)
                    If IsArray($cResult) Then _ArrayCombine($iResult, $cResult)
                    If IsArray($dResult) Then _ArrayCombine($iResult, $dResult)
                    If IsArray($eResult) Then _ArrayCombine($iResult, $eResult)
                    _ArrayDelete($iResult, 0)
                    if $iResult = "" then MsgBox(-1,"TEST","IN INTERVALUL SELECTAT NU SUNT ELEMENTE")
                    if $iResult <> "" then _ArrayDisplay($iResult)

With this modification all seems to be ok.

Link to post
Share on other sites

:D

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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 post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...