Script Examples [ HP DeskManager Customization ] MPE/iX 5.0 Documentation
HP DeskManager Customization
Script Examples
The following script files have been included here to give you examples
of the uses of script files to assist in your understanding of script
files. Some of them are working script files, and some are merely
examples that show the use of some of the options available within the
script language and HP Desk.
NOTE The script files included here are examples. These files are not
supported by Hewlett-Packard.
Remote logon
This script signs a user onto a remote machine called "tonto", by opening
a dsline connection to it.
:setjcw dserror=0
&errabort 0
:remote
&errabort 1
&FORWARD 2 <equal <jcw DSERROR> 623>
&EXIT
:setjcw dserror=0
:dsline tonto
:remote hello ian,user.account
:remote
&EXIT
Reading Scripts
This is a script file to read an installed script and copy it to your
Work Area.
&FORWARD inputok <PARMPRES 1>
&PRINT You must supply the name of the script file you wish to copy to the WA
&EXIT
$inputok
&SAVE scriptname <PARMREM 1>
open workarea nolist
copy from <MAKEQUOTED <VAR scriptname>> of script
read it
close
&EXIT
Invoking TDP
This script invokes TDP to edit an item in HP Desk.
&FORWARD okay <PARMPRES 1>
&PRINT
&PRINT you must specify an item to edit
&PRINT
$okay
:purge <PARM 2>
copy <PARM 1> to <PARM 2>
:run tdp.pub.sys,info="t <PARM 2>"
copy text from <PARM 2>
&EXIT
Press Spacebar to Continue
This script goes to the In Tray when the Spacebar is pressed.
&ECHO 0
$bigloop
$mainloop
&PRINT <USERNAME>
&PRINT
&PRINT waiting!! please press (spacebar) to continue
&PRINT
&SAVE entered <PROMPT " " "NO" 1 300>
&FORWARD intray <YESNO <VAR entered>>
&BACK mainloop
$intray
intray
&EXIT
Answer Question to Proceed
This script file will not continue until the user answers with a "yes".
&QUIET
&NOECHO
&BREAK 0
$tryagain
&SAVE y <PROMPT "Please answer 'yes' to the prompt :- " "N">
&FORWARD ifyes <STREQUAL <MALEQUOTED <upshift <VAR y>>> "Y">
&BACK tryagain
$ifyes
&PRINT As you answered 'yes' you can carry on!
&PAUSE 5
&BREAK 1
&EXIT
Menu Options Script
This script is an example of how to use HP Desk script files to present a
user with a menu of selections. Obviously, you could add a lot more
things to the list. Also individual scripts of this type could be
installed for different user groups, depending on what you want different
users to be able to access.
$start
&PRINT
&PRINT Here is a list of the programs you can run:
&PRINT
&PRINT 1. QUERY
&PRINT 2. EDITOR
&PRINT 3. TDP
&PRINT 4. SPOOK
&PRINT
&SAVE X <PROMPT "enter the number you wish to run, or 99 to exit: ">
&SAVE X <QUOTE <VAR X>
&FORWARD exit <STREQUAL <VAR X> "99">
&FORWARD query <STREQUAL <VAR X> "1">
&FORWARD editor <STREQUAL <VAR X> "2">
&FORWARD tdp <STREQUAL <VAR X> "3">
&FORWARD spook <STREQUAL <VAR X> "4">
&PRINT
&PRINT Please enter a number from 1 - 4, or 99 to exit
&PRINT
&BACK start
$query
:RUN QUERY.PUB.SYS
&BACK start
$editor
:RUN EDITOR.PUB.SYS
&BACK start
$tdp
:RUN TDP.PUB.SYS
&BACK start
$SPOOK5
:RUN SPOOK5.PUB.SYS
&BACK start
$exit
&EXIT
Deleting In Tray items
This script (called KILLJUNK) can be used to delete items from your In
Tray.
&FORWARD saveparmsubj <PARMPRES 1>
&PRINT
&PRINT 1. Type the word KILLJUNK and press 'RETURN'
&PRINT
&PRINT You will see this message and then be prompted for the subject
&PRINT to delete.
&PRINT
&PRINT 2. Type the word KILLJUNK followed by the subject to delete
&PRINT
&PRINT eg. KILLJUNK junk
&PRINT will delete all items having the word junk in their subject
&PRINT
&PRINT or KILLJUNK junk items
&PRINT will delete all items having the phrase 'junk items'
&PRINT in their subject
&PRINT
&PRINT To avoid this message in future use the second option.
&PRINT
&PRINT If you enter the word "NONE", then the script will exit.
&PRINT
&SAVE subject <MAKEQUOTED <PROMPT "Subject to delete :- " "NONE">>
&EXIT <STREQUAL <VAR subject> "NONE">
&FORWARD subjectok
$saveparmsubj
&COMMENT save the parameter entered value
&SAVE subject <MAKEQUOTED <PARMREM 1>>
$subjectok
&SAVE count 1
open intray nolist
$begin
&SAVE next <FIND <VAR subject> "" <VAR count>>
&FORWARD exit <EQUAL <VAR next> 0>
delete <VAR next>
&SAVE count <ADD <VAR next> 1>
&BACK begin <LESS <VAR count> <LAST>>
$exit
&PRINT No more <VAR subject> items to delete
close
&EXIT
Filing Items
This script (called FILEIT) moves an In Tray item to the Filing Cabinet,
stripping off the Distribution List.
&FORWARD begin <PARMPRES 2>
&PRINT The syntax of the command is :-
&PRINT
&PRINT FILEIT item_number folder_name
&PRINT
&PRINT where item_number is the number of an item in your In Tray
&PRINT folder_name is the name of the folder in your Filing Cabinet
&PRINT
&PRINT This script moves the In Tray item to the Filing Cabinet stripping
&PRINT off the Distribution List
&EXIT
$begin
&FORWARD intray <EQUAL <AREA> 1>
&PRINT This command can only be executed from the In Tray
&EXIT
$intray
&FORWARD itemok <REF <PARM 1>>
&PRINT The number you entered does not exist.
&EXIT
$itemok
&COMMENT We will not check the name of the folder since HP Desk will prompt
&COMMENT you to create a new folder if the one given does not exist.
copy <PARM 1> to workarea
delete <PARM 1>
open workarea nolist
open <LAST> nolist
&SAVE count 1
$loop
&FORWARD notdl <NOT <EQUAL <TYPE <VAR count>> 1166>>
delete <VAR count>
$notdl
&SAVE count <ADD <VAR count> 1>
&BACK loop <GREATER <LAST> <VAR count> >
close
copy <LAST> to <MAKEQUOTED <PARM 2>>
delete <LAST>
close
&PRINT Item moved to <PARM 2>
&EXIT
Deleting Messages by Username
This script (called DSENDER) deletes messages in the In Tray, according
to sender. The name of the user whose massages are to be deleted is
specified as the first parameter.
&COMMENT check that we're in the In Tray, if not, exit.
&FORWARD 3 <EQUAL <AREA> 1>
&PRINT sorry, only allowed in the In Tray
&EXIT
&COMMENT if the user didn't supply a name, exit.
&FORWARD 3 <PARMPRES 1>
&PRINT I expected a sender's name
&EXIT
&COMMENT take everything the user typed as a name, and make it
&COMMENT quoted if it wasn't already
&SAVE sender <MAKEQUOTED <PARMREM 1>>
&COMMENT find the first item whose creator is the name specified
&SAVE item <FIND "" <VAR sender>>
&COMMENT an item number of 0 indicates that there are no messages
&COMMENT from that user, therefore exit.
&FORWARD delitem <GREATER <VAR item> 0>
&PRINT there are no messages from that user
&EXIT
&COMMENT delete the item
$DELITEM
DELETE <VAR item>
&COMMENT find the next item from the sender, starting the search from where
&COMMENT we found the last one. If there is another item, go back and
&COMMENT delete it, otherwise exit.
&SAVE item <FIND "" <VAR sender> <VAR item>>
&BACK delitem <GREATER <VAR item> 0>
&EXIT
Deleting Items by Subject
This script scans the current area for items which match a given subject,
and deletes them
&COMMENT If no parameter is specified, exit
&FORWARD checkparm <PARMPRES 1>
$badparm
&PRINT I expected a quoted subject
&EXIT
&COMMENT If parameter is not a quoted subject, exit
$checkparm
&BACK badparm <NOT <EQUAL <PARMTYPE 1> 2>>
&COMMENT Find the item number of the first item matching the given
&COMMENT subject. An item number of 0 means that there is no item
&COMMENT with this subject, therefore exit.
&SAVE item <FIND <PARM 1> "">
&FORWARD delitem <GREATER <VAR item> 0>
&PRINT there are no items matching that subject
&EXIT
&COMMENT delete the item
$delitem
&DELETE <VAR item>
&COMMENT Find the item number of the next item which matches the
&COMMENT given subject, starting the search from where we found
&COMMENT the last one. If an item is successfully found, go back and
&COMMENT delete it.
&SAVE item <FIND <PARM 1> "" <VAR item>>
&BACK delitem <GREATER <VAR item> 0>
&COMMENT when there are no more items to be deleted, exit
&EXIT
Combining Text
This script file (called JOIN) joins two different text items into one
new one. The two items to be joined are passed as parameters to the
script file, and the name of the new item to be created is prompted for
within the script file. For this to work it is necessary that the user
has MPE Access.
:PURGE join
:PURGE file1
:PURGE file2
&COMMENT Check if parameters have been provided, and whether items are text
&FORWARD noparm <NOT <PARMPRES 1>>
&FORWARD noitem <NOT <REF <PARM 1>>>
&FORWARD badtype <NOT <EQUAL <TYPE <PARM 1>> 1167>>
copy <PARM 1> to (file1)
&FORWARD noparm2 <NOT <PARMPRES 2>>
&FORWARD noitem <NOT <REF <PARM 2>>>
&FORWARD badtype <NOT <EQUAL <TYPE <PARM 2>> 1167>>
copy <PARM 2> to (file2)
&FORWARD fcopy
$noparm
&SAVE item1 <PROMPT "Enter item number of the first item you want to join: ">
&FORWARD noitem <NOT <REF <VAR item1>>>
$item1ok
&FORWARD badtype <NOT <EQUAL <TYPE <VAR item1>> 1167>>
copy <VAR item1> TO (file1)
$noparm2
&SAVE item2 <PROMPT "Enter item number of the second item you want to join: ">
&FORWARD noitem <NOT <REF <VAR item2>>>
$item2ok
&FORWARD badtype <NOT <EQUAL <TYPE <VAR item2>> 1167>>
copy <VAR item2> to (file2)
$fcopy
:build join;rec=-80,1,f,ascii
:file join;acc=append
&PRINT The JOIN is being performed...
:run fcopy.pub.sys;info="from=file1;to=*join;nouserlabels"
:run fcopy.pub.sys;info="from=file2;to=*join;nouserlabels"
&PRINT Your joined file will now be copied back into your Work Area.
&PRINT When the Subject prompt appears type in the subject for the new file.
copy text from (join)
:PURGE file1
:PURGE file2
:PURGE join
&EXIT
&COMMENT Error routine if TEXT is not selected
$badtype
&PRINT
&PRINT You can only join TEXT items
:PURGE file1
&EXIT
&COMMENT Error routine if the item does not exist
$noitem
&PRINT
&PRINT That item does not exist
:PURGE file1
&EXIT
Reordering Items
This is a script file that enables you to reorder items within a package.
For example, if a user has 7 items in his package and he wants to move
item 3 to be placed before item 7, the user should run this script file.
The script will prompt for the item to be moved and the new position of
the item.
&SAVE last <LAST>
&SAVE itemmove <PROMPT "Which item do you wish to move " "0" 3 20>
&SAVE whereto <PROMPT "Where do you wish to insert the item " "0" 3 20>
&FORWARD inputok <NOT <EQUAL <VAR itemmove> 0>>
&PRINT You must specify an item to move
&EXIT
$inputok
&FORWARD itemok <REF <VAR itemmove>>
&PRINT Item number does not exist
&EXIT
$itemok
move <VAR itemmove> to here
&COMMENT Item to move is now at the bottom of the list.
&COMMENT Now move all other items past the item at the end of the list
&COMMENT starting with item 'whereto'
&COMMENT test to see if the item is being to moved to the end of the list
&FORWARD noteol <NOT <EQUAL <VAR whereto> <VAR last>>>
move <VAR whereto> to here
close
open <REFNUM it>
&EXIT
$noteol
move <VAR whereto>/<VAR last> to here
close
open <REFNUM it>
&EXIT
Nested Folder Script
This script opens a specified list of nested folders.
&SAVE next 0
&COMMENT Open the Filing Cabinet
open cabinet nolist
$LOOP
&COMMENT "next" is a pointer to the next parameter, which
&COMMENT refers to the next level of folder to be opened.
&SAVE next <ADD <VAR next> 1>
&FORWARD exit <NOT <PARMPRES <VAR next>>>
&SAVE folder <MAKEQUOTED <PARM <VAR next>>>
&COMMENT Check that at least one folder exists with the specified name.
&COMMENT The OPEN command will deal with giving the user a choice, if
&COMMENT there's more than one.
&FORWARD nofolder <EQUAL <FIND <VAR folder> "" 1 -101> 0>
$folderok Open the folder
open <VAR folder> nolist
&PRINT .
&BACK loop
$nofolder No such folder
&PRINT <VAR folder> does not exist or is not a folder.
&FORWARD exit
$exit
&EXIT
MPE/iX 5.0 Documentation