Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
12.  Creating Actions Manually Building the Execution String for a COMMAND Action Creating an Action that Accepts a Dropped File or Prompts for One  Previous   Contents   Next 
   
 

Creating an Action that Prompts for a Non-File Argument

Use this syntax for the non-file parameter:

%"prompt"%

or

%(String)"prompt"%

(String) is optional, since quoted text is interpreted, by default, as string data. This syntax displays a dialog box that prompts for non-file data; do not use this syntax when prompting for a file name.

For example, this execution string runs the xwd command and prompts for a value to be added to each pixel:

EXEC_STRING xwd -add %"Add value:"% -out %Arg_1"Filename:"%

Interpreting a File Argument as a String

Use this syntax for the argument:

%(String)Arg_n%

For example, this execution string prints a file with a banner containing the file name, using the command lp -tbanner filename.

EXEC_STRING lp -t%(String)Arg_1% %(File)Arg_1"File to print:"%

Providing Shell Capabilities in an Action

Specify the shell in the execution string:

/bin/sh -c 'command'
/bin/ksh -c 'command'
/bin/csh -c 'command'

Examples

  • This execution string illustrates an action that uses shell piping.

    	EXEC_STRING /bin/sh -c 'ps | lp'
  • This is a more complex execution string that requires shell processing and accepts a file argument.

    	EXEC_STRING /bin/sh -c 'tbl %Arg_1"Man Page:"% | troff -man'
  • This execution string requires that the argument be a compressed file. The action uncompresses the file and prints it using lp -oraw.

    	EXEC_STRING				/bin/sh -c 'cat %Arg_1 "File to print:"% | \
     					uncompress | lp -oraw'
  • This execution string starts a shell script.

    	EXEC_STRING /usr/local/bin/StartGnuClient

Creating COMMAND Actions for Multiple File Arguments

There are three ways for actions to handle multiple file arguments:

  • The action can be run repeatedly, once for each argument. When an EXEC_STRING contains a single file argument and multiple file arguments are provided by dropping multiple files on the action icon, the action is run separately for each file argument.

    For example if multiple file arguments are supplied to the following action definition:

    	ACTION DisplayScreenImage
    	{ 	
    			EXEC_STRING					xwud -in %Arg_1%
     		...
     	}

    the DisplayScreenImage action is run repeatedly.

  • The action can use two or more non-interchangeable file arguments. For example:

    	xsetroot -cursor cursorfile maskfile  

    requires two unique files in a particular order.

  • The action can perform the same command sequentially on each file argument. For example:

    	pr file [file ...]  

    will print one or many files in one print job.

Creating an Action for Non-Interchangeable Arguments

Use one of the following syntax conventions:

  • If you want the action to prompt for the file names, use this syntax for each file argument:

    	%(File)"prompt"%

    Use a different prompt string for each argument.

    For example, this execution string prompts for two files.

    	EXEC_STRING				xsetroot -cursor %(File)"Cursor bitmap:"% \
     								%(File)"Mask bitmap:"%
  • To accept dropped files, use this syntax for each file argument:

    	 %Arg_n%

    using different values of n for each argument. For example:

    	EXEC_STRING				diff %Arg_1% %Arg_2%

Creating an Action with Interchangeable File Arguments

Use one of the following syntax conventions:

  • To create an action that accepts dropped files and issues a command in the form command file 1 file 2 ..., use this syntax for the file arguments:

    	%Args%
  • To create an action that accepts multiple dropped files, or displays a prompt for a single file when double-clicked, use this syntax for the file arguments:

    	%Arg_1"prompt"% %Args%

    The action will issue the command in the form: command file 1 file 2 ....

Examples

  • This execution string creates an action that executes:

    	pr file 1 file 2

    with multiple file arguments.

    	EXEC_STRING pr %Args%
  • This execution string creates an action similar to the previous example, except that the action displays a prompt when double-clicked (no file arguments).

    	EXEC_STRING  pr %Arg_1"File(s) to print:"% %Args%
 
 
 
  Previous   Contents   Next