Help required with Quark Applescript, please ......

Hi There,

I’ve been trying to create a script that runs with Quark Xpress 4.1. Basically what I’m trying to do is create a script that when a Quark document is dropped onto it the document will be opened and then a list made of the pic box images with their paths. If the pic box contains nothing then this would be ignored. Once the list has been created I’m wanting to save it as a text document. Here’s what I have so far:-

on open (someitems)

set picList to {}

tell application "QuarkXPress™ 4.1"
	
	activate
	
	repeat with theitem in someitems
		
		open theitem remap fonts no use doc prefs yes
		
		get the count of pages in document 1
		set pagecount to the result
		
		repeat with |pc| from 1 to pagecount -- page loop
			
			set picBoxCount to the count of picture boxes of page |pc| of document 1 -- pic box loop
			
			repeat with i from 1 to picBoxCount
				
				tell picture box i of page |pc| of document 1
					
					set ItemName to (file path of image 1)
					
					set picList to (picList & ItemName)
					
					display dialog ItemName
					
				end tell
				
				
				
			end repeat
			
			
			
		end repeat
		
		set total to the count {picList}
		
		display dialog total
		
		close document 1 saving no
		
	end repeat
	
end tell

end open

As you can see there are a few dialog boxes I’ve put in to see what’s happening. If I cut out all the dialog boxes and the bits where I’m trying to create a ‘list’ of all the images everything works fine. The script loops as it should telling me the names and paths of all the images in the Quark Document.

It’s when I try to store the items in a list a seem to hit the problem, the ‘count’ of the list is 1 not 4 which it should be for the test page I’m using. Can anyone see where I’ve gone wrong?

I’m creating a list of all the pic box images so I can then hopefully create a text document with this list in it. Is this the right way to go with this or can anyone suggest an easier route.

I also tried to put in a check to see if the pic box was empty and giving a ‘null’ result, if it was empty then this would be ignored and not added to the list. I couldn’t get this to work. The check was something like this:-

if ItemName is not equal to “null” then
set ItemName to (file path of image 1)

Any help with this would be appreciated.

Thanks in advance

Nick

This line:

set total to the count {picList}

should be:

set total to the count of picList

The way you had it, the script counts the number of items in a list {} that has one item: piclist.

Thanks for the help, that worked! The script now loops through and displays the correct number of items.
I’ve also added another display dialog that returns all the image names stored in the list however there are no carriage returns so it makes interesting reading. Is there a way of inserting a carriage return after each item in the list?
The ‘null’ entries still crop up, I need to have a look at the ‘if’ statement again. Does anyone have any ideas why that is failing?

Thanks again in advance,

Nick