7 Replies Latest reply on Jan 31, 2008 8:18 PM by Newsgroup_User

    Difference in boolean ops for MX 2004?

    Level 7
      I just noticed this and it was driving me nuts. It used to be that if I had
      a statement that said:

      if [var] then [do something]

      And if the [var] was greater than 0, it would [do something], and if 0 or
      lower, it wouldn't. Now, it seems that values below 0 have the same effect
      as values above 0. The only value that makes it *not* [do something] is if
      it's *exactly* 0. So if a variable ever has the potential to go negative, I
      have to change all such statements referencing it to:

      if [var] > 0 then [do something]

      Am I the only one seeing this problem? The same scripts worked fine in MX,
      but in MX 2004, I have to add "> 0" to them all to make them work correctly.
      Not only is this annoying to have to search through and fix all the code
      that's written that way, it's also inconsistant with just about every other
      language I've ever programmed in. Kind of a weird change for them to
      make...


        • 1. Re: Difference in boolean ops for MX 2004?
          Chunick Level 3
          try setting the scriptExecutionStyle to 9, eg.

          the scriptExecutionStyle = 9

          set it back to 10 when you want to use MX2004 syntax/code.
          • 2. Re: Difference in boolean ops for MX 2004?
            Level 7
            "And if the [var] was greater than 0, it would [do something], and if 0
            or lower, it wouldn't. Now, it seems that values below 0 have the same
            effect as values above 0. "

            Hasn't it always been this way?

            0 is false, every other integer is evaluates to true, even negative
            integers.
            • 3. Re: Difference in boolean ops for MX 2004?
              Level 7
              > try setting the scriptExecutionStyle to 9, eg.
              >
              > the scriptExecutionStyle = 9
              >
              > set it back to 10 when you want to use MX2004 syntax/code.

              Yeah, unfortunately, I've got other scripts in the same movie that depend on
              it being style 10, so that's not an option.

              I mean, it's an easy fix, once I track down all the places that need it, I'm
              just rather miffed that they changed this, and I kind of wonder what their
              reason for doing so was? I mean, most other languages interpret negative
              values as FALSE in boolean statements, and so did Lingo up until the latest
              version. I just don't understand why they felt the need to buck the trend
              and change that basic rule...


              • 4. Re: Difference in boolean ops for MX 2004?
                Level 7
                Pardon me for jumping in your thread, but I am very curious about this.
                I use the same sort of technique all of the time. I do use an old
                version of Director (8.5) but hope to upgrade when a new one is
                released. I don't want to run into any such problems when I import my
                old code.

                8.5 evaluates negative numbers as TRUE. I confirmed this by creating the
                following handler

                on testTruthValue whichValue
                if whichValue then
                return TRUE
                else
                return FALSE
                end if
                end


                and then testing it in the message window

                put testTruthValue(-1)
                -- 1

                put testTruthValue(0)
                -- 0

                put testTruthValue(1)
                -- 1

                You said "most other languages interpret negative values as FALSE in
                boolean statements, and so did Lingo up until the latest version."

                This hasn't been my experience, so what am I missing?
                • 5. Re: Difference in boolean ops for MX 2004?
                  Level 7
                  I just tested Dir MX (v9) and it also evaluates any non-zero number as
                  true... positive or negative. It is doing a boolean operation of
                  zero=false and anything else is true
                  • 6. Re: Difference in boolean ops for MX 2004?
                    Level 7
                    TTBOMM, anything non-zero evaluates to TRUE and has done since D5.

                    Things get messy when involving VOID in a boolean comparison, but that
                    too is operator error and why the function voidP() exists
                    • 7. Re: Difference in boolean ops for MX 2004?
                      Level 7
                      >I just tested Dir MX (v9) and it also evaluates any non-zero number as
                      >true... positive or negative. It is doing a boolean operation of
                      >zero=false and anything else is true

                      Hmm... This is odd, because I know for a fact that the code I'm using
                      worked perfectly in MX, but doesn't in 2004 unless I add the >0. Now,
                      running simple tests without all the other stuff going on I get the same
                      results as you guys. Unfortunately, my actual code is far more complicated,
                      so there's any number of other things that could be happening differently, I
                      suppose. Can't think of what other difference would, say, prevent the
                      numbers from going negative in the first place? Because that's the only
                      difference between these two versions of my code. It'd be far too much code
                      to post here searching for the causes of this.

                      At any rate, negative numbers evaluating as false IS the standard in most
                      programming languages, but then I guess Macromedia has never been one to bow
                      to the industry standard for anything... (*grumbles something about
                      Ctrl-arrow-keys flipping between scripts instead of jumping from word to
                      word like every other program in existence, random functions starting at 1
                      instead of 0, etc...*) We'll see if Adobe straightens them out on some of
                      these issues, assuming they ever do release another Director version...