× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Don,

If you want a one-step procedure, you could also/instead use this
bitpattern()
procedure, for instance if you want to check that ONLY bit 2 (the third
bit) is
on and all the other bits are off, you would use this:

   if bitpattern( '00100000' : MyField );

or if you don't care about the state of the other bits, you would use
this:

   if bitpattern( 'xx1xxxxx' : MyField );

I wrote bitpattern() because it's easier to understand (IMHO,
obviously!) than the
equivalent %BITAND statement. In other words, it's easier to use this:

   if bitpattern( '1x1xx1xx' : MyField );

instead of either this:

   if (%bitand( MyField : x'80') = x'80' and
       %bitand( MyField : x'20') = x'20'
       %bitand( MyField : x'04') = x'04');

or this:

   if (%bitand( MyField : x'A4') = x'A4');

neither of which are immediately comprehensible (as can be seen from the
existence
of this thread!!!). Plus it's easier to check for a combination of off
and on bits
together in a single byte...

I know that it's not free-format code, but you can no doubt convert it
to 
free-format if it's important to you (I'm no fan of free-format, but
even if
I were, I wouldn't bother changing this but would simply compile it into
a 
service program as-is, since it doesn't really need any 'work')...

HTH,

Rory

 *=====================================================================
 * Return bit-pattern value

 *=====================================================================
P bitpattern      B                   Export                           
D                 PI              N                                    
D P_Pattern                      8A   Value                            
D P_Char                         1A   Value                            
 *---------------------------------------------------------------------
D UnspecChar      DS                                                   
D   CharArr                      1A   Dim(8)                           
D Pattern         DS                                                   
D   PattArr                      1A   Dim(8)                           
D B               S             10I 0 Inz                              
 *---------------------------------------------------------------------
 *                                                                     
C                   Eval      Pattern = P_Pattern                      
C                   Eval      UnspecChar = bitform( P_Char : 1 )

 *                                                                     
C     1             Do        8             B                          
C                   If        ( PattArr(B) = '0' or
C                               PattArr(B) = '1') and
C                             PattArr(B) <> CharArr(B)                 
C                   Return    *Off                                     
C                   Endif                                              
C                   Enddo                                              
 *                                                                     
C                   Return    *On                                      
 *                                                                     
C     *PSSR         Begsr                                              
C                   Return    *Off                                     
C                   Endsr                                              
 *                                                                     
P                 E                                                    
 *=====================================================================


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.