Hi all,
I have been thinking this over and over again. But just don’t get it.
A catalogue. 12 picture boxes on a page with 12 corresponding text boxes.
The user selects some of these 12 picture boxes and then selects a folder with the picture files.
This selection can be (for example) picture box “ThumbPic_07”, “ThumbPic_08” and “ThumbPic_09”.
Users selects three image files and the pics should be placed in the right place. Should be…
Since the list of the selection (SelectedBoxes) is not in the same order as theBoxList (alphabetical) I can’t use this list. So, my idea was to run a repeat loop, check if the item of the selectedBoxes is in theBoxList and then use this box to put the pic in.
Funny thing is (Mmmh… funny. Not.) The results returned are okay. If I change n to thecounter (which counts the pictures already placed) the script does work, but starts to put a pic in ThumbPic_01 instead of _07.
Even if I put a number instead of n, the script is not working.
Now what am I missing in this line?
set thebox to (item 1 of item n of theboxList)
You can find it at the bottom of the script. See also my comments overthere.
Great thanks in advance for those who help me out…
Kjeld
property theboxList : {¬
{"ThumbPic_01", "ThumbSpec_01"}, ¬
{"ThumbPic_02", "ThumbSpec_02"}, ¬
{"ThumbPic_03", "ThumbSpec_03"}, ¬
{"ThumbPic_04", "ThumbSpec_04"}, ¬
{"ThumbPic_05", "ThumbSpec_05"}, ¬
{"ThumbPic_06", "ThumbSpec_06"}, ¬
{"ThumbPic_07", "ThumbSpec_07"}, ¬
{"ThumbPic_08", "ThumbSpec_08"}, ¬
{"ThumbPic_09", "ThumbSpec_09"}, ¬
{"ThumbPic_10", "ThumbSpec_10"}, ¬
{"ThumbPic_11", "ThumbSpec_11"}, ¬
{"ThumbPic_12", "ThumbSpec_12"}}
global SelectedBoxes
global numPicBox
global folderList
global picList
global selPiclist
global thefolder
tell application "QuarkXPress Passport"
tell document 1
set SelectedBoxes to (name of every picture box of selection) as list
set numPicBox to count of items in SelectedBoxes
end tell
end tell
--Select number of images. Repeat when selected amount of images doesn't correspond with the amount of selected boxes.
set thefolder to (choose folder with prompt "Selecteer de map met afbeeldingen.")
set folderList to (list folder (thefolder as alias) without invisibles)
set theSel to false
repeat while theSel is false
set picList to (choose from list folderList with prompt "Selecteer " & numPicBox & " afbeeldingen om te plaatsen." with multiple selections allowed)
set selPiclist to count of items in picList
if (count of items in picList) is greater than numPicBox then
display dialog "Je hebt meer afbeeldingen dan het beschikbare aantal kaders geselecteerd." & return & "Selecteer maximaal " & numPicBox & " afbeeldingen."
end if
if (count of items in picList) is less than numPicBox then
display dialog "Je hebt minder afbeeldingen dan het beschikbare aantal kaders geselecteerd." & return & "Selecteer maximaal " & numPicBox & " afbeeldingen."
end if
if selPiclist is equal to numPicBox then
set theSel to true
end if
end repeat
tell application "QuarkXPress Passport"
tell document 1
--try
set theCounter to 1
repeat with n from 1 to count theboxList --Repeat 12 times ('cause there are 12 pic boxes)
-- try
if (item 1 of item n of theboxList) is in SelectedBoxes then --Everytime when the name of one of the selected boxes is in the picture box list then.
--The following line is causing the trouble.
--When replacing n with theCounter puts a picture in the boxes starting with box ThumbPic_01,
--while this should be 07 or 09 for example...
--Also doesn't work when I replace n with 7 or 9.
set thebox to (item 1 of item n of theboxList)
tell picture box thebox
set color to "magenta" -- Just to check if this part works. It does.
--Put image in box.
set theImage to (thefolder & (item theCounter of picList) as string)
set image 1 to alias theImage
--end try
end tell
set theCounter to theCounter + 1
end if
-- end try
end repeat
--end try
end tell
end tell
{SelectedBoxes, n, thebox, picList, theImage}