'Repeat with' question + book recommendation

Is there some way to jump to the middle of a “repeat with” block?

Maybe something like:

repeat with aFile in FileList starting at x

On a loosely related matter, can anyone recommend a good AppleScript book? Especially one that will explain how to interpret AppleScript Dictionary syntax; that stuff makes zero sense to me no matter how many times I read it. I end up guessing and reading error messages until I figure out how it works.

Thanks in advance!

PS: What happened to the FAQ area that used to be here?

You could do something like this…

set letters to {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"}
display dialog "How far in should we start? (From 1 to 11)" default answer ""
set startPoint to text returned of result
repeat with i from startPoint to 11
	display dialog (item i of letters)
end repeat

Try something like this:

count FileList
repeat with i from x to result
	set aFile to item i of result
	-- the rest of your script
end repeat

We have a list of books. If you buy one of them, please give it a review. :slight_smile:

It has been combined with the AppleScript Sourcebook.

In that list of books mentioned above, you will find Hanaan Rosenthal’s AppleScript - A Complete Gude to Scripting and Automation on Mac OS X. I am still utilizing the first edition (published in 2004) - but it is without a doubt my AppleScript bible.

Using that with the information you can garner from this site. You can be up and running in no time.

Hi Scott, IMHO Hanaan’s book is a reference book, the (real) bible is
Matt Neuburg’s AppleScript: The Definitive Guide

Classic.

Having never read Nueburg’s book - I cannot attest to your claim. However, I can tell you that there is no way I am sitting down and reading any of these books cover to cover… and that probably includes the bible! So, in my hands all of the books are reference books.

Here’s another way, but I didn’t test the speed:


set l to {1, 2, 3, 4, 5}
repeat with this_item in items 3 thru -1 of l
	display dialog this_item
end repeat

Reading dictionaries takes experience. If you just continue doing it, you’ll get it.

gl,

Hanaan’s book gives you great coverage of all the basics and more advanced topics. As I recall, the coverage of dictionaries is rather basic. Matt Neuberg’s book is quite excellent, but I think it is much more useful for more experienced programmers as it devotes a lot of coverage to more advanced topics. Matt’s book does contain a real life example of learing the scripting model of an application from scratch and the most revealing insight I derived from this was that even for someone who knows Applescript inside and out, using the dictionary is a “hit and miss” proposition and relies a LOT on trial and error. (sad but true)

An even better investment might be using Script Debugger as that gives you a nice look at the dictionary, PLUS it lets you use the “Explorer” mode to see what all the applescript terms in the dictionary are returning. Even cooler, you can drag and drop stuff from the dictionary explorer window right into your script. This feature alone is worth the price. http://www.latenightsw.com/

Vince

I’m going to fully agree with Vince here… If you’re doing any serious scripting get yourself a copy of Script Debugger… you wont regret it!

Speed is definitely not an issue as we will be displaying Keynote presentation files with the repeat loop.

Can I assume that -1 means “last item” in this context?

Indeed, I was afraid of that. :slight_smile:

Thanks to everyone who replied!

You assume correctly =)