I am very new to applescript and am trying to create a script to run in Quark that will take text from the clipboard and put it into a selected text box. The catch is that the text in the clipboard will have words in it that have brackets (ex. “[ aword]”)[applescript around them that need to be made bold and the brackets removed. I have come up with the following code so far. It is one of my first attempts so be gentle and thank you so much for any help!
tell application "QuarkXPress"
-- open quarkxpress if it is not open
activate
-- make sure there is a document open
if (exists (document 1)) then
-- pull the information from the clipboard
set theclip to the clipboard
tell document 1 to set story 1 to theclip
-- initialize the brace holders
set brace1 to 1
set brace2 to 1
set brace1offset to 1
set brace2offset to 1
repeat while brace1offset > 0
tell application "Finder"
set brace1offset to (offset of "[" in (characters brace1 thru (length of theclip) of theclip) as string)
set brace2offset to (offset of "]" in (characters brace2 thru (length of theclip) of theclip) as string)
set brace1 to brace1 + brace1offset
set brace2 to brace2 + brace2offset
end tell
if brace1offset > 0 then
tell document 1 to set style of characters (brace1 + 1) thru (brace2 - 2) of story 1 to bold
end if
end repeat
else
display dialog "You must have a window open" buttons {"I Am Stupid"} default button 1
end if
end tell