Jump to content
Sign in to follow this  
gracea

How can i change array elements arrangement (inside script) for easy reading...?

Recommended Posts

gracea

How can i change array elements arrangement (inside script) for easy reading from this...

Local $ProcessNameList[3][2] = [["CALC.EXE", ""], ["NOTEPAD.EXE", ""], ["MSPAINT.EXE", ""]]

To something like this...?     ("Please stick to the original code as much as possible.")

Local $ProcessNameList[3][2] = 
[["CALC.EXE", ""],          ; CALCULATOR
["NOTEPAD.EXE", ""],            ; NOTEPAD.EXE
["MSPAINT.EXE", ""]]            ; MSPAINT.EXE

I wanted this for easy reading especially most the comment entries. And from time to time i might sort the elements (from script code - not by running the code) by selecting the element code move it to ms excel sort it by name then move it back to script code.

Tried different variation for those part only but no success. So far i wanted to stick on the original script code below "BUT" with my ideal elements/items arrangement for easy reading. The elements/items could be more than 10.

Local $ProcessNameList[3][2] = [["CALC.EXE", ""], ["NOTEPAD.EXE", ""], ["MSPAINT.EXE", ""]] ;Define a 2D array to store the process name and in the second column the pids of running applications

While 1
    For $i = 0 To UBound($ProcessNameList) - 1 ;read the array in a for loop
        If ProcessExists($ProcessNameList[$i][0]) Then ;if the process exists then we will check it
            $aPid = ProcessList($ProcessNameList[$i][0]) ;get the pids for all instances of process name
            If IsArray($aPid) Then ;if we got the list continue
                For $x = 1 To $aPid[0][0] ;we will check in a for loop if the pid process is already in our list
                    If Not StringInStr($ProcessNameList[$i][1], "|" & $aPid[$x][1] & "|") Then ;if the pid process is not in our list (second column of our process name array)...
                        MsgBox(0, "Process running", $ProcessNameList[$i][0] & " is running with pid " & $aPid[$x][1]) ;... then show a message...
                        $ProcessNameList[$i][1] &= "|" & $aPid[$x][1] & "|" ; ... and add the pid in our list (second column of our process name array)
                    EndIf
                Next
            EndIf
        EndIf
    Next
    Sleep(500)
WEnd

Current code reference:

'?do=embed' frameborder='0' data-embedContent>>

Lucky Me...?!


:P " Loved It ! " :wub:

Share this post


Link to post
Share on other sites
Tekk

Like this?

Local $ProcessNameList[3][2] = [ _
        ["CALC.EXE"   , ""], _       ; CALCULATOR
        ["NOTEPAD.EXE", ""], _       ; NOTEPAD.EXE
        ["MSPAINT.EXE", ""]]

Share this post


Link to post
Share on other sites
gracea

Tekk

Thank you. Work and tested. Now i can move on to next script.


:P " Loved It ! " :wub:

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  

×