Error - Can’t get text item delimiters

I have a little script that retrieves non background process and their PID’s (thanks again StefanK). This runs fine in the Script Editor. But when I run the script through iChat I receive the following error:

I have the following:

	on processHandle(theMessage)
		try
			set listProcess to {}
			tell application "System Events"
				repeat with aProcess in (get processes whose background only is false)
					tell aProcess to set end of listProcess to (unix id as text) & " - " & its name
				end repeat
			end tell
			set {tid, text item delimiters} to {text item delimiters, return}
			set listProcess to listProcess as text
			set text item delimiters to tid
			set theResponse to listProcess
		on error error_message
			set theResponse to "Static Parser - error retrieving processes. " & error_message
			
		end try
		return theResponse
	end processHandle

A little birdie told me:

The problem with what the birdie told me is I while I think I followed, I’m not sure how to put it into practice in the above script.


set {TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
set listProcess to listProcess as text
set AppleScript's text item delimiters to TID

to avoid further unexpected errors, use the using terms from block only around the iChat event handler(s)

Thanks once again!:smiley: