Re: Saving handler-defined scripts without source code
Re: Saving handler-defined scripts without source code
- Subject: Re: Saving handler-defined scripts without source code
- From: Andy Wylie <email@hidden>
- Date: Sun, 12 Jan 2003 22:09:53 +1300
on Sat, 11 Jan 2003 17:05:28 +1100 Steven Angier wrote:
>
On 11/1/03 9:23 AM, "Arthur J. Knapp" <email@hidden> wrote:
>
>
>> Does anyone know how to save a handler-defined script so that its source
>
>> code is not stored in the file? I have several rather large objects wrapped
>
>> in constructor functions which tip the scales at around 100 KB when they
>
>> should only be around 20 KB.
>
>
>
> The great Richard 23, in a rare on-list appearance last year, showed us
>
> how to do this very thing:
>
>
>
> <http://lists.apple.com/mhonarc/applescript-users/msg31751.html>
>
>
Thanks for digging this up, Arthur -- but I think mine is a different
>
problem. In my example the file bloat is not due to the handler-contained
>
script's parent scope being stored, but to the actual source code of the
>
handler-contained script being stored. I guess that the compiler doesn't dig
>
more than one level down when generating run-only code.
>
It might be different but I think it may help to understand some facet
(store script?) of global garbage collection, this script's test shows
persistant garbage from its largest items, it uses Satimage OSAX's 'put
resource' to reclaim space, does anyone know of a less brutal solution?
script _store
property parent : AppleScript
on scpt(x)
script
property data : x
end script
end scpt
end script
to g0scpt()
+data
rdat4661736455415320312E3130312E31300E000000040FFFFFFFFE0001000201FFFF000001
FFFE00000E000100000F1000020003FFFD0003FFFC01FFFD00001000030001FFFB0AFFFB0004
0A726461740AFFFC00040A6D736E6700617363720001000DFADEDEAD;
end g0scpt
property _0scpt : g0scpt()
to _save(x, pStr)
my _store's scpt(x)
store script result in file pStr replacing yes
_gDat(pStr)
end _save
to _gDat(pStr)
try
tell application "Finder" to (update file pStr)'s size
{size:result, data:(load script alias pStr)'s data}
on error m number n
if n = -2763 then
_zero(pStr)
_gDat(pStr)
else
error {n, m}
end if
end try
end _gDat
on _zero(pStr)
put resource my _0scpt to file pStr type "scpt" index 128
_gDat(pStr)
end _zero
--test
property pStr : (path to "desk") & "abc r23" as string
_save(application "Finder"'s selection, pStr)
--> {size:1449.0,
data:{file "abc r23" of application "Finder"}}
_save(application "Finder"'s selection, pStr)
--> {size:1449.0,
data:{}}
_zero(pStr)--Satimage OSAX
--> {size:511.0,
data:missing value}
_save(application "Finder"'s selection, pStr)
--> {size:1077.0,
data:{}}
_____________________________ Andy
_______________________________________________
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.