The Daily Click ::. Forums ::. Klik Coding Help ::. Compare two lists. Add line differences to third list.
 

Post Reply  Post Oekaki 
 

Posted By Message

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1331

VIP MemberStarSnow
16th February, 2012 at 19:31:09 -

I'm *trying* to create a simple app that uses the Process Viewer extension to populate a list of process names.
I have three list objects. Every 10 seconds it either fills the first or second list depending on the state of ListObject1's AlterableValue1.
Every 19 seconds, each line in the two lists are compared and line differences are added to ListObject3.

Basically, it's supposed to poll the system for a list of running processes (ListObject2), compare it to a list of processes recorded 10 seconds ago (ListObject1), then add any line differences to ListObject3. Instead, it adds ALL of the processes from ListObject1 to ListObject3 and I don't quite understand why. Anybody mind schooling me?

<// Update process list at frame start //>
Start of Frame:
Process Viewer -> Update Process List

<// Populate ListObject1 with current process list //>
On Loop "PopList1":
ListObject1 -> AddLine pExeFile$ ("ProcessViewer")
Process Viewer -> Next Process;

<// Populate ListObject2 with current process list //>
On Loop "PopList2":
ListObject2 -> AddLine pExeFile$ ("ProcessViewer")
Process Viewer -> Next Process;

<// Compare the two lists. If no line difference, skip to next line //>
On loop "CompLists" & List Select$( "ListObject1" ) = List Select$( "ListObject2" ):
ListObject1 -> Set current line "ListObject1" to List Select ("ListObject1") + 1;
ListObject2 -> Set current line "ListObject2" to List Select ("ListObject2") + 1;

<// Compare the two lists. If a line difference, add to List3 then skip to next line //>
On loop "CompLists" & List Select$( "ListObject1" ) <> List Select$( "ListObject2" ):
ListObject3 -> Add a line ("ListObject3") Select$ ("ListObject1");
ListObject1 -> Set current line "ListObject1" to List Select ("ListObject1") + 1;
ListObject2 -> Set current line "ListObject2" to List Select ("ListObject2") + 1;

::CATEGORY: PopulateLists (Inactive at start)::
<// If ListObject1's AltValA = 0, populate first list object //>
AlterableValueA ("ListObject1") = 0:
Process Viewer -> Update Process list;
ListObject1 -> Reset;
Start Loop -> "PopList1" 30 times;
ListObject1 -> Set Current Line 0;
ListObject2 -> Set Current Line 0;
ListObject1 -> Set AlterableValue A to 1;
Deactivate Group -> "PopLists";

<//If ListObject's AltValA = 1, populate second list object //>
AlterableValueA ("ListObject1") = 1:
Process Viewer -> Update Process list;
ListObject2 -> Reset;
Start Loop -> "PopList2" 30 times;
ListObject1 -> Set Current Line 0;
ListObject2 -> Set Current Line 0;
ListObject1 -> Set AlterableValue A to 0;
Deactivate Group -> "PopLists";
::END CATEGORY: "PopulateLists"::

<//Every 10 seconds, fill either the first or second ListObject//>
Every 10 seconds:
Activate Group "PopLists";

<// Compare lists every 19 seconds and run loop until the last line of ListObject1 is reached //>
Every 19 seconds:
Start loop "CompLists" list NBlines "ListObject1" times.

Edited by The_Antisony

 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1331

VIP MemberStarSnow
16th February, 2012 at 19:36:57 -

Sorry about the event scripting text formatting. I know it's a little hard to make heads or tails of. If anybody has MMF2 Dev, I wouldn't mind passing the source.

Could it be that I added conditional statements to my fastloops? If that's the case, can anybody offer an alternative method?

Edited by The_Antisony

 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?

Chris Burrows



Registered
  14/09/2002
Points
  2396

GOTW WINNER OCT. 2011
16th February, 2012 at 21:29:49 -

Post your mfa and I'll have a crack at it. Or email it: chrishrew@hotmail.com

 
n/a

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1331

VIP MemberStarSnow
17th February, 2012 at 07:16:22 -

https://skydrive.live.com/redir.aspx?cid=e2d87e65cc574f02&resid=E2D87E65CC574F02!122&parid=E2D87E65CC574F02!120

^^ That be it.
It's probably some ridiculous head-slap issue; thanks for taking a look.


Edited by The_Antisony

 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1331

VIP MemberStarSnow
17th February, 2012 at 21:24:29 -

Since I'm basically just trying to log a simple process list every 25 seconds, instead of copying from one list to another, I kinda just went this route:
Image

It pulls all processes ending in ".exe" and adds them to the list, then removes string matches from the list and saves a list file.
I'm going to play with it a bit. I still think I want to add some kind of list comparison, but now that the list file is external, I'm thinking it might be easier to use the getline extension for comparison and edit the external file to kill all previous results.

 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?

Chris Burrows



Registered
  14/09/2002
Points
  2396

GOTW WINNER OCT. 2011
18th February, 2012 at 00:06:20 -


So let me clarify...

You want to create a list of all running processes.

Then 25 seconds later you want create a second list.

And then if there are any processes in this second list that are not in the first list, close them?

 
n/a

Chris Burrows



Registered
  14/09/2002
Points
  2396

GOTW WINNER OCT. 2011
18th February, 2012 at 03:32:30 -

This is how I'd do it: http://www.whenthereisnoroominhellthedeadwalktheearth.com/MMF/Process.mfa

Hope it's helpful

Let me know if you want me to explain anything.

 
n/a

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1331

VIP MemberStarSnow
18th February, 2012 at 09:04:42 -

Well, kinda. If you're wondering about it's application, I'm essentially logging a set of processes every 25 seconds while I'm repairing client PCs. I do repairs on a lot of systems that still run Windows XP, and it'd be a perk if I could portably log all the applications and system processes while I keep notes and troubleshoot; then include all of that in the client's case data XML file. When I bring the portable app back home, I can merge the individual XML files with a full database app that organizes client data by week, month, and year.

Instead of logging 15 of the same processes every 25 seconds with rare diversion, I'd like the list to knock out Windows XP's default system processes first, then save the resulting list file, wait 25 seconds, repopulate the list object, then compare to the listfile for differences. That way, only new processes are logged. If there were some better way of doing that by enumerating processes, I'd like to know about it, but I don't want to skip malware-related processes that may hook or load with Windows.

I'll take a look at your example because it'll likely help me out with the comparison portion.
After checking it out, that's exactly what I was after. I think I was having issues with comparing the same indexed line between the two list objects; instead my app was figuring that each line was unmatched and no entries were being pushed to the third list; but I was using set linenumber% = 0 and compare currentline$ instead of compare line at counter number which would have kept everything unified. Whoops.

Thanks for the help, Chris.

Edited by The_Antisony

 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?

Chris Burrows



Registered
  14/09/2002
Points
  2396

GOTW WINNER OCT. 2011
19th February, 2012 at 19/02/2012 23:37:44 -


Glad to help. Good luck with it

 
n/a
   

Post Reply



 



Advertisement

Worth A Click