Using "Using terms from application"?

Hi All,

I have a script being launched by a Mail rule.
Sample. (Suggested from post http://bbs.applescript.net/viewtopic.php?id=20575 not my actual script)

using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		repeat with eachMessage in theMessages
			tell application "Mail"
				tell eachMessage
					set theSender to (extract name from sender)
					set theDate to date received
					set theContents to content as text
				end tell
			end tell
			set theDate to short date string of theDate
			set TempFile to ((path to desktop) as string) & theSender & "_" & theDate
			set theTextFile to open for access TempFile with write permission
			write theContents to theTextFile
			close access theTextFile
		end repeat
	end perform mail action with messages
end using terms from

I have added quite a bit of code to this script. My question is do I have to explicitly call an apps terms for tell blocks to other apps beside mail?

Example

using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		repeat with eachMessage in theMessages
			tell application "Mail"
				tell eachMessage
					set theSender to (extract name from sender)
					set theDate to date received
					set theContents to content as text
				end tell
			end tell
			set theDate to short date string of theDate
			set TempFile to ((path to desktop) as string) & theSender & "_" & theDate
			set theTextFile to open for access TempFile with write permission
			write theContents to theTextFile
			close access theTextFile
		end repeat
		
		--ADDED TELL BLOCK
		tell application "Whatever"
			do stuff that involves terms only in it's dictionary
		end tell
		
		--OR SHOULD IT BE
		using terms from application "Whatever"
			tell application "Whatever"
				do stuff that involves terms only in it's dictionary
		end tell
		end using terms from
	end perform mail action with messages
end using terms from

Is this needed or does it access the terms of the app by default even when nested in a “using terms from” statment?

I have a stand alone version of my script for testing that works fine. When I put the code back in the actual script that Maill will use, which has the entire script in a Using terms from application “Mail” statment and a “on perform mail action” handler, some of the code no longer works.

Thanks,
Mark

Hi Mark,

No you don’t need to use ‘using terms from’ for every tell block. The reason you’re using it around the handler is because the script couldn’t compile the script if it wasn’t there (the ‘on perform mail action’). The compiler has to know to look in Mail for that.

Edited: and note that, the tell statements tell app “someapp”, the compiler already looks in the dictionary for that app to compile statements in the tell block specific to that app.

Edited: I didn’t see the second part. Try placing the other tell blocks in subroutines. To call the subroutines, use ‘my’ or ‘of me’.

gl,