Run Command Tutorial

 

Table of Contents

Using Command Query Shortcuts

Introduction

You can use Komodo's Run Command shortcuts to have a dialog box prompt you for input data for a command, whenever it is run. These queries can specify default values. You can also set them to prompt only if no value could be determined automatically. For example, you could create a command that searches Google for the current selection and have it display a pop-up dialog box to ask for a search term if nothing has been selected.

Query shortcuts come in two forms. First, there is a new shortcut, "%(ask)," which always prompts the user for data. Second, every shortcut can be modified to prompt only if no valid value could be determined using the "orask" modifier.

It is a good idea for Windows users to enclose all Komodo shortcuts (with the exception of %(browser)) in double quotation marks. This is necessary to ensure that any spaces in filenames or file paths are interpreted correctly.

Top

Always Prompting with %(ask)

The full syntax of the %(ask) shortcut is:
        "%(ask[:NAME:[DEFAULT]])"
where "NAME" is an optional name to use when prompting in the dialog box and "DEFAULT" is an optional default value to place in the dialog box.

This is best illustrated with some examples. Start with the following:

  1. Select Tools|Run Command.
  2. In the Run field, enter the command: echo Your favorite number is "%(ask)"
  3. Click the Run button to run the command. The Interpolation Query dialog box will be displayed.

    View Example

  4. Enter your favorite number and click OK to finish running the command.

You can refine this shortcut by adding a more meaningful name than "Value 0" and a more appropriate default value.

  1. Select Tools|Run Command.
  2. In the Run field, enter the command: echo Your favorite number is "%(ask:Fav Number:42)"
  3. Click the Run button to run the command. The Interpolation Query dialog box will now look like this:

    View Example

  4. If your favorite number does not happen to be 42, enter a different number and click OK to finish running the command.
Top

Prompting When Necessary with %(...:orask)

Any Run Command shortcut can be modified to prompt the user for a value if one cannot be determined automatically. The full syntax of the modified shortcut is:
        "%(SHORTCUT:orask[:NAME])"
where "NAME" is an optional name to use when prompting in the dialog box.

In the previous step we created a shortcut to search for the selected word on Google with the command:
%(browser) http://www.google.com/search?q="%W"
However, if nothing has been selected and there is no word under your cursor, the command will fail. In this case, it would be better if the command prompted you for a search term.

  1. Ensure that your cursor is not positioned over a word.
  2. Select Tools|Run Command.
  3. In the Run field, enter the command:
    %(browser) http://www.google.com/search?q="%(W:orask:Search for)"
  4. Click the Run button to run the command. The Interpolation Query dialog box will prompt you for a search term.

Top Previous Next