Announcement

Collapse
No announcement yet.

Var = TRUE vs Var

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

  • Var = TRUE vs Var

    I just got done reading the manual. I have a couple of questions.

    Can you test for a variable being TRUE by using just the variable name?

    if blnVar = %TRUE then .....

    if blnVar then .....

    Are both of these syntax valid in PB/DLL 6.0?

    Thanks.

  • #2
    Lets consider these one by one:

    1. IF var = %TRUE THEN...
    This performs an explicit test for one value of "var" against the value of %TRUE (which is usually defined as -1)

    2. IF var THEN...
    This performs an implicit ISTRUE() function, and therefore any non-zero value of "var" will cause the code following the THEN clause to be executed.

    3. IF ISTRUE var THEN... and IF ISTRUE(var) THEN...
    These two statements function identically to #2 above.

    4. IF ISFALSE var THEN... and IF ISFALSE(var) THEN...
    These perform the opposite of #2 and #3 - if "var" is zero, then the condition is met.

    5. IF NOT var THEN...
    This is a completely different test - NOT performs a two's-compliment of "var", which is then implicitly tested for 'truth' or 'falsity'. See the help file for more info on the NOT bitwise operator.



    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected]suppor[email protected]</A>
    Lance
    mailto:[email protected]

    Comment

    Working...
    X