• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: alms for an ex-leper
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: alms for an ex-leper


  • Subject: Re: alms for an ex-leper
  • From: Paul Berkowitz <email@hidden>
  • Date: Thu, 23 Jan 2003 22:56:17 -0800

On 1/23/03 12:17 PM, "Bill Metzinger" <email@hidden> wrote:

> 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.

global KeyList

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

--> "1"

'a reference to' likes globals. Otherwise you can do it this way (same speed
advantage as 'a reference to', actually faster, known as "Serge script
objects"):


on open
set A to {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
set KeyList to A
script keyScript
property KeyListRef : KeyList
end script
display dialog (item 1 of keyScript's KeyListRef)
end open

--> "1"


Similarly, in the run handler (explicit or implicit), as fast as handler
script objects and faster than 'a reference to':


on run
set A to {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
set KeyList to A
display dialog (item 1 of my KeyList)
end run

--> 1

which will also work in a handler if you declare Keylist as a global.





--
Paul Berkowitz
_______________________________________________
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.

References: 
 >alms for an ex-leper (From: Bill Metzinger <email@hidden>)

  • Prev by Date: alms for an ex-leper
  • Next by Date: Re: alms for an ex-leper
  • Previous by thread: alms for an ex-leper
  • Next by thread: Re: alms for an ex-leper
  • Index(es):
    • Date
    • Thread