Thank you all for such a brilliant forum. In the past two weeks I've gone from knowing nothing about scripting to compiling two scripts which do exactly as I need thanks mostly to contributors to this forum.
My question is about WHY my script works. I can understand most of the syntax I've been working with (sort of) but I can't get my head around this one....
The script is based on one from the thread "[AS] Indesign CS - place image into existing frame" (thanks Matt McGregor and Shane Stanley).
-- Thanks to all Adobe Forums contributors for generously publishing sections of code which new users can use to build their own
-- This version selects images from a specific folder
-- Script needs to be altered to automatically select the relevant "eps files" folder
tell application "Finder"
set dsFolder to "Macintosh HD:Users:Design:Desktop:Scripting:8076707_Qld WC:eps files:"
set dsPics to every item of folder dsFolder
tell application "Adobe InDesign CS2"
set dsDocument to active document
set dsLayer to layer 4 of dsDocument
set FrameNo to 1
repeat with dsPicItem in dsPics
place dsPicItem as alias on rectangle FrameNo of dsLayer
fit rectangle FrameNo given content to frame
set FrameNo to (FrameNo + 1)
How does the script understand the term dsPicItem when it hasn't been defined?
How does the script know to place one instance of each image (rather than, say, repeating the first image in every frame)?
On 3/7/08 1:46 PM, "myDwayneSmith" <email@example.com> wrote:<br /><br />> How does the script understand the term dsPicItem when it hasn't been defined?<br />> How does the script know to place one instance of each image (rather than,<br />> say, repeating the first image in every frame)?<br /><br />When you say "repeat with dsPicItem in dsPics", you're saying to put a<br />reference to the first item of dsPics into dsPicItem, then next time around<br />put the second item, and so on. It's just a shorter way of saying:<br /><br />repeat with i from 1 to count of dsPics<br />set dsPicItem to item i of dsPics<br /><br />Sometimes it can cause problems (because of the way references work), so the<br />"longer" way is a better habit to get into.<br /><br />-- <br />Shane Stanley <firstname.lastname@example.org>