Introducing Parameters to Scripts [ HP DeskManager Customization ] MPE/iX 5.0 Documentation
HP DeskManager Customization
Introducing Parameters to Scripts
How could you write a script which would cope if the item you want to
mail does not always have the same subject?
There are two ways to deal with this problem. The first is to pick up
the subject of the item from the command line. The active function PARM
allows a script to access the command line parameters. The second
solution involves the use of variables and will be covered later.
You can write a script which allows you to specify the subject of the
item when you invoke the script. For example, to pick up an item from
your Work Area called "Weekly Status Report", you would invoke the script
file (called "Weekly Status") by typing:
SCRIPT "Weekly Status" "Weekly Status Report"
The command line in your script should look like this:
SEND <PARM 1> to Mary Smith / ACCTS/01
In the above example, we change the references from "Weekly Status
Report" to <PARM 1>. This active function means "substitute the
information from the first parameter of the command line".
How can scripts cope if people make mistakes when typing the script
command line? They might leave out the quotation marks. In our example
this would result in the word "Weekly" being treated as the first
parameter and the rest of the line being ignored. Using <PARMREM 1>
instead of <PARM 1> would avoid this situation, as this function returns
the first parameter and the remainder of the line. However, if you
forget to put in the quotes, even using <PARMREM 1> will not avoid the
SEND command having incorrect syntax. To avoid this situation use
<MAKEQUOTED>. This makes the supplied subject into a quoted string if it
is not already one. This may be necessary in certain circumstances as
script functions often require items to be explicitly quoted or unquoted.
Our example script now looks like this:
&FORWARD itemok <REF <MAKEQUOTED <PARMREM 1>>>
&PRINT I don't think you have created the report yet
&EXIT
$itemok Come here if the item is OK
SEND <MAKEQUOTED <PARMREM 1>> to Mary Smith / ACCTS/01
ACKNOWLEDGE 4
URGENT
MAIL
&EXIT
Notice how the brackets <> are used with SEND. The result of <PARMREM 1>
should have quotes around it so <PARMREM 1> is included within the
<MAKEQUOTED> argument.
MPE/iX 5.0 Documentation