Puzzle Of the Day
Puzzle Of the Day
- Subject: Puzzle Of the Day
- From: "R. Nelson Byrne" <email@hidden>
- Date: Fri, 20 Aug 2010 14:15:10 -0700
Thanks all for the help and advice with System Events. I hope you can
spare me some more.
Here's where I'm stuck now. I have a folder with four files in it, two
of which are jpgs. I wanted to loop over them and have Graphic
Converter do some work on them (actually, I had a much larger folder
to begin with). So I had Finder get me a list of all the "jpg" files
in the folder, as a list of aliases. So far, so good.
Next I called up Graphic Converter and within its tell block I set up
a repeat loop over the items in the list. GC choked on the very first
one, and its error message told me that it had bitten off the entire
list, not just the item in the repeat loop. Puzzling.
So I put in some log statements to compare the first repeat item with
what I knew it would turn out to be and the log told me:
They are both aliases, they look the same, but they are not the same.
OK. OK.
Must be something weird about repeat loops in a tell block (that would
be too awful to believe, but I was desperate.) So I took out the GC
tell block and now I have:
------------------------------------------
alias "Miele HD:Users:rnb:Desktop:Trim me:" returning MyPODfolder
tell application "Finder" to get (files of MyPODfolder whose name ends
with "jpg") as alias list returning MyPODjpgs
alias "Miele HD:Users:rnb:Desktop:Trim me:A photo.jpg" returning bjpg
repeat with ajpg in MyPODjpgs
log (ajpg is bjpg)
log {"ajpg: ", ajpg}
log {"bjpg: ", bjpg}
log {"Class of ajpg: ", class of ajpg}
log {"Class of bjpg: ", class of bjpg}
exit repeat
end repeat
-----------------------------------------
Now the log reads:
------------------------------------------
tell application "Finder"
get every file of alias "Miele HD:Users:rnb:Desktop:Trim me:" whose
name ends with "jpg"
{alias "Miele HD:Users:rnb:Desktop:Trim me:A photo.jpg", alias
"Miele HD:Users:rnb:Desktop:Trim me:B photo.jpg"}
(*false*)
(*ajpg: , Miele HD:Users:rnb:Desktop:Trim me:A photo.jpg*)
(*bjpg: , Miele HD:Users:rnb:Desktop:Trim me:A photo.jpg*)
(*Class of ajpg: , alias*)
(*Class of bjpg: , alias*)
end tell
------------------------------------------
One odd thing is that I didn't use an explicit tell block for Finder;
I just wrote "tell application "Finder" to get ..." and yet the log
output looks like it comes from within a Finder tell block.
Another odd thing is that ajpg and bjpg look the same to me - BUT ARE
NOT THE SAME! (that's the *false* in the log).
Perhaps it means that ajpg is a item in a repeat loop, or a reference
to such a thing, whereas bjpg is ???? But they sure look the same
according to the log.
Even if I get past this, I still have to find out why GC tries to open
the entire list (how would it know there was a list anyway?) instead
of the item selected for it by the repeat loop.
Maybe I have a typo I just can't see, maybe I'm breaking some rule,
maybe I myself am loopy. Anyway, I would appreciate help.
TIA
Nelson
PPC dual G5, 10.5.8, Script Editor Version 2.2.1 (100.1), AppleScript
2.0.1
_______________________________________________
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