Re: POSIX and lists question
Re: POSIX and lists question
- Subject: Re: POSIX and lists question
- From: Andrew Oliver <email@hidden>
- Date: Wed, 10 Aug 2005 18:44:55 -0700
On 8/10/05 5:47 PM, "aaron spesard" <email@hidden> wrote:
> Why doesn't this work?
>
> set theFiles to {}
> set n to 1
> repeat with counter from n to (count of thePaths)
> -- thePaths is a bunch of PDFs dropped on the window.
>
> set placedPDF to item n of thePaths
> set PPDF to POSIX file placedPDF
> set item n of theFiles to PPDF
> end repeat
>
> I get an applescript error saying: "Can't set item 1 of "" to file
> "blah/blah/blah.pdf"."
This has nothing to do with the fact that you're using POSIX paths, but all
to do with the way you're trying to build your list theFiles.
The issue is that you're trying to 'set item n of theFiles' to some value.
In order to do this AppleScript first evaluates 'item n of theFiles' and
would then change its content to the specified value. The issus is that you
cannot get item 1 of an empty list, just like you can't get the 10th item
from a 9-item list
You need to change the way you build your list. The classic solution is to
build a new list that includes the new item:
set theFIles to theFiles & PPDF
But a better solution is to append the new item to the end of the list:
set end of theFiles to PPDF
Both these options will extend the list with the new item.
Andrew
:)
_______________________________________________
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