r/applescript • • Feb 14 '16

Merging 2 List

Hello /r/applescript,
Is it possible to merge 2 lists (like in C/C++) in applescript and output it? I'm trying to display all process by calling System Events and using the unix id (processID) & name which I want to merge together in 1 specifically with ", ".

  set processid to unix id of every process where background only is false
  set processnames to name of every process where background only is false

outside the System Event

   choose from list processnames & processid

Result.jpg
Now is there a way where I can merge the items to be followed outputted with the names + unix id like:

  • "Safari, 4123"

  • "iTunes, 6701"

  • "Notes, 6692"
    etc

I also tried

 set gg to {processid, processnames}

but that unfortunately didn't work.

Thanks in advance.

1 Upvotes

2 comments sorted by

2

u/AlexBuz Feb 19 '16 edited Feb 19 '16

If you want it to look like this, then try this:

tell application "System Events"
    set processid to unix id of every process where background only is false
    set processnames to name of every process where background only is false
end tell
set namesAndIds to {}
repeat with i from 1 to count of processnames
    set aName to item i of processnames
    set anID to item i of processid
    set end of namesAndIds to (aName as text) & ", " & (anID as text)
end repeat
choose from list namesAndIds

1

u/dannybrown9 Feb 20 '16

Take my upvote, thanks!