Re: Editable?
Re: Editable?
- Subject: Re: Editable?
- From: jj <email@hidden>
- Date: Tue, 08 Nov 2005 11:04:40 +0100
- Thread-topic: Editable?
>> Otherwise, if you need it vanilla, this may work (or not):
>>
>> #########################
>> set scpt to read alias "path:to:file.scpt"
>> set isNotEditable to (scpt's item 25 is ((ASCII character 255)) and
>> (scpt's
>> item 26 is (ASCII character 254)))
>> #########################
>>
>
> OK but this will be useless if the script is saved as an application.
> As far as I know, there is no difference between the datafork of an
> editable and the one of a non-editable script when saved as
> application.
> The differences are localised in the resourcefork.
Not useless. I said "ask if needed".
####################################
set fileToExamine to alias "path:to:Unknown Script"
set isDataFork to true
try
set q to read fileToExamine
--> could error "end of file" if res-fork scpt
if q does not start with "FasdUAS" then error
--> didn't find flag of compiled script
on error
set isDataFork to false
end try
if isDataFork then
set scpt to q
else --> extract scpt from resource fork
set resfork to (do shell script "cat " & quoted form of ¬
POSIX path of ((fileToExamine as text) & ":rsrc"))
set scpt to text (offset of "FasdUAS" in resfork) thru -1 of resfork
end if
set isNotEditable to (scpt's item 25 is ((ASCII character 255)) and ¬
(scpt's item 26 is (ASCII character 254)))
####################################
You can add better error trapping, support for more things, such as
application bundles, scptd's, and even FaceSpan applications, but I won't
;-)
jj
--
http://www.macscripter.net/
http://www.osaxen.com/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden