Info on myself (as a script)

This might be a silly question, but …why the first line of the script works and the other doesn’t

my name
--> return the script name

my creation date
--> ERROR

As far as I know, name is a property of the script itself but creation date is a property of the file storing the script.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 11 octobre 2018 21:10:42

Interesting! Based on your input I did:
my name
--> return the script name. OK this is expected!
set collectedInfo to my properties
--> return a list of information

But now the info are on the application I use to edit/run the script. Among those, the “name” is now Script Debugger.

--Interesting! Based on your input I did:
my name
log result
--> return the script name. OK this is expected!
set collectedInfo to my properties
--> return a list of information about the editor

set scriptPath to path of document 1
tell application "System Events"
	set scriptCreationDate to creation date of disk item scriptPath
end telll

I got:
(4ldicroce)
tell application “Script Editor”
get properties
→ {selection:insertion point after character 180 of text of document “4ldicroce.scpt”, frontmost:true, class:application, name:“Script Editor”, version:“2.10”}
get path of document 1
→ “/Users/yvankoenig/Pictures/4ldicroce.scpt”
end tell
tell application “System Events”
get creation date of disk item “/Users/yvankoenig/Pictures/4ldicroce.scpt”
→ date “vendredi 12 octobre 2018 à 11:13:56”
end tell
Résultat :
date “vendredi 12 octobre 2018 à 11:13:56”

It seems logical except perhaps the fact that my name returns the name of the script while my properties return the properties of the application editing the script.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 12 octobre 2018 11:16:04

A script doesn’t have its own identity until it’s saved. Then its name is that of the script file without the extension — UNLESS you set a name property in the script code itself, in which case getting my name will return that instead of name of the file.

property name : "Fred"

my name

I don’t get it.

If I save the script, I get exactly the same with this script:

my name
-- name of the saved scritp on my desktop

set collectedInfo to my properties
-- multiple info in Script Debugger

my creation date
--> ERROR: Can’t get creation date.

Hi.

If you look in the AppleScript Language Guide, you’ll see that AppleScript only defines class, name, id, and version properties for a script. It doesn’t provide properties or modification date properties. If you’re running a script inside either Script Debugger or Script Editor, my properties will return the scriptable properties of the editor. Neither a running script nor either of the editors has a modification date property. Only the files from which they’re launched have that, so a script has to identify its own file and get the modification date from that.

Thanks Nigel for clarifying this !