1

I have an AppleScript .app file that creates a list variable based on a website's HTML data. The number of items in this list varies based on the unique HTML data that is downloaded on every iteration, and can range from 1 to 50.

I ultimately want to display the contents of each line as its own drop-down menu in one dialog. I am using the external script library, Dialog Toolkit, to accomplish this, which requires the declaration of many additional variables.

Dialog Toolkit works differently than choose from list, for example. The choose from list dialog will automatically adjust its size to add a new line for each list item. But, for a Dialog Toolkit dialog, you instead must separately define (i.e., as its own unique variable) every drop-down menu that is needed. If you don't, zero drop-down menus will exist in the dialog.

Hence, 50 if statements are needed to ensure that the dialog contains all drop-down menus, like so:

repeat with i from 1 to (count of theList)
        if (i is 1) then
            set {dropdown1} to create labeled dropdown (item i of theList)
        else if (i is 2) then
            set {dropdown2} to create labeled dropdown (item i of theList)
        i if (i is 3) then
            set {dropdown3} to create labeled dropdown (item i of theList)
        else if (i is 4) then

        ...

        else if (i is 50) then
            set {dropdown50} to create labeled dropdown (item i of theList)
        end if
end repeat

-- Note: The above code snippet is a very stripped down version of my code.

Is it possible for an AppleScript to create, on its own, new variables that have formulaic titles?

Here is the type of thing that I desire:

repeat with i from 1 to (count of theList)
    set {(("dropdown" & i) as variable)} to create labeled dropdown (item i of theList)
end repeat

OS X El Capitan, version 10.11.6.


  • I do not believe that which you desire is possible. – user3439894 Jul 15 '17 at 12:08
  • It's possible to create multiples labeled dropdowns without needing 50 defined variables and 50 else if conditions. I do not answer because it will not answer your original question. If you want an example of this script, change the title of the question, or post another question. – jackjr300 Aug 21 '17 at 23:52

You must log in to answer this question.

Browse other questions tagged .