[Info-vax] completion status from LIB$SPAWN

David Froble davef at tsoft-inc.com
Fri Apr 27 18:54:32 EDT 2012


Hein RMS van den Heuvel wrote:
> On Friday, April 27, 2012 10:34:33 AM UTC-4, David Froble wrote:
>> StGallen wrote:
> :
>> specifies success or failure.  Don't test the value, do a mask comparison, ie;
>>
>> If (Stat% And SS$_NORMAL)
>> Then Print "Success"
>> Else Print "Failure"
>> End If
> 
> I beg to differ. That's disgusting code. 
> It may work, but does not does what it suggest.
> 
> SS$_NORMAL is NOT a bitmask, it is a word value.
> That only works because you know its value is 1.
> If so, then IMHO it is better just write that: stat & 1
> Or use  STS$M_SUCCESS as mentioned earlier,
> Or use a 16-bit-word-compare.
> 
> fwiw,
> Hein

I'm puzzled.  Just what do you find wrong with the example of a bit mask comparison?  It 
is an example, not something that would be actually used.

Yes, many understand that SS$_NORMAL is a constant value of 1 used widely throughout VMS, 
and that there are many such constant values and masks used in VMS.

Many years ago the argument for the constants and masks was, "DEC could change the value 
of something, and using the constants would mean your code would still work".  I've never 
seen any thing like this change, and I doubt I ever will, and if it happens it would be in 
my opinion a huge mistake.  Regardless, DEC encouraged the use of the constants...

Grabbing an example of working code:

         Def* FnWriteSocket%( Z0$ )

         MSG::BUF$ = Z0$
         ByteCount% = Len( Z0$ )

         Stat% = SYS$QIOW(       ,                       !  Event flag &
                                 ConnectCh% By Value,    !  VMS channel &
                                 IO$_WRITEVBLK By Value, !  Function code &
                                 IOSB::Stat%,            !  I/O status block &
                                 ,                       !  AST routine &
                                 ,                       !  AST parameter &
                                 MSG::BUF$ By Ref,       !  P1 - I/O buffer &
                                 LEN(Z0$) By Value,      !  P2 - length of buffer
  &
                                 ServerItemLst::Len%,    !  P3 - remote address &
                                 ,                       !  P4 &
                                 ,                       !  P5 &
                                         )               !  P6

         If      ( Stat% And SS$_NORMAL ) = 0%
         Then    Call VMSERR( Stat% , E$ )
                 E$ = "Unable to queue write to socket - " + E$
                 SaveStat% = Stat%
                 FnWriteSocket% = -1%
                 Exit Def
         End If

         If      ( IOSB::Stat% And SS$_NORMAL ) = 0%
         Then    If      IOSB::Stat% = SS$_ABORT &
                 Or      IOSB::Stat% = SS$_CANCEL
                 Then    E$ = "Timeout"
                 Else    Call VMSERR( IOSB::Stat% , E$ )
                 End If
                 E$ = "Unable to write to socket - " + E$
                 SaveStat% = IOSB::Stat%
                 FnWriteSocket% = -1%
                 Exit Def
         End If

         Fnend

My usual is to first to check for success or failure, and if failure, then perhaps test 
for specific anticipated failure modes.

But if it's disgusting, I won't be offended ....



More information about the Info-vax mailing list