--delay 5 tell application "Finder" get (id of first process whose frontmost is 1) set procid to result end tell set f to alias "Macintosh HD:flex50.txt" try set ref_num to open for access f with write permission set eof ref_num to 0 on error close access f try set ref_num to open for access f with write permission set eof ref_num to 0 on error errText number errNum display dialog "couldn't open file because" & return & return & return & errNum & " - " & errText end try end try #seteof of ref_num to (get eof of ref_num) write procid to f as text close access ref_num tell application "Finder" get (id of every process whose frontmost is 1) set procid to result end tell