Picture List script in Quark 6

When running AppleScript in Quark 6 using the following line of code:
set filevar to file path of image i of it as text

Under Event Log, this show up:
get file path of image 10 of page 1 of document 1

Then I get the following error message:
“Can’t make <> of <> 10 of <> 1 of document 1 of application “Quark Express” into a string”

Can anyone please help on this question? Your comments would be greatly appreciated.

This is from an AppleScript originally written by Shirley Hopkins from her book “AppleScripting Quark Xpress”, but slightly modified by me. It worked great in Quark 4.11, (the application code line in the AppleScript below was slightly different), and we used it a lot, but we are currently switching to Quark 6.

The script places a list of pictures, and the pages they came from, into a new Quark document.

–Herbert Ripka
Greendale, WI

P.S. Does anyone know how to contact Shirley Hopkins?

P.P.S. The following is the complete script (which has the above problem in it):

set piclist to “”
set ThePath to “”

tell application “QuarkXPress”
tell default document 1
set properties to {facing pages:false, item spread coords:false}
set properties to {horizontal measure:points, vertical measure:points}
end tell
tell document 1
repeat with p from 1 to (count of pages)
tell page p
repeat with i from 1 to (count of picture boxes in it)
if not (bounds of image 1 of picture box i) = {0, 0, 0, 0} then
set m to the name
set filevar to file path of image i of it as text
set filename to my getfileName(filevar)
set thisline to "Page " & (m as text) & “:” & filename & return
set piclist to piclist & thisline
end if
end repeat
end tell
end repeat
end tell
make document at beginning with properties {page width:(8.5 * 72), page height:(11 * 72), page rule origin:{0, 0}, top margin:36, left margin:36, right margin:36, bottom margin:36}
tell document 1
make text box at beginning with properties {bounds:{36, 36, 730, 574}}
copy piclist to story 1
set properties of story 1 to {font:“Times”, size:10, leading:12, justification:“left”}
end tell
end tell

on getfileName(path)
set pathstr to (path as string)
set lastColon to (offset of “:” in (reverse of (characters of pathstr)) as string) of pathstr
return text from -(lastColon - 1) to -1 of pathstr
end getfileName

Hello!
This should work for you:

set piclist to ""
set ThePath to ""

tell application "QuarkXPress"
	tell default document 1
		set properties to {facing pages:false, item spread coords:false}
		set properties to {horizontal measure:points, vertical measure:points}
	end tell
	tell document 1
		set Startpage to current page
		repeat with i from 1 to (count of picture boxes)
			set current box to picture box i
			show current box
			if not (bounds of image 1 of picture box i) = {0, 0, 0, 0} then
				tell image 1 of picture box i
					set filevar to (file path)
				end tell
				set m to name of current page
				set filename to my getfileName(filevar)
				set thisline to "Page " & (m as text) & ":" & filename & return
				set piclist to piclist & thisline
			end if
		end repeat
		set current box to null
		set current page to Startpage
	end tell
	make document at beginning with properties {page width:(8.5 * 72), page height:(11 * 72), page rule origin:{0, 0}, top margin:36, left margin:36, right margin:36, bottom margin:36}
	tell document 1
		make text box at beginning with properties {bounds:{36, 36, 730, 574}}
		copy piclist to story 1
		set properties of story 1 to {font:"Times", size:10, leading:12, justification:"left"}
	end tell
end tell

on getfileName(path)
	set pathstr to (path as string)
	set lastColon to (offset of ":" in (reverse of (characters of pathstr)) as string) of pathstr
	return text from -(lastColon - 1) to -1 of pathstr
end getfileName

This works in Quark 6, however on a multi-page document the result always shows the first page of the document, even if the images come from later pages.

set thisline to "Page " & (m as text) & “:” & filename & return

m is always the first page of the document

Thank you for your help so far!

–Herb

Make sure you have these two lines:

set current box to picture box i 
         show current box

It might be kind of annoying, but it’s necessary. This selects box i and then shows it to you. By doing this, it knows what page the image is on and sets it in piclist. Without these two lines, the page will alway be logged as whatever page you’re currently viewing.

I have been using AppleScript only over the past few months, and am introducing their use to artists at my company. I had heard that scripts can do wonders for Quark workflows, so I am slowly working my way through Shirley Hopkins’ book. I know just enough to be dangerous.

Thanks again for your help. You have been a lifesaver!

–Herbert Ripka
Greendale, Wisc.

Yep, AS can be fun (and dangerous) especially with Quark.

I hope that my suggestion worked.
T.I.

Instead of

set current box to picture box i
show current box

which jumps around the page showing the current page.

How about this script:

set piclist to ""
set thisline to ""
set filename to ""

tell application "QuarkXPress"
	activate
	tell document 1
		repeat with p from 1 to (count of pages)
			tell page p
				set m to the name
				repeat with i from 1 to (count of picture boxes)
					tell picture box i
						if not (bounds of image 1) = {0, 0, 0, 0} then
							set filevar to file path of image i of it as text
							set filename to my getfileName(filevar)
							set thisline to "Page " & m & ":	" & filename & return
							set piclist to piclist & thisline
						end if
					end tell --picture box i
				end repeat --picture boxes i
			end tell --page
		end repeat --pages p
	end tell --document
	
	make document at beginning with properties {page width:(8.5 * 72), page height:(11 * 72), page rule origin:{0, 0}, top margin:36, left margin:36, right margin:36, bottom margin:36}
	tell document 1
		make text box at beginning with properties {bounds:{36, 36, 730, 574}}
		copy piclist to story 1
		set properties of story 1 to {size:10, leading:12, justification:"left"}
	end tell --document
	
end tell --application

on getfileName(path)
	set pathstr to (path as string)
	set lastColon to (offset of ":" in (reverse of (characters of pathstr)) as string) of pathstr
	return text from -(lastColon - 1) to -1 of pathstr
end getfileName

This took more experimentation to see what works, than actual code-writing!

the secret to getting page numbers of pics in quark 6 docs is using something like this:

get name of page 1 of image 1 (of whatever picture box you are addressing

The page number shows up as 2001 or 2002 if the pic is off the pasteboard to the left or right respectively. the following is a handler that I use to find text that is off the pasteboard. you can batch find page numbers of pics the same way.


on pasteboard(theFolder)
	tell application "Finder"
		set theFiles to (every file of theFolder whose file type is "xprj")
		if (length of theFiles) > 0 then
			repeat with i from 1 to (length of theFiles)
				tell application "QuarkXPress"
					set z to false
					set thisFile to (item i of theFiles)
					open thisFile remap fonts no --open file defined by loop 
					if (exists document 1) is false then
						my logBadPage(name of thisFile & " will not open ")
					else
						tell document 1
							-- set errantText to "0" as integer
							set errantText to (name of page 1 of every text box)
							repeat with j in errantText
								if (j as integer) > 2000 then
									set z to true
								end if
							end repeat
							if z is true then
								my logBadPage(name of thisFile)
							end if


						end tell
						close document 1 saving no --close file without saving it 
					end if
				end tell
			end repeat
		end if
		
		-- starts loop through all subfolders of "myFolder", should handle heirarchy of any depth
		set subfolders to every folder of theFolder
		repeat with this_subfolder in subfolders
			my pasteboard(this_subfolder)
		end repeat
	end tell
end pasteboard