Sign in to follow this  
Followers 0
amakrkr

Array compare

6 posts in this topic

#1 ·  Posted (edited)

Hello,

 i have found quite some examples on forum but this array compare still bugs me.

What am i trying to do is, i have one array of opened processes and one array of processes listed in ini file.

I am trying to compare those two arrays and eliminate processes that are already in ini file (or in second array).

But my code instead of displaying those that are not in ini file it displays every single process because i suspect that

my code checks arrays like this:

ARRAY1: [0] PID 345   ARRAY2:[0] PID: 0  -> FALSE

ARRAY2: [1] PID 3544 ARRAY2:[1] PID: 345 -> FALSE

Above example should return only 3544.

Here is my code:

#include <Array.au3>

local $avArray[3] = ["1255","0","23423"]  
Local $aList = ProcessList("notepad.exe") 

for $i = 0 to UBound($aList,1) - 1 
 if $aList[$i][1] <> "23423" Then
     MsgBox(0,"This: ",$aList[$i][1])
 EndIf 
Next
Edited by amakrkr

Share this post


Link to post
Share on other sites



I think the PID will change for every time you start a process, how can you store a bunch of PID and know what it is?

ProcessList will return in element 0 the number of results so you should start your loop with i=1

Share this post


Link to post
Share on other sites

hI,

Geir1983 thats not the problem. Problem is i need to compare strings in array 1 with every string in array 2 and display the one which is not in array2 or is in arry 2 doesnt matter.   Thanks 

Share this post


Link to post
Share on other sites

nvm i solved it my self.

thanks all who tried to help!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

#include <Array.au3>

local $avArray[3] = ["1255","0","12540"]
Local $aList = ProcessList("notepad.exe")

for $i = 1 to Ubound($aList)-1
    $IsInArray=False
    For $j = 0 to Ubound($avArray)-1
        if $aList[$i][1] = $avArray[$j] Then $IsInArray=True
    Next
    IF $IsInArray Then MsgBox(0,"This: ",$aList[$i][1])
 Next

Like this?

Edit: to late

Edited by Geir1983

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  
Followers 0