My soul is tormented by Quark (I think)
My soul is tormented by Quark (I think)
- Subject: My soul is tormented by Quark (I think)
- From: "Rips Ethan J" <email@hidden>
- Date: Mon, 7 Oct 2002 17:07:40 -0400
- Thread-topic: My soul is tormented by Quark (I think)
[Length warning]
Hello, scripters-
I bit off more than I could chew when I raised the question last week about
using shell script sorting instead of the Finder in scripts for OS X.
Nonetheless, I'm overwhelmed by the responses. Thank you all, John Delacour,
John Baxter, Rob Jorgenson, Shane Stanley, has, Bill Fancher, Chris Janton,
Randal Schwartz & Paul Berkowitz. You guys amaze me. I have so much to
learn...
Anyway, I'm still trudging away with more mundane stuff. Specifically, I'm
having a devil of a time figuring out what's got to be one of the simplest,
most obvious things in the world-how to save a Quark file to a folder on my
desktop! I think I must be screwing up an object reference, but I can't seem
to find it.
By the way, I never would've gotten as far as I have (however far that is) if
not for the invaluable assistance of Arthur Knapp, Shirley Hopkins, Caryn
Francis & someone whose date code I manhandled into the shape I needed but
whose name I neglected to record. Please don't hold the stuff below against
them...
Here's the offending code (I hard coded a bunch of stuff at the beginning in
an effort to find the gremlins in what is supposed to be a handler):
--Path to Quark template is assigned to var templatePath
property templatePath
: alias "Production:Fact Sheets:= Templates:FactSheetTemplate"
--Assign the
folder's path to var imagepath:
--alias "Thelonious:Desktop Folder:07_02 Fact
Sheets:= Graphics:Pie Charts:Institutional_Class B:"
global imagePath
set
imagePath to (choose folder with prompt "Select the folder of current pie
charts:")
--destination folder for completed fact sheets
--alias
"Thelonious:Desktop Folder:Test f:"
global destFolder
set destFolder to
(choose folder with prompt "Select the destination folder for the fact
sheets:")
--generate 4-digit code for date
copy ((offset of (the month of
(current date)) in ,
"jan feb mar apr may jun jul aug sep oct nov dec ") + 3)
/ 4 ,
as integer to mm
if mm < 10 then copy "0" & mm as string to mm
if ((mm
= 10) or (mm > 10)) then copy mm as string to mm
copy (year of (current date)
as string) to yy
set yr to (yy's text from character 3 to character 4)
copy mm
& yr to dateCode
dateCode
--Convert each finder object (names of files in
imageList) to alias
--NEED TO SUBSTITUTE NON-AS CODE TO SORT CONTENTS OF
IMAGEPATH FOR OS X COMPATIBILITY (later)
tell application "Finder"
--sort
list by name
set imageList to sort (every file of imagePath) by name
--then
coerce each item to alias
repeat with i in imageList
set i's contents to i
as alias
end repeat
--Yields list of aliases
imageList
end tell
--THE CODE
ABOVE WORKS
--repeat loop to insert pie chart in each doc generated via Quark
template
repeat with i in imageList
--set myAlias to "item 1 of {alias
"Thelonious:Desktop Folder:07_02 Fact Sheets:= Graphics:Pie
Charts:Institutional_Class B:132PER-1002.eps""
set myAlias to i
--call name
processing handler, passing each alias plus path to each image & dateCode
getFileName(myAlias, imagePath, dateCode)
end repeat
--CODE WORKS TO THIS
POINT
--handler accesses filename & concatenates to imagePath to set up pie
chart insertion (for each file)
--fAlias is "item 1 of alias
"Thelonious:Desktop Folder:07_02 Fact Sheets:= Graphics:Pie
Charts:Institutional_Class B:132PER-1002.eps""
on getFileName(fAlias,
pathname, dateCode)
try
set fAlias to ("" & pathname & fAlias)
on error
errMsg number errNum
error "getFileName(fAlias) --> " & fAlias & " does
not exist."
end try
set o to text item delimiters
set text item
delimiters to ":"
--ensures that colon is excluded
if (fAlias ends with
":") then
set n to fAlias's text item -2
else
set n to fAlias's text item
-1
end if
--reset TIDs to original setting
set text item delimiters to o
n
--call function to insert pie into Quark doc
insertPie(n, pathname,
dateCode)
end getFileName
on insertPie(chartName, pathStr, dateCode)
try
set docName to (chartName's text from character -13 to character -15) & "PER"
& dateCode
set finalFolder to ("" & destFolder & docName)
set myPie to
(pathStr & docName & ".eps")
set myPie to (myPie as alias)
on error errMsg
number errNum
error "File does not exist." --script stops here.
end try
tell document 1 of application "QuarkXPress(tm)"
if not (document 1 exists)
then
open file templatePath
end if
tell picture box 1 of
document 1
try
set image 1 to myPie
set bounds of image 1 to
centered
on error errMsg number errNum
set image 1 to (choose file with
prompt "Select pie chart:")
set bounds of image 1 to centered
end try
end tell
save document 1 in finalFolder without template
--SCRIPT
CHOKES HERE; "QuarkXPress(tm) got an error: Some parameter wasn't understood."
close document 1 saving yes
end tell
end insertPie
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.