HP OpenVMS Systems

ask the wizard
Content starts here

Translating messages to condition values?

» close window

The Question is:

Using Help/message and f$message you can easily determine the text associated
 with a particular condition code, however, is there an easy way to determine
 the hex condition code from a particular error if all you have is the
 identification, severity and f
acility text? For example;  I want to trap a RMS-F-FNF error in my command
 procedure, but i need to know what the hex value of the condition code is when
 this occurs.  How do I do this, other than causing a FNF to occur and
 observing the hex value in the
$status symbol?
thanks much...

The Answer is :

  Use the F$MESSAGE mechanism:
$ somecommand
$ stat=$STATUS			! Save status
$ statmsg=F$MESSAGE(stat)       ! translate to text
$ IF F$LOCATE("-FNF,",statmsg).LT.F$LENGTH(statmsg)
$   !  handle FNF condition
$   !  not FNF
  This is independent of facility, severity and control bits, and is
  thus more likely to work than a comparison with a raw HEX number.
  Inclusion of raw numeric values in code is STRONGLY DISCOURAGED.
  (Assuming you cannot simply match on the severity field or similar,
  an attempt to match specific condition values will likely mishandle
  other successful or failing status codes, or the message-inhibit
  flag, or messages with variant severities.)
  To match on the message condition value (this is the portion of the
  message that is specific to the particular message, less various
  other fields):
$ condmask=%XFFF8
$ rms$_fnf=%X00018292 .AND. condmask	! From $RMSDEF
$ stat=$STATUS
$ IF (stat.AND.condmask).EQ.rms$_fnf
$   !  handle FNF condition
$   !  not FNF
  You can also use $SEVERITY at the DCL level, rather than $STATUS.
  If you wish to examine condition values directly, please see:
$ library /extract=$rmsdef /output=$rmsdef sys$library:starlet.mlb
$ search $rmsdef.mar fnf
  An example tool follows:
$ tab[0,7] = 9
$ library /extract = 'p1' /output = 'p1' sys$library:starlet.mlb
$ on control_y then $ goto done
$ open /read source 'p1'.mar
$ loop:
$       read /end = done source line
$       if f$element( 0, tab, line ) .nes. "$EQU" then $ goto loop
$       'f$element( 1, tab, line ) == f$integer( f$element( 2, tab, line ))
$       goto loop
$ done:
$ close source
$ show symbol rms$_fnf
  If you have the Compaq C Compiler installed, you can use the
  following command to search for condition values:
$ Search sys$common:[decc*...]rmsdef.h rms$_fnf

answer written or last revised on ( 12-MAR-2001 )

» close window