Scripting a look at the code of another AppleScript

I have an odd question. I have AppleScripts being distributed to a large art department. I always start all of my scripts with the following:

(*Created by Name
Version 1.00

*)

When I make updates I change the version number and make a note of what changed. I wanted this to make it easy to tell if various people had the most current version of the scripts. The only problem is that we decided to save “Run Only” versions of the scripts before we gave them out so people wouldn’t try to make their own modifications. So now I can’t open the script up to see what version it is…

Is there any way to view the code at the beginning of a script using another script? I started creating a droplet that I could drop another AppleScript on to read the beginning of its code. Not sure how to do this. Any Shell commands that might be able to display this? I thought of scripting the script editor but the fact that the scripts will be run only seems like it kills that idea.

Model: G5 - Script Editor ver 2.1.1
AppleScript: 1.10.7
Operating System: Mac OS X (10.4)

I wouldn’t count on it. (Interest standard “You should’ve kept an editable copy” message. :))

I just tried using a hex editor (Hex Fiend), and I couldn’t read any comments. I was able to property names and values though; Of course, if you had properties in your script, you could just check those with AppleScript (using load script).

I am afraid you can’t read script strings due to the inability to retrieve script text in recent (Intel?) system SW
See discussion: http://bbs.applescript.net/viewtopic.php?id=17827

I would welcome any other way to do it.

Interesting. So, I could save the version number as a property. I would add that to all of my scripts as part of my “Standard” scripting format, then I could just pull the properties on individual scripts to check the version. That could definitely work.

For the record, I do have the original editable scripts. It’s the multiple run-only copies that are getting distributed that I need to keep track of. Distributing and managing all these scripts in a large art department has proven to be the most challenging part of this whole AppleScript thing!

Alright, I tried to figure this out myself but I can’t seem to get it. The scripting dictionary is typically cryptic:

load script‚v : Return a script object loaded from a specified file
load script file : an alias or file reference to the file containing the script object
→ script : the script object. You can get this object’s properties or call its handlers as if it were a local script object.

The last line is what I need. What is “arrow-script” supposed to mean??

This is what I have so far for a drop-app to display a property value of a script. I know I need to add some checks for file type and stuff. This is just the basics.

on open ThisScript
	load script ThisScript
	display dialog PropertyVariableThatIKnowExists
end open

Any ideas?

Model: G5 Tower (not Intel) - Script Editor ver 2.1.1
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Let’s say you have this script called “Art.scpt”:

(* Created by Mat
Version 1.0

*)
property _scriptVersion : "1.0"

-- whatever else

You would use something like this:

on open theseItems
	set theScript to load script (first item of theseItems)
	display dialog _scriptVersion of theScript
end open

See also: Script Objects

Another example…

TestScript

(* Created by Mat
Version 1.0

*)
property vernum : "1.0"

(* all the stuff it does *)

on reportVersion()
	display dialog vernum
end reportVersion

and now make it report its version

set scriptPath to (path to desktop as Unicode text) & "TestScript.app"
set libraryScript to load script file scriptPath

tell libraryScript
	reportVersion()
end tell

Hmm so that works and my method above works, though impractical for this use, but something like this doesn’t…

tell libraryScript
	display dialog vernum
end tell

Thats counter to what I was expecting, but I don’t use ScriptObjects very often.

James, try this:

tell libraryScript to display dialog it's vernum