How to ask for user decision?

Hi, I’m rewritting a script that sorts by two criteria with sortedArrayUsingDescriptors (initially written as a “quick” response to a DEVONthink user’s question). The old version needed the criteria and whether it should sort ascending/descending written into the source - which of course was not very user friendly …

I now figured I can ask for the criteria on runtime and evaluate the resulting strings by using NSAppleScript which works fine - but I’ve no idea how to ask for user input in a nice way.

Showing two choose from list dialogs would be fine but one can only change the cancel button's name - and not its function … (the idea was to use it for Sort descending), so that can’t be used I’m afraid.

I guess there’s no way other than building a custom dialog and if that’s necessary then I’d like to know whether it’s possible to show two “choose from lists” side by side plus ascending/descending radio buttons and where to begin :slight_smile:

This is a job for Myriad Tables.

You could probably copy one of the “Make new table with data”; “modify table” and “Display table” from the sample script, add your list of lists with two or more columns, give your three buttons names, and you’re in business. Plus if you have any questions, the developer is Shane Stanley, who practically lives here

use script "Myriad Tables Lib" version "1.0.11"
use scripting additions
 set #~result_Any~# to make new table with data #~Any_List~# ¬
    with title #~Text~# ¬
    with prompt #~Text~# ¬
    multiple selections allowed #~Boolean~# ¬
    can add and delete #~Boolean~# ¬
    editable columns #~Number_List~# ¬
    column headings #~Text_List~# ¬
    row numbering #~Boolean~# ¬
    initially selected rows #~Number_List~# ¬
    empty selection allowed #~Boolean~# ¬
    row template #~Any_List~# ¬
    multiple lines allowed #~Boolean~# ¬
    double click means OK #~Boolean~#
 
 
 modify table #~Any~# ¬
    OK button name #~Text~# ¬
    OK button is default #~Boolean~# ¬
    cancel button name #~Text~# ¬
    extra button name #~Text~# ¬
    grid style #~Grid_styling~# ¬
    column widths pattern #~Number_List~# ¬
    highlighted rows #~Number_List~# ¬
    alternate backgrounds #~Boolean~# ¬
    row dragging #~Boolean~# ¬
    column reordering #~Boolean~# ¬
    accessory view #~Any~# ¬
    hidden cancel button #~Boolean~# ¬
    initial position #~Number_List~#
 
 
 set #~result_Extended_table_reply_or_Table_reply~# to display table #~Any~# ¬
    giving up after #~Number~# ¬
    extended results #~Boolean~#
 

(If you click the “Open in Script Debugger” button you’ll see a much better display of the script in Script Debugger)
(EDIT: Earlier version of this post had the make table with data command, which doesn’t let you name the buttons)

Thanks! That would be perfect.

Unfortunately I didn’t find a way to show two lists side by side.

What I had in mind was something like this

Or did you mean I should simply show two separate windows?

You might do better to look at Dialog Toolkit Plus (download from the same page as Myriad Tables), and use two popup menus instead of lists.