• 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: a question about accessing list items through a reference
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a question about accessing list items through a reference


  • Subject: Re: a question about accessing list items through a reference
  • From: Tetsuro KURITA <email@hidden>
  • Date: Thu, 31 May 2007 13:41:16 +0900

I could resolve my problem by myself.I looks that nobody is interested in
myproblem. But I will introduce my experience, because someone will meet
sameproblem. Also even now I have unsolved questions. Therefore I hope
authority's comments.

A reference to an item of a list may usually appear in a loop of "repeat with ~ in ~" statement  as follows.

(* Script A *)
property a_list : {1, 2}
repeat with ref_to_item in a_list
    set contents of ref_to_item to 3
end repeat

Above script works well. But very slow. As well known, to accelerate
loop,items of AppleScirpt's list must be accessed through a reference to a
list or script object as follows.

(* Script B *)
property a_list : {1, 2}
repeat with ref_to_item in my a_list
    set contents of ref_to_item to 3 -- error of number -10006
end repeat

But this script does not work. Someone says I can drop "my" before "a_list".
But we need "my" in the point of view of the performance, and it should be
considered that the list is in the other script object in some cases.

Accidentally I found the following scripts works well.

(* Script C *)
property a_list : {1, 2}
repeat with ref_to_item in (a reference to my a_list)
    set contents of ref_to_item to 3
end repeat

I could have obtained what I wanted. But I could not understood what happen.
Why does not "Script B" works ?
Why does "Script C" works ?

> I found a strange behavior when accessing list items.
>
> The following code works.
>
> property a_list : {1, 2}
> set a_ref to a reference to item 1 of a_list
> set contents of a_ref to 3
>
> But following code does not works with error of number -10006.
>
> property a_list : {1, 2}
> set a_ref to a reference to item 1 of my a_list
> set contents of a_ref to 3
>
> Is it a bug ?


=======================================================
 Tetsuro KURITA
  E-mail: email@hidden
  http://homepage.mac.com/tkurita/scriptfactory/en/
=======================================================


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: a question about accessing list items through a reference
      • From: Philip Aker <email@hidden>
References: 
 >a question about accessing list items through a reference (From: Tetsuro KURITA <email@hidden>)

  • Prev by Date: Re: [ANN] Script Timer 2.5 released by Apps & More Software Design
  • Next by Date: Re: InDesign, current view
  • Previous by thread: a question about accessing list items through a reference
  • Next by thread: Re: a question about accessing list items through a reference
  • Index(es):
    • Date
    • Thread