Menus

Table of contents

  1. Choose From Menu
  2. Choose From List

Choose From Menu

The syntax for a menu is very similar to a switch statement. Use the following syntax to create a menu:

menu "Prompt" {
    item "Item 1":
        /* do stuff if selected... */
    item "Item 2":
        /* do other stuff if selected... */
}

The menu prompt can be a variable or a literal value, and so can each item label.

Choose From List

Create a variable with a list() action as its value.

Just like in Shortcuts, each item must be text, but you can still use inline variables.

@list = list("Item 1", "Item 2", "Item 3")

Then simply use the chooseFromList() action with the list and a prompt.

@list = list("Item 1", "Item 2", "Item 3")
@chosenItem = chooseFromList(list,"Choose a item")

The variable chosenItem will hold the item chosen from your list by the user.