Re: Why do I get this error?
Re: Why do I get this error?
- Subject: Re: Why do I get this error?
- From: kai <email@hidden>
- Date: Thu, 20 Apr 2006 09:07:52 +0100
On 20 Apr 2006, at 08:35, Michelle Steiner wrote:
The following code generates an error. The only difference between
the two scripts is the word "the" before "end".
[snip]
set thePack to items 1 through (foo - 1) of thePack & (items (foo +
1) through end of thePack)
[snip]
set thePack to items 1 through (foo - 1) of thePack & (items (foo +
1) through the end of thePack)
[snip]
The error is this:
tell current application
random number from 1 to 52
11
get items from item 12 to "2C"
"Can't make items from item 12 to \"2C\" into type reference."
"items (foo + 1) through the end of thePack" is highlighted
Seems it's a parsing thing, Michelle. The insertion of the word "the"
causes the expression "end of thePack" to be evaluated before the
reference expression "items (foo + 1) through end".
So instead of evaluating the reference expression as [items x through
-1] and then applying that to the list 'thePack', the script first
evaluates "the end" (item -1) of thePack as "2C" - and then can't
make sense of the reference expression [items x through "2C"].
Introducing parentheses should cause a change in the sequence of
evaluation and fix the error:
set thePack to items 1 through (foo - 1) of thePack & ((items (foo +
1) through the end) of thePack)
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden