15 Replies Latest reply on Apr 20, 2007 6:56 AM by Chunick

    Void not really void

    macandrew
      I ran into a frustrating bug which was only solved when I recognized what appears to be a logical inconsistency (a "bug") where the keyword Void isn't really Void. Try this in the Message window:

      put bozo
      -- <Void>
      put bozo = Void
      -- 1
      bozo = 0
      put bozo = Void
      -- 1

      I was checking to see whether a certain variable (relating to user input) had been initialized (i.e. the user had entered a value for that item) - and 0 being a legitimate value (in this case) obviously I was expecting Void to be different from 0!

      the fix:

      put voidP(bozo)
      -- 0

      Logically, Void does NOT equal 0 -- except to Lingo

      (Director 10.1.1, Mac OS 10.4.9)
        • 1. Re: Void not really void
          Level 7
          Yes that one has been brought up a few times. It's definitely an
          inconsistency, call it a bug if you like.

          put void = 0
          --1
          put voidP(0)
          --0

          Odd eh.


          --
          Dave -
          Head Developer
          http://www.blurredistinction.com
          Adobe Community Expert
          http://www.adobe.com/communities/experts/


          • 2. Re: Void not really void
            Level 7
            I think you are misunderstanding something. Typing

            put bozo = anything

            is going to return true (1). It is not a test statement, it is an
            assignment. The return of true basically says "Yes, bozo has been assigned
            the value of whatever".

            Try this

            bozo = 0
            put bozo = Void
            -- 1
            put bozo
            -- <Void>

            Using voidP is the correct way to test for VOID.



            • 3. Re: Void not really void
              Level 7
              You're right voidP is the proper way to test. Except it's still
              inconsistent: put void = 0 should not return true - you shouldn't be able to
              assign 0 to void. This is also one reason it's better to use = for
              assignment and == for equality.

              --
              Dave -
              Head Developer
              http://www.blurredistinction.com
              Adobe Community Expert
              http://www.adobe.com/communities/experts/


              • 4. Re: Void not really void
                Level 7
                Since you are into inconsistencies, try this out:

                put [#a, #b].findPos("b")


                "DMennenoh **AdobeCommunityExpert**" <dave@blurredistinction.com> wrote in
                message news:f0638v$qi1$1@forums.macromedia.com...
                > You're right voidP is the proper way to test. Except it's still
                > inconsistent: put void = 0 should not return true - you shouldn't be able
                > to assign 0 to void. This is also one reason it's better to use = for
                > assignment and == for equality.
                >
                > --
                > Dave -
                > Head Developer
                > http://www.blurredistinction.com
                > Adobe Community Expert
                > http://www.adobe.com/communities/experts/
                >


                • 5. Re: Void not really void
                  CopyPixels
                  Dave C,

                  "put bozo = anything' is a test statement in Lingo.

                  macandrew ,

                  Void should never equal zero, but it does. So, you use VoidP:

                  if bozo.VoidP then
                  -- assign default
                  else
                  -- use current value
                  end if

                  Randal.
                  • 6. Re: Void not really void
                    Level 7
                    Here's food for thought. If variables are initialized properly you
                    shouldn't have to test for VOID.


                    --
                    Craig Wollman
                    Lingo Specialist
                    Word of Mouth Productions
                    212-928-9581

                    www.wordofmouthpros.com
                    "macandrew" <webforumsuser@macromedia.com> wrote in message
                    news:f05j12$6rv$1@forums.macromedia.com...
                    >I ran into a frustrating bug which was only solved when I recognized what
                    > appears to be a logical inconsistency (a "bug") where the keyword Void
                    > isn't
                    > really Void. Try this in the Message window:
                    >
                    > put bozo
                    > -- <Void>
                    > put bozo = Void
                    > -- 1
                    > bozo = 0
                    > put bozo = Void
                    > -- 1
                    >
                    > I was checking to see whether a certain variable (relating to user input)
                    > had
                    > been initialized (i.e. the user had entered a value for that item) - and 0
                    > being a legitimate value (in this case) obviously I was expecting Void to
                    > be
                    > different from 0!
                    >
                    > the fix:
                    >
                    > put voidP(bozo)
                    > -- 0
                    >
                    > Logically, Void does NOT equal 0 -- except to Lingo
                    >
                    > (Director 10.1.1, Mac OS 10.4.9)
                    >


                    • 7. Re: Void not really void
                      CopyPixels Level 1
                      Craig,

                      Absolutely!

                      But, variables passed into a method may be Void. You have to check.

                      Randal.
                      • 8. Re: Void not really void
                        CopyPixels Level 1
                        alchemist,

                        I was not familiar with " put [#a, #b].findPos("b")". That makes no sense.

                        As you know, Lingo is case insensitive, so the following which I'm sure you are aware of makes no sense.

                        put ["B"].findpos("b")
                        -- 0

                        put ["B":0].findpos("b")
                        -- <Void>

                        Hey, we're back to Void, because void equals Zero......NOT!

                        Are we hav'in fun yet.

                        Randal.
                        • 9. Void not really void
                          Lukewig Level 1
                          If you want to be sure, use a function like this:

                          on equal (var1, var2)
                          -- check the ilk, and then wrap in lists
                          -- for case-sensitivity of strings
                          if var1.ilk = var2.ilk then return ([ var1 ] = [ var2 ])
                          else return 0
                          end
                          • 10. Re: Void not really void
                            Lukewig Level 1
                            -- put [#a, #b].findPos("b")

                            Director does try to be really 'helpful' when comparing things of different types:

                            put "a" = #a
                            -- 0

                            put ["a"]=[#a]
                            -- 1

                            The findPos result is pretty kooky since #symbols are really just integers with a text-label. It would appear that symbols in lists are something special.
                            -- Luke
                            • 11. Re: Void not really void
                              Level 7
                              Hmmm...I haven't run into that case before...well actually I have and
                              modified my code to keep it from happening....just convention I suppose.



                              --
                              Craig Wollman
                              Lingo Specialist
                              Word of Mouth Productions
                              212-928-9581

                              www.wordofmouthpros.com
                              "CopyPixels" <webforumsuser@macromedia.com> wrote in message
                              news:f06i21$dhs$1@forums.macromedia.com...
                              > Craig,
                              >
                              > Absolutely!
                              >
                              > But, variables passed into a method may be Void. You have to check.
                              >
                              > Randal.


                              • 12. Re: Void not really void
                                Level 7
                                > put ["a"]=[#a]
                                > -- 1
                                put [1,2].findPos("2")
                                -- 2

                                > #symbols are really just integers
                                Ehm.. nope, actually they are not - they are just the same in size (both 8
                                bytes 4header + 4value).
                                Symbols are positions in an internal list, holding string values.
                                When compiling a lingo script, for every symbol director will perform a
                                search in that list, and create the integer-like symbol value.
                                That's why the less symbols created, the faster the movie will be.


                                "Lukewig" <webforumsuser@macromedia.com> wrote in message
                                news:f06k76$ft8$1@forums.macromedia.com...
                                > -- put [#a, #b].findPos("b")
                                >
                                > Director does try to be really 'helpful' when comparing things of
                                > different
                                > types:
                                >
                                > put "a" = #a
                                > -- 0
                                >
                                > put ["a"]=[#a]
                                > -- 1
                                >
                                > The findPos result is pretty kooky since #symbols are really just
                                > integers
                                > with a text-label. It would appear that symbols in lists are something
                                > special.
                                > -- Luke
                                >



                                • 13. Void not really void
                                  Chunick Level 3
                                  quote:

                                  ran into a frustrating bug which was only solved when I recognized what appears to be a logical inconsistency (a "bug") where the keyword Void isn't really Void. Try this in the Message window:

                                  it's not too surprising since Director's data types are very loosely cast, for example:
                                  val = "3"
                                  put val + 2
                                  -- 5 (or 5.000, depending what the floatPrecision is set to)

                                  so, lesson learned; use voidP(), floatP(), objectP(), integerP(), stringP() to test data types.
                                  • 14. Re: Void not really void
                                    Level 7
                                    And don't forget igottaP ()

                                    Sorry, I couldn't resist. (obviously)

                                    --
                                    Craig Wollman
                                    Lingo Specialist
                                    Word of Mouth Productions
                                    212-928-9581

                                    www.wordofmouthpros.com
                                    "Chunick" <webforumsuser@macromedia.com> wrote in message
                                    news:f09fbd$4dd$1@forums.macromedia.com...
                                    >
                                    quote:

                                    ran into a frustrating bug which was only solved when I recognized what
                                    > appears to be a logical inconsistency (a "bug") where the keyword Void
                                    > isn't
                                    > really Void. Try this in the Message window:

                                    > it's not too surprising since the data types can be very loosely cast in
                                    > Director, for example:
                                    > val = "3"
                                    > put val + 2
                                    > -- 5 (or 5.000, depending what the floatPrecision is set to)
                                    >
                                    > so, lesson learned; use voidP(), floatP(), objectP(), integerP(),
                                    > stringP() to
                                    > test data types.
                                    >


                                    • 15. Re: Void not really void
                                      Chunick Level 3
                                      quote:

                                      Originally posted by: Newsgroup User
                                      And don't forget igottaP ()

                                      LMAO! :-)