tell Applescript?

I was wondering, what is the difference between “tell Applescript” and “tell me.”

Does “tell Applescript” make my app not have to do work or freeze?

tell me refers to executing script…


script yourScriptHere
   on run 
     tell me to run  -- calls this run handler 
    end run

   tell me to run
end script 

----- 

on run 
    tell yourScriptHere to run -- run's previous script block
tell me to run  -- calls this run handler 
end run

That doesn’t even compile on my end! :frowning:

In script yourScriptHere there are two on run-handlers. By deleting one of them, the script will compile, although it doesn’t explain the difference between tell AppleScript and tell me


script yourScriptHere
	on run
		tell me to run -- calls this run handler 
	end run
end script

----- 

on run
	tell yourScriptHere to run -- run's previous script block
	tell me to run -- calls this run handler 
end run

According to the AppleScript Language Guide (my text formatting):

And:

The value of the AppleScript constant appears to be a script object in its own right, from which the script inherits certain properties:

return {class of AppleScript, my parent}
--> {script, «script AppleScript»}

A quick demo of the inheritance can be shown in the fact that while some scripters traditionally write AppleScript’s text item delimiters, others simply write text item delimiters because the script inherits that property from AppleScript anyway:

set text item delimiters to "aardvark"

return {text item delimiters, AppleScript's text item delimiters}
--> {"aardvark", "aardvark"}

But if the script has its own text item delimiters property, this is used instead of AppleScript’s:

property text item delimiters : missing value

set text item delimiters to "aardvark"

return {text item delimiters, AppleScript's text item delimiters, {1, 2, 3} as text}
--> {"aardvark", {""}, "1aardvark2aardvark3"}

AppleScript inherits properties it hasn’t defined itself from the application running the script:

return {parent, parent's parent}
--> {«script AppleScript», current application}

Since the script in turn inherits from AppleScript, it also inherits the application’s scriptable properties and abilities which haven’t been overridden by AppleScript. However, it’s quite a confusing situation with the various changes that have been made over the years, so caution is advised. (ie. Don’t try to be too clever.) tell me to activate and tell me to quit are carried out by the current application. But while my name returns the name of the current application (if no name property has been defined in the script), the name of AppleScript is the constant AppleScript, which leaves one puzzling over the inheritance chain. Also, the name of a labelled script object is a text version of the label! (With AppleScript 2.1.1, at least.)

script fred
end script

return {my name, AppleScript's name, fred's name}
--> {"AppleScript Editor", AppleScript, "fred"}

Until quite recently, path to me used to be synonymous with path to current application; but now, with the exception of unsaved scripts in AppleScript Editor, path to me returns an alias to the script file.

Basically, you shouldn’t have to “tell Applescript” anything. But you might occasionally want to use it to distinguish one of its properties from a similarly named property elsewhere.

Well, well. I’ve been doing it correctly without knowing why exactly. :slight_smile: