HP OpenVMS Systems

ask the wizard
Content starts here

DCL and Error Handling?

» close window

The Question is:

 
I have the following code on a COM file:
 
$ proc_nbr = 0
$determine_process_number:
$ on error then goto determine_process_number
$ proc_nbr = proc_nbr + 1
$ set process/name = "Richard_''proc_nbr'"
$ set prompt = "rcm_tst_''proc_nbr'> "
 
- - -
 
I am able to get the error trapping to work fine, but I can't seem to suppress
 the presentation of this error message as the COM file cycles through existing
 process names:
 
   %SET-E-NOTSET, error modifying process name
   -SYSTEM-F-DUPLNAM, duplicate name
 
How do I keep the above error message from being displayed during COM file
 execution?
 
Thank you.
 
Richard


The Answer is :

 
  You could use:
 
$ proc_nbr = 0
$ MSG=F$ENVIRONMENT("MESSAGE") ! Save message state
$ SET MESSAGE/NOFACILITY/NOIDENT/NOSEVERITY/NOTEXT ! Supress messages
$determine_process_number:
$ on error then goto determine_process_number
$ proc_nbr = proc_nbr + 1
$ set process/name = "Richard_''proc_nbr'"
$ SET MESSAGE'MSG' ! Restore message state
$ set prompt = "rcm_tst_''proc_nbr'> "
 
 
  Alternatively, you could avoid the problem entirely with:
 
$ JPIUSR = F$GetJPI(0,"USERNAME")
$ PRCIDX = F$Fao("!4XW",F$GetSYI("MAXPROCESSCNT")-F$GetJPI("0","PROC_INDEX"))
$ PRCNAM = F$Edit("''JPIUSR'*''PRCIDX'","COLLAPSE,UPCASE")
$ If F$GetJPI("0","MASTER_PID") .eqs. F$GetJPI("0","PID")
$ Then
$    Set Process/Name='PRCNAM'
$ EndIf

answer written or last revised on ( 28-JUL-2004 )

» close window