scripting@wanadoo.nl




AllFlags()

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
5 February 2002 AllFlags()
AuthorW.M. Hinsch (New Mexico Mark)
Action Given two numbers, returns a boolean true if ALL the '1' bits in the second number are set in the first number, else returns a boolean false.
SyntaxAllFlags (NumberToTest, TestNumber) 
Parameters
  • NumberToTest (Required / String) Any number or string that can be converted to a number with Val().
  • TestNumber (Required / String) Pretty much 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 AllFlags() would return true for 1 (0001), 2 (0010), and 8 (1000) as well as 3 (0011), 9 (1001), 10 (1010) and 11 (1011). 
    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)' ?
    'AllFlags(51,&0)=' + AllFlags(51,Val('&0')) ?
    'Test 110011 against 000011 (3)' ?
    'AllFlags(51,3)=' + AllFlags(51,3) ?
    'Test 110011 against 001100 (12)' ?
    'AllFlags(51,12)=' + AllFlags(51,12) ?
    'Test 110011 against 010010 (18)' ?
    'AllFlags(51,18)=' + AllFlags(51,18) ?
    'Test 110011 against 010110 (22)' ?
    'AllFlags(51,22)=' + AllFlags(51,22) ? ;AnyFlags() and AllFlags() differ here
    
    110011 = 51
    
    &0 = Dec 0
    ; Console Output
    ;Test 110011 against 000000 (0)
    ;AllFlags(51,&0)=0
    ;Test 110011 against 000011 (3)
    ;AllFlags(51,3)=1
    ;Test 110011 against 001100 (12)
    ;AllFlags(51,12)=0
    ;Test 110011 against 010010 (18)
    ;AllFlags(51,18)=1
    ;Test 110011 against 010110 (22)
    ;AllFlags(51,22)=0
    
     
    Source
    FUNCTION AllFlags ($inum, $itst)
      ; Returns a boolean true if all the '1' bits in $iTst are also set in $iNum.
      $inum=Val($inum)
      $itst=Val($itst)
      IF ($itst = 0)
        $allflags=0
        EXIT
      ENDIF
      $allflags=(($inum & $itst) = $itst)
    ENDFUNCTION ; - AllFlags -
     
      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