5 Replies Latest reply on Aug 4, 2008 5:10 PM by McFazstp

    check void member

    Level 7
      Hi,

      I want to check if a member exists but I think I have an error in my script:

      m = member("titel." & group & "_" & pid)
      -- debugger says m = <void>
      if not(voidp(m)) then
      -- condition is true when m is <void>!?

      What am I doing wrong here?

      TIA
        • 1. Re: check void member
          Level 7
          VoidP checks if a variable is void or not. With your code the variable m
          is always going to have some value so it won't be void, it just may not
          be a real member name. Instead of that, just check if the memberNum is
          greater than zero

          m = member("titel." & group & "_" & pid)
          if member(m).memberNUm > 0 then
          -- member m exist, execute this code
          else
          -- member m does not exist, do something else
          end if



          Marco Mind wrote:
          > Hi,
          >
          > I want to check if a member exists but I think I have an error in my
          > script:
          >
          > m = member("titel." & group & "_" & pid)
          > -- debugger says m = <void>
          > if not(voidp(m)) then
          > -- condition is true when m is <void>!?
          >
          > What am I doing wrong here?
          >
          > TIA
          • 2. Re: check void member
            Level 7
            FYI, Checking that member(m) > 0 is somewhat superfluous. If suffices to
            just check the truth value of member(m).memberNum

            if member(m).memberNum then
            --
            else
            --
            end if
            • 3. Re: check void member
              Level 7
              Opps, scratch that! the memberNum is -1 for non existent members, (I
              thought it was 0) -1 truth value is true. Only 0 is false, so that won't
              work. Stick with the original suggestion. Sorry...


              Dave C wrote:
              > FYI, Checking that member(m) > 0 is somewhat superfluous. If suffices to
              > just check the truth value of member(m).memberNum
              >
              > if member(m).memberNum then
              > --
              > else
              > --
              > end if
              • 4. Re: check void member
                Level 7
                Dave C wrote:
                > VoidP checks if a variable is void or not. With your code the variable m
                > is always going to have some value so it won't be void, it just may not

                Thanks, I wonder why the watcher gives me a <Void> value back. Now I
                check for the member's ilk. Gives often good results too.
                • 5. check void member
                  McFazstp Level 1
                  This will vary depending on your scriptExecutionStyle.

                  _movie.scriptExecutionStyle = 10
                  put member( "invalid member name" )
                  -- <Void>

                  _movie.scriptExecutionStyle = 9
                  put member( "invalid member name" )
                  -- member(-1 of castLib 1)

                  The voidP check is required if you have a scriptExecutionStyle of 10 because it doesn't return a member reference so testing any member properties will cause an error.

                  As to your original question what do you get when you do this?