I’m instructing QuarkXpress to allow me to choose from the list of stylesheets:
set the_SSs to name of every style spec
set theBaseStyle to choose from list the_SSs with prompt "Pick your stylesheet:" ¬
OK button name {"Choose"} cancel button name {"No I won't"} without multiple selections allowed
And it works, but the list of stylesheets are not listed in alphabetical order.
I’m not sure what order they are in, but its not an order that I recognize. Maybe creation date?
Is there a way to get a list’s items to be presented alphabetically? (I’m surprised that this isn’t the default)
Browser: Safari 533.19.4
Operating System: Mac OS X (10.4)
set the_SSs to name of every style spec
(*
Here insert a piece of code sorting your list according to your preferences
*)
set theBaseStyle to choose from list the_SSs with prompt "Pick your stylesheet:" ¬
OK button name {"Choose"} cancel button name {"No I won't"} without multiple selections allowed
It’s not Choose from list duty to sort your list.
I would shout if it was doing that on a list carefully designed to fit my needs.
tell application "QuarkXPress"
activate
tell document 1
set the_SSs to name of every style spec
set the_list to the_SSs
set old_delims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {ASCII character 10} -- always a linefeed
set list_string to (the_list as string)
set new_string to do shell script "echo " & quoted form of list_string & " | sort -f"
set new_list to (paragraphs of new_string)
set AppleScript's text item delimiters to old_delims
set theBaseStyle to choose from list new_list with prompt ¬
"Pick your stylesheet:" OK button name {"Choose"} cancel button name {"No I won't"} without multiple selections allowed
end tell
end tell
The more I look at this, the more I think choosing from a list is the wrong way to go.
Would there be a way to, instead of having the user choose the stylesheet from a list,
…have them click in the QX document on a paragraph, and then that paragraph’s stylesheet would be the one the script uses?
I have this code, but it requires a selection of text:
tell application "QuarkXPress"
activate
tell document 1
set sel to the selection
tell paragraph 1 of sel
set x to name of style sheet as text
set the clipboard to x
end tell
end tell
end tell
Whereas I would just want to click on a paragraph and get its stylesheet
Hi. I noticed in your first example that you refer to style spec and that you later use style sheet; if you use the latter syntax, is the result different? I don’t use XPress, but, if it allows keyboard assignment to scripts”à la InDesign”you could get the style sheet’s name value upon having a text selection and invoking the key command. If you need an arbitrarily ordered list, you could use the same method and append the results to a file.
I believe (but don’t quote me) that “style spec” is a property of the document (the definition, or the attributes that it indicates) whereas the term style sheet is a property of a paragraph.