Announcement

Collapse
No announcement yet.

$IF NOT is not?

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

  • $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

  • #2
    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?

    Comment


    • #3
      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.
      There are no atheists in a fox hole or the morning of a math test.
      If my flag offends you, I'll help you pack.

      Comment


      • #4
        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.

        Comment


        • #5
          'NOT 1' does not equal zero.
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            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.

            Comment


            • #7
              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
              "Not my circus, not my monkeys."

              Comment


              • #8
                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.
                Politically incorrect signatures about immigration patriots are forbidden. Searching “immigration patriots” is forbidden. Thinking about searching ... well, don’t even think about it.

                Comment


                • #9
                  Code:
                  %FALSE = 0
                  %TRUE  = NOT %FALSE
                  
                  %AnyEquate =  %TRUE | %FALSE
                  ....
                  
                  $IF [NOT] %Anyequate
                  ...
                  $ELSE
                  ...
                  $ENDIF
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    %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
                    Rgds, Dave

                    Comment


                    • #11
                      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?
                      Michael Mattias
                      Tal Systems (retired)
                      Port Washington WI USA
                      [email protected]
                      http://www.talsystems.com

                      Comment


                      • #12
                        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.
                        Michael Mattias
                        Tal Systems (retired)
                        Port Washington WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #13
                          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.
                          Rgds, Dave

                          Comment


                          • #14
                            Daniel,

                            If you use the regular Basic values of TRUE = -1 and FALSE = 0, your code works perfectly!
                            "The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.

                            Comment

                            Working...
                            X