Announcement

Collapse
No announcement yet.

Why is this? Use of the AND operator.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why is this? Use of the AND operator.

    There is an if statement in one of the examples to let you know when a "file" is a directory:

    Code:
    IF (STRUCT_FIND_DATA.dwFileAttributes AND %FILE_ATTRIBUTE_DIRECTORY) <> %FILE_ATTRIBUTE_DIRECTORY THEN
    Why is the STRUCT_FIND_DATA.dwFileAttributes there? I know the FILE_ATTRIBUTE contains bits to indicate the state of R,A,S,H and other things including the Directory flag.

    Is doing this basically the same thing?
    Code:
    IF ISTRUE BIT(FILE_ATTRIBUTES, 4)   THEN RESULT = RESULT  + "4, Directory (16),"
    I can test it but do you think the AND way would be faster?

  • #2
    Like?
    Code:
    if somename.FILE_ATTRIBUTES and &h00000010??? then RESULT = RESULT  + "4, Directory (16),"
    Some PB code compiles pretty "tight" so I don't know if AND would be faster (maybe that's what PB compiles to). Leaving out ISTRUE should speed it up some either way. (saves the non-zero to all bits "1" step, and is still TRUE to the IF.)

    Cheers,
    Dale

    Comment


    • #3
      I will try that Dale, Thanks!

      Comment

      Working...
      X