Re: osascript and Modification Date of Compiled Script
Re: osascript and Modification Date of Compiled Script
- Subject: Re: osascript and Modification Date of Compiled Script
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 17 Mar 2004 09:32:59 -0800
On 3/17/04 8:39 AM, "Doug McNutt" <email@hidden> wrote:
>
At 08:03 -0800 3/17/04, John W. Baxter wrote:
>
> On 3/17/2004 5:03, "Jeffrey Berman" <email@hidden> wrote:
>
>> Is there a way to run a compiled AppleScript from a Unix shell using the
>
>> 'osascript' command without altering the modification date of the script
>
>> file?
>
>
>
> Yes.
>
> As you wrote the script, TestVar is a global variable. The values of global
>
> variable persist between runs by being stored in the script file (given
>
> well-behaved script runners). Change the script to
>
>
>
> local TestVar
>
>
Another procedure which would not involve messing with the not-so-clear
>
global/local/property definitions in AppleScript would be to go ahead and lock
the script. Then use a UNIX cp on it to a file in /tmp. Use osascript to execute
the copy. Cleanup of the tmp file is not required and it will almost surely be
executed from cache memory anyway.
There's nothing unclear about it. It's perfectly clear. Read the relevant
section of the AppleScript Language Guide or the AppleScript - A Definitive
Guide recently published by O'Reilly. As John said (which you cut),
"Numerous alternative changes are possible which also make the variable not
a global." But why use them when the proper AppleScript solution is
perfectly straightforward. Just do what John said: make an explicit local
declaration in the script file (or call a handler where all variables will
be local by default).
I'm getting a little fed up with this. There's a perfectly good way of doing
this in AppleScript - just learn AppleScript if you're not clear on it. Read
Matt's (O'Reilly) book and refer back to it when necessary.
As far as your UNIX method goes, it's not going to work if the script was
made by Smile or Script Debugger in their default formats - Resource Fork
scripts. Or for Script Editor scripts pre-Panther. It will only work for SE
2.0 scripts in Panther. Otherwise cp won't move the resource fork and you'll
have nothing. You'd need ditto -rsrc instead of cp. Some people would
consider this less clear and more complicated than simply declaring all
variables as local.
--
Paul Berkowitz
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.