I have a string variable that is declared in the first line of my program, and then it is set to something in function like this:
set procTime to "0:00.79" as string
getProcessTime("iTunes", procTime)
display dialog procTime -- ****
on getProcessTime(proc, procTime)
try
tell application "System Events" to set pid to the unix id of process proc as string
set procTime to paragraph 2 of (do shell script "ps -p " & quoted form of pid & " | awk '{ print $4 }'") as string
display dialog procTime -- ****
end try
end getProcessTime
The problem is that in the second “display dialog”, I am getting the string I want, but in the first one it is always “0:00.79” like when it is initiated. I’ve tried changing the first line to just “set procTime to string” but then the first “display dialog” gives me the answer of “TEXT”
Anyone know why this variable would be doing that?
Thanks!