Jump to content
Sign in to follow this  
inferno123

Substracting two arrays

Recommended Posts

inferno123

Could anybody help me on removing items from array ($Result_Array). The items I want to remove are in $sub_array . Thank you for all your help

The piece of code is:

$phrase = "Security Update for Windows XP"

Dim $sub_array[1][1]

For $y = 0 To $Result_Array[$y][0]

$element = $Result_Array[$y][0]

$string = StringInStr($element, $phrase)

If $string = 1 Then

;MsgBox(0, "", $element)

;_ArrayDelete($Result_Array,$element)

_ArrayAdd($sub_array, $Result_Array[$y][0])

EndIf

Next

For $n = 1 To $sub_array[0]

$search = _ArraySearch($Result_Array, $sub_array[$n])

If $search = 1 Then

MsgBox(0, "", $search)

_ArrayDelete($Result_Array, $search)

EndIf

Next

Share this post


Link to post
Share on other sites
BrettF
inferno123

$outFile1 = @TempDir & "\temp1.tmp"

$outFile2 = @TempDir & "\temp2.tmp"

$outFile3 = @TempDir & "\temp3.tmp"

FileOpen($outFile2, 1)

$strFile = "c:\Version.txt"

$text_1 = FileRead($outFile2)

$text_2 = FileRead($outFile1)

Local $array_reg_values[1][1], $array_sub_values[1][1], $array_sub_values_Versions[1][1], $azbArray[1][1]

Local $key = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall"

For $a = 1 To 1000

$reg_values = RegEnumKey($key, $a)

If StringInStr($reg_values, "No more data is") = 0 Then

_ArrayAdd($array_reg_values, $reg_values)

EndIf

Next

$array_reg_values[0] = UBound($array_reg_values) - 1

For $b = 1 To $array_reg_values[0]

$sub_key = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall" & "\" & $array_reg_values[$b]

$reg_sub_values = RegRead($sub_key, "DisplayName")

_ArrayAdd($array_sub_values, $reg_sub_values)

Next

$array_sub_values[0] = UBound($array_sub_values) - 1

For $c = 1 To $array_sub_values[0]

If $array_sub_values[$c] = "" Then

$array_sub_values[$c] = $array_reg_values[$c]

EndIf

Next

For $d = 1 To $array_sub_values[0]

$sub_key = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall" & "\" & $array_reg_values[$d]

$reg_sub_values_versions = RegRead($sub_key, "DisplayVersion")

_ArrayAdd($array_sub_values_Versions, $reg_sub_values_versions)

Next

_FileWriteFromArray($outFile2, $array_sub_values)

Dim $Result_Array[uBound($array_sub_values) ][2]

For $i = 0 To UBound($array_sub_values) - 1

$Result_Array[$i][0] = $array_sub_values[$i]

$Result_Array[$i][1] = $array_sub_values_Versions[$i] ;->>> Joing arrays into single 2D array

Next

That is the $Result_array. I want to remove Security Updates string from Result Array. Is my approach to this array correct ?

Share this post


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
Sign in to follow this  

×