Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Common Desktop Environment: Advanced User's and System Administrator's Guide > Chapter 10 Creating Actions Manually

Restricting Actions to Certain Arguments

» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

Restricting an action to a particular type of argument refines the action. For example, it is useful to 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.

Restricting an Action to a Specified Data Type

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
}

Restricting an Action Based on the Number of Arguments

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”.

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.

  1. 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.

  2. 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 no file argument:

    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%
}

Restricting an Action Based on the Mode of the Argument

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

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.