help moving Quark image galley os9 script to osX

I frankenstein-ed an old script to make it work in os9. When I tried to open it in osX, I received compile errors. It worked sweet in os9. I was hoping to use the code in osX. When I comment the errors, and run the script, I get the message that no files were found.

My questions are: Are image ID different in osX as opposed to ox9? When I use the code (( «class fitp» is “EPSF” )), does osX recognize this as EPS files? And why won’t these definitions work:

		--set «class HMEA» to «constant measUPNT»
		--set «class VMEA» to «constant measUPNT»
                 --set «class qpro» to {bounds:{0, 0, grfkheight, grfkwidth}}

I would so appreciate the help. I know it must be simple, but it’s like staring at a wall in the dark. I just don’t see it.

Thanks,

je


on run
	ListContents(choose folder with prompt "Select Folder for Galley") --if double-clicked choose folder
end run

on open of finderObjects -- catch drag'n'drop launches
	ListContents(finderObjects)
end open

on ListContents(theFolders)
	
	tell application "Finder"
		activate
		set theDemoFile to (name of startup disk) & ":applications:tsGalley:app:tsGalley1x"
		set MyGalleyPath to the name of theFolders
		set RBtf1 to "what is this	"
		set RBtf2 to "text box 2	"
		set RBtf3 to "end text box information"
		
	end tell
	
	tell application "QuarkXPress Passport"
		activate
		try
			set theOpenDOcs to name of every document
		on error
			set theOpenDOcs to {}
		end try
		try
			if "tsGalley1x" is not in theOpenDOcs then
				open file theDemoFile given «class KPRF»:«constant KPRFyes », «class RMPF»:«constant RMPFno  », «class KAUP»:«constant KPRFyes »
			end if
		on error
			repeat
				set theChosenDoc to choose file of type "XTMP" with prompt "Where is "tsGalley1x"?"
				set theNameOfTheChosenDoc to my nameOf(theChosenDoc)
				if theNameOfTheChosenDoc is "tsGalley1x" then
					open theChosenDoc given «class KPRF»:«constant KPRFyes », «class RMPF»:«constant RMPFno  », «class KAUP»:«constant KPRFyes »
					exit repeat
				end if
			end repeat
		end try
		
		tell document 1
			--set «class HMEA» to «constant measUPNT»
			--set «class VMEA» to «constant measUPNT»
			
			set theFolder to theFolders
			try
				tell application "Finder"
					set theImageList to every file of theFolder whose kind is not "alias" and ¬
						the «class fitp» is "TIFF" or the «class fitp» is "EPSF" or ¬
						the «class fitp» is "PICT" or the «class fitp» is "JPEG"
					if class of theImageList is not list then set theImageList to theImageList as list
					set theImageNameList to the name of every file of theFolder whose kind is not "alias" and ¬
						the «class fitp» is "TIFF" or the «class fitp» is "EPSF" or ¬
						the «class fitp» is "PICT" or the «class fitp» is "JPEG"
					if class of theImageNameList is not list then set theImageNameList to theImageNameList as list
				end tell
			on error
				beep
				display dialog "No images were found in this folder." buttons {"Cancel"} default button 1
			end try
			
			set theNumberOfImages to the number of items of theImageList
			set theCounter to 1
			set theMasterPage to «class MPID» of «class CUPG»
			
			repeat
				tell «class CUSP»
					set thePictureBoxList to the «class posp» of every «class PICB»
					set theNumberOfPBoxes to number of items of thePictureBoxList
					set theTextBoxList to the «class posp» of every «class TXTB»
					--set i to 1 --repeat with i from 1 to theNumberOfPBoxes
					set «class IMAG» 1 of thePictureBoxList to (item theCounter of theImageList) as alias
					set bounds of «class IMAG» 1 of thePictureBoxList to center
					
					set text flow 1 of (item 1 of theTextBoxList) to (item theCounter of theImageNameList)
					
					---Shrink Picture Box begin
					tell «class PICB» 1 of «class CUPG»
						
						tell «class IMAG» 1
							set grfkbnds to bounds
							
							set grfkwidth to (item 3 of grfkbnds) as real
							
							set grfkheight to (item 4 of grfkbnds) as real
						end tell
						--set «class qpro» to {bounds:{0, 0, grfkheight, grfkwidth}}
						tell «class IMAG» 1
							set bounds to center
							set ImageOffset to «class ofse» as list
							set WidthOffset to (item 2 of ImageOffset) as real
							set HeightOffset to (item 1 of ImageOffset) as real
							set grfkwidth to (item 3 of grfkbnds) - (WidthOffset * 2)
							set grfkheight to (item 4 of grfkbnds) - (HeightOffset * 2)
						end tell
						--	set «class qpro» to {bounds:{0, 0, grfkheight, grfkwidth}}
						tell «class IMAG» 1
							set bounds to center
						end tell
					end tell
					
				end tell
				
				set theCounter to theCounter + 1
				if theCounter > theNumberOfImages then
					--save file stuff begin
					tell application "Finder"
						activate
						set MySavedFile to (name of startup disk) & ":software:tsGalley:Galleys:" & MyGalleyPath
						
						if file (MySavedFile) exists then
							
							tell application "QuarkXPress Passport"
								activate
								try
									set theOpenDOcs to name of every document
								on error
									set theOpenDOcs to {}
								end try
								try
									if "tsGalley.document" is not in theOpenDOcs then
										save document 1 in MySavedFile
									end if
								on error
									display dialog "Document tsGalley.document already open. Please save document with a unique file name."
								end try
							end tell
						else
							
							tell application "QuarkXPress Passport"
								activate
								save document 1 in MySavedFile
							end tell
						end if
					end tell
					--save file stuff end
					
					beep 2
					return
				end if
				set theNewSpread to make new «class sprd» at end
				«event miscmvis» theNewSpread
				set «class MPID» of «class CUPG» to theMasterPage
			end repeat
		end tell
	end tell
end ListContents

on folderPathOf(filePath)
	set reversedFilePath to (reverse of characters of (filePath as text) as text)
	set theOffset to (length of reversedFilePath) - (offset of ":" in reversedFilePath)
	return (characters 1 thru theOffset of (filePath as text)) & ":" as text
end folderPathOf

on nameOf(aFile)
	set aBackwardsFilePath to (reverse of characters of (aFile as text) as text)
	set theOffset to (offset of ":" in aBackwardsFilePath)
	set theOffset to (length of aBackwardsFilePath) - theOffset + 2
	return (characters theOffset thru -1 of (aFile as text)) as text
end nameOf

More info would be helpful, what version of Quark and are you trying to run the script in OS X while using a version of Quark in Classic? As to the reason that your script is returning those odd lines of code they are Quark specific classes that the script editor cannot resolve because it does not have access to the Quark scripting dictionary.

Jerome,

Thanks for the quick reply. I wrote the script orginally for Quark 4.11. It was used in os9 native but tested in Classic.

I now want to use the script exclusively in osX with Quark 6.5. I have an intel imac core duo, but I also wish to run it on my powerbook 1.5 ghz.

With your experience, am I better off starting from scratch, or working with this script?

I appreciate the feedback.

Regards,

je

Model: iMac 1.83 GHz Intel Core Duo, 2 gm sdram
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

First go back to the computer with OS 9, save out the script as a text file, you also might want to print it for reference. Then open it on the iMac, it should be uncompiled at this time. Change the name of the application to just Quark, or anything else really, and click the compile button. When asked to locate the application point it to Quark 6.5. It should compile correclty now. Next you will have to test and trouble shoot it to make sure it is working correctly, there were changes to the scripting between the versions. If you still have classes that are not plain text («class PICB») then go back to your print out and type them in again and recompile and trouble shoot.

Thanks again. That worked. It makes sense as well.

Now, the scripts runs correctly, but it does not find images in folders where images exist.

I am assuming that osX recognizes images (or all files) differently than os9. That is my next step. Thanks for the help.

je

Model: iMac 1.83 GHz Intel Core Duo, 2 gm sdram
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Below is the code that I use to build a file list for my InDesign image catalog script. You should be able to call it by changing your try block to the finder to:

tell me to set theImageList to BuildList(theFolder)

Eleminate any file types and extension that you don’t want placed from the FileTypes and TileExtension lists. It will build a list of all the sub folders as well and sorts the list


on BuildList(DroppedItems)
	set FileTypes to {"TIFF", "EPSF", "JPEG", "8BPS", "PDF "}
	set FileExtension to {"tif", "eps", "jpg", "psd", "pdf"}
	set NewList to {}
	repeat with AType from 1 to (count of FileTypes)
		if item AType of ImageFormats of MyDocPrefs is true then
			repeat with AnItem in DroppedItems as list
				set AnItem to AnItem as string
				if the last character of AnItem is ":" then
					tell application "Finder"
						set FileList to (files of entire contents of alias AnItem whose file type is (item AType of FileTypes) or name extension is (item AType of FileExtension) as list)
					end tell
					repeat with AFile in FileList
						set AFile to AFile as string
						set NewList to NewList & AFile
					end repeat
				else
					tell application "Finder"
						if file type of alias AnItem is (item AType of FileTypes) or name extension of alias AnItem is (item AType of FileExtension) then set NewList to NewList & AnItem
					end tell
				end if
			end repeat
		end if
	end repeat
	set NewList to sort_list_X(NewList)
	return NewList
end BuildList
--=======================
on sort_list_X(the_list)
	set OldDelim to AppleScript's text item delimiters
	set AppleScript's text item delimiters to ":"
	copy {{}, {}, (count of the_list)} to {index_list, sorted_list, list_count}
	repeat list_count times
		set low_item to {}
		repeat with i from 1 to list_count
			if i is not in index_list then
				set list_item to item i of the_list
				if low_item = {} then
					copy {list_item, i} to {low_item, low_item_index}
				else if (last text item of list_item) comes before (last text item of low_item) then
					copy {list_item, i} to {low_item, low_item_index}
				end if
			end if
		end repeat
		copy {low_item, low_item_index} to {(end of sorted_list), (end of index_list)}
	end repeat
	set AppleScript's text item delimiters to OldDelim
	return sorted_list
end sort_list_X
--=======================

Thanks to all who responded or read this thread. I learned quite a bit in just tweaking my old script.

I have a feeling I could get pretty good just reading through the posts here.

I hope that one day I can post help for someone else.

Like an old Kung Fu master once said, It is an honor to be a student and a responsibility to be a teacher. Each day we learn so we can teach.

Thanks again.

je

Model: iMac 1.83 GHz Intel Core Duo, 2 gm sdram
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)