Hi everyone,
I tried to generate text from QuarkXpress based on the user’s list of style through Display Dialog. This script works fine in Applescript, but when put into XCODE with a button us userinterface, the Display Dialog doesn’t works.
HELP!!!
property XX : ""
on clicked theObject
set recipe to ""
set thisline to ""
set dialogResult to display dialog "Input List of Styles" default answer XX
set myList to text returned of dialogResult
set XX to myList
set source_folder to choose folder with prompt "Select folder containing QUARKXPRESS Documents"
tell application "Finder" to set item_list to every item of source_folder
set mySearchList to getwords(myList)
repeat with this_item in item_list
set doc_kind to kind of (info for this_item as alias)
if doc_kind contains "QuarkXPress" then
tell application "QuarkXPress"
activate
open this_item use doc prefs no remap fonts no do auto picture import no without reflow
set recipe to recipe & name of document 1 & return
end tell
end if
set recipe to GenerateList(mySearchList, recipe)
end repeat
tell application "TextEdit"
make new document at beginning with properties {text:recipe as Unicode text}
activate
end tell --application
end clicked
on GenerateList(mySearchList, recipe)
repeat with i from 1 to (count of mySearchList)
set myStyle to item i of mySearchList
tell application "QuarkXPress"
activate
tell document 1
set pageList to every page
repeat with aPage in pageList
tell aPage
set pageIndex to index
set pageName to name
set textBoxList to every text box
repeat with aTextBox in textBoxList
tell aTextBox
set foundParagraphList to (every paragraph whose style sheet is myStyle)
repeat with aParagraph in foundParagraphList
set thisline to contents of aParagraph
set recipe to recipe & myStyle & tab & thisline & tab & pageIndex & return
end repeat
end tell --aTextBox
end repeat
end tell --aPage
end repeat
end tell --document
end tell
end repeat
tell application "QuarkXPress"
activate
tell document 1
close saving no
end tell
end tell
return recipe
end GenerateList
on getwords(txt)
set olddelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
set txtitems to text items of txt
set AppleScript's text item delimiters to olddelims
return txtitems
end getwords