• 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
Passed lists, references, and occasional errors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Passed lists, references, and occasional errors


  • Subject: Passed lists, references, and occasional errors
  • From: "Nigel Garvey" <email@hidden>
  • Date: Sat, 19 Apr 2008 13:40:50 +0100

This script is contrived to illustrate something I ran into this morning:

  on aHandler(aList)
    script o
      property l : aList
    end script

    item 1 of o's l

  end aHandler

  try
    repeat with i from 1 to 100
      aHandler(characters of "abcdefghijklm")
    end repeat
  on error msg
    display dialog msg & return & "on iteration " & i & "."
  end try

Most times, on both my Jaguar and Tiger machines, it displays a message
to the effect 'Can't get item 1 of characters of "abcdefghijklm". on
iteration 34.' (The iteration number seems to depend on the speed of the
machine, the way the script's run, and the length of the string.) When
it's run without the 'try' block in Script Editor, the line 'item 1 of
o's l' is highlighted by the error. The questions that puzzle me are:

1. Why does it only error sometimes?
2. How does the handler know that the list is derived from the characters
of "abcdefghijklm"?

The error never occurs if:

1. The handler's passed an _explicit_ reference.

  aHandler(a reference to characters of "abcdefghijklm")

2. The characters are explicitly 'got' beforehand.

  aHandler(get characters of "abcdefghijklm")

3. o's l is initialised to an explicitly dereferenced aList.

  on aHandler(aList)
    script o
      property l : aList's contents
    end script

4. o's l is _set_ to aList.

  on aHandler(aList)
    script o
      property l : missing value
    end script

    set o's l to aList

5. aList is used instead of o's l in the problem line.

  item 1 of aList


Words of one syllable, please.


NG

 _______________________________________________
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: Passed lists, references, and occasional errors
      • From: has <email@hidden>
    • Re: Passed lists, references, and occasional errors
      • From: Ed Stockly <email@hidden>
    • Re: Passed lists, references, and occasional errors
      • From: Philip Aker <email@hidden>
  • Prev by Date: Re: Passing argumenst to C executable from Apple script
  • Next by Date: Re: Passed lists, references, and occasional errors
  • Previous by thread: Re: Deleting "cached" items from the volumes folder
  • Next by thread: Re: Passed lists, references, and occasional errors
  • Index(es):
    • Date
    • Thread