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