Restricting an action to a particular type of argument refines the action. For example, you should restrict an action that invokes a viewer for PostScript files to only PostScript file arguments; with the restriction, the action will return an error dialog if a non-PostScript file is specified.
You can restrict actions based on:
The data type of the file argument.
The number of file arguments--for example, no arguments versus one or more arguments. This provides different drop and double-click behavior for the action icon.
The read/write mode of the argument.
Use the ARG_TYPE field to specify the data types for which the action is valid. Use the data attribute name.
You can enter a list of data types; separate the entries with commas.
For example, the following action definition assumes a Gif data type has been created.
ACTION Open_Gif { TYPE COMMAND LABEL "Display Gif" WINDOW_TYPE NO_STDIO ARG_TYPE Gif ICON xgif DESCRIPTION Displays gif files EXEC_STRING xgif }
Use the ARG_COUNT field to specify the number of arguments the action can accept. Valid values are:
* (Default)--any number of arguments. Other values have precedence over *.
n--any non-negative integer, including 0.
>n--more than n arguments.
<n--fewer than n arguments.
One use for ARG_COUNT is to provide different action icon behavior, depending on whether the user double-clicks the icon or drops a file on it. See the next section, "To Provide Different Double-Click and Drop Behavior."
Use this procedure to create an action that accepts a dropped file but does not prompt for a file when the action icon is double-clicked.
Create an action definition for the double-click functionality.
Use the ARG_COUNT field to specify 0 arguments. Use a syntax for the EXEC_STRING that does not accept a dropped argument.
Create a second action definition for the drop functionality.
Use the ARG_COUNT field to specify >0 argument. Use a syntax for the EXEC_STRING that accepts a dropped file.
For example, suppose the following two command lines can be used to start an editor named vedit:
To start the editor with a file argument that is opened as a read-only document:
vedit -R filename
The following two actions create drop and double-click functionality for an action named Vedit. The first action has precedence when the database is searched for a match, since ARG_COUNT 0 is more specific than the implied ARG_COUNT * of the drop functionality definition.
# Double-click functionality ACTION Vedit { TYPE COMMAND ARG_COUNT 0 WINDOW_TYPE PERM_TERMINAL EXEC_STRING vedit } # Drop functionality ACTION Vedit { TYPE COMMAND WINDOW_TYPE PERM_TERMINAL EXEC_STRING vedit -R %Arg_1% }
Use the ARG_MODE field to specify the read/write mode of the argument. Valid values are:
* (Default)--any mode
!w--non-writable
w--writable