Re: alms for an ex-leper
Re: alms for an ex-leper
- Subject: Re: alms for an ex-leper
- From: julifos <email@hidden>
- Date: Fri, 24 Jan 2003 09:58:32 +0100
>
I have a droplet/applet that I don't understand it's different behavior.
>
------
>
on run
>
set A to {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
>
set KeyList to A
>
set KeyListRef to a reference to KeyList
>
display dialog (a reference to item 1 of KeyListRef)
>
end run
>
>
on open
>
set A to {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
>
set KeyList to A
>
set KeyListRef to a reference to KeyList
>
display dialog (a reference to item 1 of KeyListRef)
>
end open
>
--------
>
If I try it as a droplet first I get the err "Can't make item 1 of
>
KeyList into a string"
>
When I launch it I get the dialog "1"
>
Then trying the droplet again gives the dialog "1"
>
Both work until I save changes to the script, then the droplet options
>
gives an err until I launch it again.
>
Is this normal?
>
What I'm getting at is that I have a sorting routine that only wants to
>
work as an app and not as a droplet.
>
The two seem to handle references differently.
Seems that both routines throw the same result as object to be displayed as
a dialog, and the error is generated when the "display dialog" auto-coerces
the reference to string... Why? Don't know. Why if you "run" ok, you "open"
ok? Don't know. (perhaps results of "run" are stored within the script,
because a fresh copy of this code saved as app gives me 55655 bytes before
running -> 55909 after running) (perhaps the only handler able to "store"
properties, and even locals is "run". If I delete the "display dialog" line
to avoid the error -discarding the "properties not saved because not
successful"-, the "run" handler will increase my script size, but the "open"
one will not).
Anyway, if you're not going to drop files/folders in your app, you can
delete safely the "on open" handler.
And to de-dereference item 1 of KeyListRef, you may define "KeyList" as a
run-time global, so the last reference can find it:
on open
global KeyList
set A to {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
set KeyList to A
set KeyListRef to a reference to KeyList
display dialog ((a reference to item 1 of KeyListRef)'s contents as
string)
end open
JJ
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
_______________________________________________
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.