scripting@wanadoo.nl




AnyFlags()

http://www.scriptlogic.com/kixtart/FunctionLibrary_FunctionList.aspx


actual FunctionLibrary list on 'Scriptlogic' site printer-friendly mirror of UDF topic on 'scripting@wanadoo.nl' site close
28 January 2002 AnyFlags()
AuthorW.M. Hinsch (New Mexico Mark)
Action Given two numbers, returns a boolean true if ANY of the '1' bits in the second number are set in the first number, else returns a boolean false.
SyntaxAnyFlags (NumberToTest, TestNumber) 
Parameters
  • NumberToTest (Required / String) Any number or string that can be converted to a number with Val().
  • TestNumber (Required / Numeric) Self-Explanatory 
  • RemarksDeveloped to test whether one or more bits are set in a given number. I.e. decimal 11 is binary 1011. This means AnyFlags() would return true for everything between 1 (0001)and 15 (1111) except 4 (0100). 
    ReturnsBoolean true or false (1 or 0) 
    DependenciesNone. 
    Examples
    'Test against a number with the following bit pattern:' ?
    '110011 = 51' ? ?
    '&0 = Dec 0' ? ?
    'Test 110011 against 000000 (0)' ?
    'AnyFlags(51,&0)=' + AnyFlags(51,Val('&0')) ?
    'Test 110011 against 000011 (3)' ?
    'AnyFlags(51,3)=' + AnyFlags(51,3) ?
    'Test 110011 against 001100 (12)' ?
    'AnyFlags(51,12)=' + AnyFlags(51,12) ?
    'Test 110011 against 0010010 (18)' ?
    'AnyFlags(51,18)=' + AnyFlags(51,18) ?
    'Test 110011 against 0010110 (22)' ?
    'AnyFlags(51,22)=' + AnyFlags(51,22) ? ;AnyFlags() and AllFlags() differ here
    ;Console output
    ;Test against a number with the following bit pattern:
    ;110011 = 51
    
    ;&0 = Dec 0
    
    ;Test 110011 against 000000 (0)
    ;AnyFlags(51,&0)=0
    ;Test 110011 against 000011 (3)
    ;AnyFlags(51,3)=1
    ;Test 110011 against 001100 (12)
    ;AnyFlags(51,12)=0
    ;Test 110011 against 0010010 (18)
    ;AnyFlags(51,18)=1
    ;Test 110011 against 0010110 (22)
    ;AnyFlags(51,22)=1
    
     
    Source
    FUNCTION AnyFlags ($inum, $itst)
      ; Returns a boolean true if ANY of the '1' bits in $iTst are also set in $iNum.
      $inum=Val($inum)
      $itst=Val($itst)
      $anyflags=(($inum & $itst) <> 0)
    ENDFUNCTION ; - AnyFlags -
     
      original source of UDF topic. show actual FunctionLibrary list on Scriptlogic site close top
              printer-friendly mirror of UDF topic on scripting@wanadoo.nl site  




    Copyright © 2003 www.scriptlogic.com & scripting@wanadoo.nl - last updated on 20 May 2003


    Site Meter