Announcement

Collapse
No announcement yet.

$IF NOT is not?

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

  • Arthur Gomide
    replied
    Daniel,

    If you use the regular Basic values of TRUE = -1 and FALSE = 0, your code works perfectly!

    Leave a comment:


  • Dave Biggs
    replied
    I should think that using ISTRUE and ISFALSE would be a better way to test the logical truth or falsity of an expression even in PBDos.

    Leave a comment:


  • Michael Mattias
    replied
    Win32API.inc defines the equates
    %TRUE = 1
    %FALSE = 0
    Just for the record, as long as you defined %TRUE as any non-zero integer, your Windows' programs will work correctly.... assuming you coded them correctly to begin with, using ISTRUE and ISFALSE instead of testing numeric values versus either %TRUE or %FALSE.

    Leave a comment:


  • Michael Mattias
    replied
    Win32API.inc defines the equates
    %TRUE = 1
    %FALSE = 0
    This is the PB/DOS forum where Win32API.INC holds no sway.

    Regardless...my solution works, don't it?

    Leave a comment:


  • Dave Biggs
    replied
    %TRUE = NOT %FALSE
    That's incorrect -

    Win32API.inc defines the equates
    %TRUE = 1
    %FALSE = 0

    Therfore Not %FALSE = -1. Which is True but isn't %TRUE

    Leave a comment:


  • Michael Mattias
    replied
    Code:
    %FALSE = 0
    %TRUE  = NOT %FALSE
    
    %AnyEquate =  %TRUE | %FALSE
    ....
    
    $IF [NOT] %Anyequate
    ...
    $ELSE
    ...
    $ENDIF

    Leave a comment:


  • Mark Hunter
    replied
    Basic, Power or otherwise, uses the constants 0 for False and –1 for True.

    Not n takes n in binary and reverses all the bits. Since –1 is represented as the 16 bit word 1111111111111111 this means Not n = –1 – n. The following PBDOS program illustrates this (leading 0s aren’t shown):
    Code:
     For n = -10 To 10
      Print Not n; -1 - n, Bin$(n), Bin$(-1 - n)
     Next
    Last edited by Mark Hunter; 5 Jan 2008, 08:25 PM.

    Leave a comment:


  • Eric Pearson
    replied
    Dan --

    Michael is correct, NOT 1 is not FALSE.

    If you use 0 and -1 (instead of 1) then $IF NOT will work the way you expect.

    -- Eric

    Leave a comment:


  • Daniel Raymer
    replied
    not

    But I thought that not_true = false.

    Philosophy wasn't my best subject.

    So, my dumb workaround is probably the smart way to go.

    Leave a comment:


  • Michael Mattias
    replied
    'NOT 1' does not equal zero.

    Leave a comment:


  • Daniel Raymer
    replied
    thanks but...

    It is a compiler metastatement. It tells the compiler to skip lines of code if the constant is true (>0).

    $IF...$ENDIF works just fine.

    Leave a comment:


  • Mel Bishop
    replied
    It's been a while since I played with PB/DOS but you can try....

    1. Dump the '$' in front of all IF statements.
    2. Change ENDIF to END IF (with a space).

    I'm probably wrong about this but I think '$' denotes a compiler metastatement. The code will be dealt with at compile time, not at run time.

    Leave a comment:


  • Daniel Raymer
    replied
    obvious workaround

    BTW, the obvious workaround is to use:

    $IF %RDSpro
    $ELSE
    PRINT " if not"
    $ENDIF

    ...but that is not very elegant now, is it?

    So, is $IF NOT supposed to work in PB-DOS?

    Leave a comment:


  • Daniel Raymer
    started a topic $IF NOT is not?

    $IF NOT is not?

    $IF NOT....$ENDIF is given in the PB help listing but not in my old manual. It does not seem to work, and just compiles it regardless of the parameter value. But, it doesn't give an error when you compile.

    Try this, and change %RDSpro from 0 to 1:
    ------------------------------------------
    cls
    %RDSpro=0 'both if 1 only ifnot if 0
    $IF %RDSpro
    PRINT " if "
    $ENDIF
    $IF NOT %RDSpro
    PRINT " if not"
    $ENDIF
    end
    -----------------------------------------

    It should toggle, showing one or the other. Instead you get both if =1, and only "if not" if =0
Working...
X