Re: Weird... (but quite logical really)
Re: Weird... (but quite logical really)
- Subject: Re: Weird... (but quite logical really)
- From: Kai Edwards <email@hidden>
- Date: Thu, 14 Mar 2002 03:41:39 +0000
on Wed, 13 Mar 2002 13:54:16 -0600, mjn <email@hidden> wrote:
>
Can anyone explain this to me?
>
>
This works:
>
set aliasFileList to (startup items folder)'s files
>
>
>
This works:
>
set aliasFileList to (desktop)'s files
>
>
>
Neither of these seem to work:
>
set aliasFileList to {(startup items folder)'s files, (desktop)'s files}
>
or
>
set aliasFileList to (desktop)'s files
>
set aliasFileList's end to (startup items folder)'s files
They worked for me when I wrapped them in a Finder tell block - which is
what I assume you did, too.
It makes it easier to diagnose a snag if you can clarify what you're trying
to do - and include the whole script (so that anyone trying to help you can
see the problem in context).
This is actually where I think your script didn't work:
>
The script assigns them to the reference but when it tries to accessing the
>
value, say with a repeat loop, all of the items added from the second
>
location (either in desktop in the first example or startup items in the
>
second one), fail. This is apparently because they are not being
>
referenced properly (doc 1&2 are on the Desktop and doc 0 is in startup
>
items):
OK - so you're trying to do something with a repeat loop, right?
>
--> Can't get kind of {file "Document 1" of application "Finder", file
>
"Document 2" of application "Finder"}
>
>
Whereas the others succeed like this:
>
>
get kind of file "Document 0" of folder "Startup Items" of folder "System
>
Folder" of startup disk
>
--> "PDF Document"
... and it looks like you're attempting to find out the 'kind of'
information for every file you've got listed.
>
So what is the difference in these assignments?
In the first 2 examples (the ones you say work), you get a list of files.
A simple list might look like this:
-------------------------------
{"item 1", "item 2", "item 3"}
-------------------------------
(Let's call this list1)
In the second 2 examples (the ones you say don't work), you're working with
2 lists. Again, to keep it simple, let's say they are:
-------------------------------
list1
--> {"item 1", "item 2", "item 3"}
and
list2
--> {"item a", "item b", "item c"}
-------------------------------
Now, if you say something like:
-------------------------------
set myList to {list1, list2}
-------------------------------
what you'll produce is this:
--> {{"item 1", "item 2", "item 3"}, {"item a", "item b", "item c"}}
- which is a 'compound' primary list containing 2 secondary lists.
However, if you say:
-------------------------------
set myList to list1
set myList's end to list2
-------------------------------
what you'll get instead is this:
--> {"item 1", "item 2", "item 3", {"item a", "item b", "item c"}}
- which is a 'compound' list containing 3 items and a secondary list (which
itself contains 3 more items).
If you use a repeat loop to analyse each item of a simple list, it should
work. However, with a compound list, some 'items' will not actually be items
- but secondary lists. As you might imagine, this is bound to cause any
'item' analysis to fail.
There are a couple of ways around this...
Firstly if you want to analyse each item in several lists (and you know for
certain that every 'item' in the primary list will actually be a secondary
list), you might use a double repeat loop - something like this:
----------------------------------------
repeat with secondaryList in primaryList
repeat with theFile in secondaryList
--analyse theFile as required
end repeat
end repeat
----------------------------------------
However, a much simpler way would be to concatenate the lists into a single,
primary list...
Instead of:
-------------------------------
set myList to {list1, list2}
--> {{"item 1", "item 2", "item 3"}, {"item a", "item b", "item c"}}
-------------------------------
try this:
-------------------------------
set myList to list1 & list2
--> {"item 1", "item 2", "item 3", "item a", "item b", "item c"}
-------------------------------
- which you can then operate on as you would any other list.
So, if you apply this approach to your own situation:
-------------------------------
tell application "Finder"
set aliasFileList to (startup items folder)'s files & (desktop)'s files
end tell
-------------------------------
- this should return what I believe you may be trying to produce. You can
then continue with whatever analysis you're trying to carry out.
I apologise for the somewhat lengthy reply, but the subject can cause
confusion - and I couldn't come up with a briefer explanation! ;-)
Kai
--
**********************************
Kai Edwards Creative Resources
1 Compton Avenue Brighton UK
Telephone +44 (0)1273 326810
**********************************
_______________________________________________
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.