Re: store script bloats saved files? (found a solution...
Re: store script bloats saved files? (found a solution...
- Subject: Re: store script bloats saved files? (found a solution...
- From: email@hidden
- Date: Wed, 6 Feb 2002 20:40:32 -0500
On Wed, 6 Feb 2002 16:59:06 +0000, has <email@hidden> noted,
sorts)
>
Even a dirt simple script object created by a constructor function still
>
pulls the entire container script into a saved script file with it.
I was going to write that it was simply a matter of the parent relationship
between scripts. I thought that when scripts were created either in-line or
with a constructor have a parent, when you save the script, it saves the parent
as well, so the script will work as expected. I thought you could just
manipulate the parent property, with either
property parent : AppleScript
of
property parent : missing value
But that didn't cut out parent script bits.
Its more complex than the parent-child link. Since top-level properties and
globals have visibility within script objects, they are also saved in the store
script file. The script object has both dynamic scope linkages and static
scope linkages. And you can't avoid the static linkages unless you don't use
top-level properties.
This script works, and will work even if saved from one script and loaded into
another.
property msg : "Now is the time for all good men to party!"
script Bob
property parent : AppleScript -- Try to break the connection to the
parent script
on A()
display dialog msg
end A
end script
tell Bob to A()
store script Bob in (choose file name)
>
set a to run script "
>
script
>
script b
>
--foo
>
end script
>
--bar
>
end script"
>
>
store script a's b in file "bob:test file 2"
>
>
======================================================================
>
>
This'll include everything in a only. Not beautiful, but it's the result I
>
want.
That example shows that the 'run script' command doesn't run the script in the
context of the calling script. This is why the following script gives an error.
property a : "Hi"
run script "Display dialog a"
--> Error: "Variable a is not defined"
>
The solution seems to be to put stuff into two separate scripts: either as
>
two separate files, or using a run script to create one of them.
That's pretty much it. If you don't want the script to pick up some
information, compile it in isolation.
--
>
One general question: does anyone know if there are any issues or problems
>
with "run script" under the myriad different versions of AS? (I think I
>
might have had the odd problem in the past with it failing to compile and
>
execute bigger, more complex strings, but it's so hard to tell with the
>
damn thing.)
I'd heard that script objects used to cause trouble for script debugger, because
it couldn't look inside of an object, but I understand that's been fixed for a
while now. I've noticed a limitation if a script server application returns a
script object, the event log doesn't show anything useful, just a burst of
<<data afdlfyuafiuofiuafiaafaoifdsayu...>> But other than that, no bugs. A few
misunderstandings on my part, resulting from scoping rules, but no bugs.
>
(p.s. Something else I've noticed is that when saving over an existing
>
script file: if the new object is smaller than the old one, a Get Info the
>
Finder reports that the file is still the old size after the new object has
>
been stored in it. Dunno if that's a bug in the osax or what - and it may
>
have been fixed by now anyway (I'm on AS1.3.7) - but thought I'd mention
>
it.)
Store script doesn't tell the Finder there's been a change, so you may notice
the icon won't show up until the Finder notices a change in the folder's
modification date and reexamines the directory list. I've seen similar Finder
inattention with the 'write' command. (Not the Finder's fault: Standard
Additions just doesn't tell the Finder there's been a change.)
--
Scott Norton Phone: +1-703-299-1656
DTI Associates, Inc. Fax: +1-703-706-0476
2920 South Glebe Road Internet: email@hidden
Arlington, VA 22206-2768 or email@hidden
_______________________________________________
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.