Jump to content

Array filter


MRXTO09
 Share

Recommended Posts

I would like to eliminate the elements in an array according to the elements of another one I tried to do this:
Func __Print(ByRef Const $aArray, $iBase = Default, $iUBound = Default)
    
   Dim $MODULESARRAY[119]

   $MODULESARRAY[0] = "blabla"
 ...
    
    If Not IsArray($aArray) Then Return SetError(1, 0, 0)


    Local $iLast = UBound($aArray) - 1
    If $iUBound = Default Or $iUBound > $iLast Then $iUBound = $iLast
    If $iBase < 0 Or $iBase = Default Then $iBase = 0
    If $iBase > $iUBound Then Return SetError(3, 0, 0)

            For $i = $iBase To $iUBound
               $trovato = 0
               $returntext = ""
               For $a = 1 To UBound($MODULESARRAY)
                  $sString = StringReplace($aArray[$i], "\", " ")
                  If StringInStr($sString, $MODULESARRAY[$a-1]) Then
                  $trovato = 1
                  Endif
               Next
               If $trovato = 0 Then
                  $returntext &= "[" & $i - $iBase & "]" & $aArray[$i] & "<br>"
               EndIf
            Next
            Return $returntext
EndFunc

but dosen't work

please help me :)

Link to comment
Share on other sites

Like this?

Global $MODULESARRAY[119]
For $i = 0 To UBound($MODULESARRAY)-1
    $MODULESARRAY[$i]="SomeText" & $i
Next

$newArray = $MODULESARRAY
ReDim $newArray[UBound($MODULESARRAY)+50]
For $i = UBound($MODULESARRAY)-1 To UBound($newArray)-1
    $newArray[$i]="SomeText" & $i
Next

ConsoleWrite(__Print($newArray) & @CRLF)
Exit

Func __Print(ByRef $aArray, $iBase = Default, $iUBound = Default)
    If Not IsArray($aArray) Then Return SetError(1, 0, 0)
    Local $iLast = UBound($aArray) - 1
    If $iUBound = Default Or $iUBound > $iLast Then $iUBound = $iLast
    If $iBase < 0 Or $iBase = Default Then $iBase = 0
    If $iBase > $iUBound Then Return SetError(3, 0, 0)
    $returntext = ""
    For $i = $iBase To $iUBound
        If _ArraySearch($MODULESARRAY,$aArray[$i])<0 Then
            $returntext &= "[" & $i - $iBase & "]" & $aArray[$i] & "<br>" & @CRLF
        EndIf
    Next
    Return $returntext
EndFunc

You are reseting the return text durring each loop, you need it to declar it outside of the loop.

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...