Need help getting a droplet loop using Xcatalog and Quark

I am pretty new to AS and I am having trouble getting my first looping droplet to work. I want to make a droplet that sequentially opens each of the group of Quark files dragged to it, runs the same process on each file (using the Xcatalog extension) and then closes the file without saving it.
I am not sure if my loop code is messed up, or if i am doing something wrong in the Xcatalog code. If anyone has experience scripting Xcatalog that would be GREAT!
I am running Quark 6 and Xcatalog extension version 6. Both are the most recent releases.
The error that I get is: Can’t get item 1 of {alias “path:to:item:dropped:on:app”}.
The following is the droplet that I have written so far:


on open (droppedItems)
	set DDpath to "Macintosh HD:Users:gretchenm:Documents:pricing extract test:N048.dd" as alias
	set savePath to "Macintosh HD:Users:gretchenm:Documents:pricing extract test:dataAS.tsv" as alias
	repeat with thisItem in droppedItems
		tell application "QuarkXPress"
			activate
			open thisItem remap fonts no
			update data using file savePath DD DDpath data format tab delimited with pictures ignored, hidden layers ignored, record creation and unquoted data
			close thisItem saving no
		end tell
	end repeat
end open


Does this one help you to find out? I experienced the some problem once, but can’t remember now what was wrong.

set theFolder to choose folder --Folder with files you want to process
set theFiles to list folder theFolder without invisibles
set fileTypes to {"XDOC", "XPRJ"}
set theFolder to theFolder as string
set thePath to "PS 6.1:Productie:01 Bewerkte Quarkbestanden:" --Path to folder where you want to save the files.

repeat with i from 1 to number of items in the theFiles
	set thisFile to item i of the theFiles
	set thisFile to (theFolder & thisFile) as alias
	set theInfo to info for thisFile
	set fileName to the name of theInfo as text
	set typeOfFile to file type of theInfo as text
	if typeOfFile is in fileTypes then --Check if it is a Quark doc..
		
		tell application "QuarkXPress Passport"
			try
				open thisFile use doc prefs yes remap fonts no do auto picture import no with reflow
				
				--Paste your actions here.
				
				save document 1 in (thePath & fileName)
				close document 1 --saving yes --(if you use saving yes after close doc 1 then delete the previous line.)
			end try
		end tell
		
	end if
end repeat

Using the folder method that you suggested seems to be working. The problem now is that only the first file gets processed. The loop opens and processes the first file fine, but then it opens the second file and gives me an “xcatalog failed” error from my try statement.

Is there a problem with the way that my AS is written that could cause this or is it a problem with the Xcatalog command? The Xcatalog command is designed to append the info from each document to the end of one file.

If it is a problem with the Xcatalog command, is there any way that I can get more info about why it is failing?


set theFolder to (choose folder with prompt "Pick the folder containing the files to process. Folder must ONLY contain Quark documents!") as string --Folder with files you want to process
tell application "System Events"
	set theFiles to list folder theFolder without invisibles --make a list of the files
end tell
set thePath to "Macintosh HD:Users:gretchenm:Documents:pricing extract test:dataAS.tsv" --Path to file where data is exported
set DDpath to "Macintosh HD:Users:gretchenm:Documents:pricing extract test:N048.dd" --Path to location of DD file

repeat with i from 1 to the count of theFiles --start repeat loop for each file
	set thisFile to (theFolder & (item i of theFiles)) as alias
	tell application "QuarkXPress"
		activate --bring Quark application to the front
		try
			open thisFile remap fonts no --open file defined by loop
		on error
			display dialog ("open failed " & thisFile) buttons {"Cancel"} default button 1
		end try
		try
			update data using file thePath DD DDpath data format tab delimited with pictures ignored, hidden layers ignored, record creation and unquoted data --this is the part where Xcatalog does its work
		on error
			display dialog ("Xcatalog failed " & thisFile) buttons {"Cancel"} default button 1
		end try
		try
			close document 1 saving no --close file without saving it
		on error
			display dialog "close failed" buttons {"Cancel"} default button 1
		end try
	end tell
end repeat

Perhaps the XCatalog command needs some more time to process before the script goes to the next step? Does a time out helps?

Thanks for the advice. I just tried it and the timeout does not help.
It seems, according to the error codes that I am getting, that it is a problem with Xcatalog. I am exporting the price data from the Quark files with a different DataDescription than was used to create them. Unfortunately, the actions that I apparently need to fix this problem are not in the dictionary.
I will have to start bugging the software company that wrote the extension to get a work-around.

Thanks for the help.
I finally got the *#&$&^$ thing to work.
It turned out to be a problem with the syntax of the Xcatalog command. I finally figured it out by process of elimination.
If anyone needs help scripting Xcatalog in Quark, let me know and I will be glad to help.