Hello,
I want to find the colour of a text box. I’ve written applescript that extracts the blend, and then extracts the list that I want, but then when I try to get the actual colour I’m getting an error message that says I can’t convert a class <> into a string. Which is a pity I’m at the stage where I know I’m getting to the correct Russian doll, but I can’t quite open this last one!
tell application "QuarkXPress"
--activate
tell document 1
tell page 1
tell text box 2
copy (blend of it as list) to strValue
copy (item 2 of strValue as list) to myList
-- This line is where the errors occur
set strItem to (item 1 of myList as string)
end tell
end tell
end tell
end tell
The exact error message is Can’t make <> “Black” of document “xxx.qxp” of < 2 of <> 1 of document 1 of application “QuarkXPress” into type string.
Any help anyone could provide would be very welcome.
There may be more honest ways of doing this, but something like
try
set strItem to (item 1 of myList as string)
on error errmsg
set {saveDelims, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "\""}
set strItem to text item 2 of errmsg
set AppleScript's text item delimiters to saveDelims
end try
may get you what you’re looking for.
Also (alternatively?), upon second look, I think you may want to reparenthesize
(item 1 of myList as string)
as
(item 1 of myList) as string
Dan
Edit: Added “AppleScript’s” since inside a Quark tell block.
Hello Dan,
I’ve tried them, and they don’t work. I tried altering the statement set strItem to (item 1 of myList) as string first, and that altered nothing, and then I tried to capture the error message as you suggested. The lines that deal with saveDelims have no effect on the errmsg, I assume the idea is to catch the error message than to create a list with those items that have quotes around them. As you point out though I’d expect there to be a more legitimate way of doing this, after all we write code that shouldn’t throw errors, or at least we try.
Thanks for the speedy reply,
Dan.
P.S: I like the quote, I noticed that yesterday, it made me chuckle.
tell application "QuarkXPress"
tell document 1
tell page 1
tell text box 2
copy (blend of it as list) to strValue
set strItem to name of item 2 of strValue
end tell
end tell
end tell
end tell
strItem
strItem is “White” when I try it.
From “Lost Skeleton of Cadavra”, which appeals to my infantile sense of humor