7 Replies Latest reply on Apr 2, 2007 12:43 AM by Newsgroup_User
      • 1. Re: Script error: Operator expected text = pDataMember.text.line[pQuestionNum] <Void>
        Proddy2k Level 1
        If you need some more infomation, please reply?
        • 2. Re: Script error: Operator expected text = pDataMember.text.line[pQuestionNum] <Void>
          Level 7
          When you are facing errors like this, split the line for easy debug:

          e.g.
          put pDataMember, pDataMember.ilk
          put pQuestionNum, pQuestionNum.ilk
          text = pDataMember.text.line[pQuestionNum]

          Then run the movie and check the output in the message window.
          From the script error you are getting, I'm guessing that the error is
          probably caused by pQuestionNum being void.

          "Proddy2k" <webforumsuser@macromedia.com> wrote in message
          news:euoghk$45m$1@forums.macromedia.com...
          > Can anyone help me overcome this unexpected error I am facing? What does
          > it mean?
          >
          > Script error: Operator expected
          >
          > text = pDataMember.text.line[pQuestionNum]
          >
          > <Void>


          • 3. Re: Script error: Operator expected text = pDataMember.text.line[pQuestionNum] &lt;Void&gt;
            Proddy2k Level 1
            Here is the full coding:

            property pDataMember -- question text
            property pQuestionNum -- current question
            property pPossiblePoints -- points to add to score
            property pScore -- current score
            property pCorrectAnswer -- which is current correct answer
            property pCorrectSound, pWrongSound -- sounds
            property pEndGameFrame -- frame to go to when game is over

            on getPropertyDescriptionList me
            list = [:]

            addProp list, #pDataMember,\
            [ #comment: "Data Member",\
            #format: #text,\
            #default: VOID]

            addProp list, #pCorrectSound,\
            [#comment: "Correct Sound",\
            #format: #string,\
            #default: ""]
            addProp list, #pWrongSound,\
            [#comment: "Wrong Sound",\
            #format: #string,\
            #default: ""]

            addProp list, #pEndGameFrame,\
            [#comment: "End Game Frame",\
            #format: #marker,\
            #default: #next]
            return list
            end

            on beginSprite me
            pQuestionNum = 1
            pScore = 0
            showScore(me)
            askQuestion(me)
            end

            on askQuestion me
            -- get the data
            text = pDataMember.text.line[pQuestionNum]

            -- reset all the button sprites
            sendAllSprites(#makeVisible)

            -- get the question, answers and correct answer number
            the itemDelimiter = ";"
            question = text.item[1]
            answers = text.item[2]
            pCorrectAnswer = value(text.item[3])

            -- display the question
            member("Question").text = question

            -- display the answers
            the itemDelimiter = ","
            repeat with i = 1 to 4
            member("Answer"&&i).text = answers.item
            end repeat

            -- start the potential points at 1000
            pPossiblePoints = 1000
            showPossiblePoints(me)
            end

            -- update the possible points dispaly
            on showPossiblePoints me
            if pPossiblePoints < 0 then pPossiblePoints = 0
            member("Possible Points").text = "Points:"&&pPossiblePoints
            end

            -- update the score display
            on showScore me
            member("Score").text = "Score:"&&pScore
            end

            -- see if an aswer is correct
            on clickAnswer me, n
            if n = pCorrectAnswer then
            if pCorrectSound <> "" then puppetSound pCorrectSound
            -- add to scrore
            pScore = pScore + pPossiblePoints
            showScore(me)
            -- move on to next question
            nextQuestion(me)
            return TRUE
            else
            if pWrongSound <> "" then puppetSound pWrongSound
            -- subtract from potential score
            pPossiblePoints = pPossiblePoints - 100
            showPossiblePoints(me)
            return FALSE
            end if
            end

            -- move on to next question
            on nextQuestion me
            pQuestionNum = pQuestionNum + 1
            if pQuestionNum > pDataMember.text.line.count then
            -- no more questions
            go to frame pEndGameFrame
            else
            askQuestion(me)
            end if
            end

            on exitFrame me
            -- subtract from potential score
            pPossiblePoints = pPossiblePoints - 1
            showPossiblePoints(me)
            go to the frame
            end

            -- take any key presses and send to the button sprites
            on keyDown me
            sendAllSprites(#keyHit,the key)
            end

            I think it is to do with the version of Director I have which is MX 2004. The coding was orginnally for Director 7. Any ideas?
            • 4. Re: Script error: Operator expected text = pDataMember.text.line[pQuestionNum] &lt;Void&gt;
              Level 7
              A friendly hint: Don't post lengthy code - as a rule, noone will bother
              checking it.

              try changing the first handler with the one below, and see how it goes from
              there.

              on getPropertyDescriptionList me
              myList = [:]
              myList.addProp( #pDataMember2, [#comment: "Data Member", #format:#text,
              #default: ""] )
              myList.addProp( #pCorrectSound, [#comment: "Correct Sound",#format:
              #string,#default: ""] )
              myList.addProp( #pWrongSound, [#comment:"Wrong Sound" , #format: #string,
              #default:""] )
              myList.addProp( #pEndGameFrame, [#comment: "End Game Frame",#format:
              #marker,#default: #next] )
              return myList
              end


              "Proddy2k" <webforumsuser@macromedia.com> wrote in message
              news:euopl5$ei5$1@forums.macromedia.com...
              > Here is the full coding:
              >
              > property pDataMember -- question text
              > property pQuestionNum -- current question
              > property pPossiblePoints -- points to add to score
              > property pScore -- current score
              > property pCorrectAnswer -- which is current correct answer
              > property pCorrectSound, pWrongSound -- sounds
              > property pEndGameFrame -- frame to go to when game is over
              >
              > on getPropertyDescriptionList me
              > list = [:]
              >
              > addProp list, #pDataMember,\
              > [ #comment: "Data Member",\
              > #format: #text,\
              > #default: VOID]
              >
              > addProp list, #pCorrectSound,\
              > [#comment: "Correct Sound",\
              > #format: #string,\
              > #default: ""]
              > addProp list, #pWrongSound,\
              > [#comment: "Wrong Sound",\
              > #format: #string,\
              > #default: ""]
              >
              > addProp list, #pEndGameFrame,\
              > [#comment: "End Game Frame",\
              > #format: #marker,\
              > #default: #next]
              > return list
              > end
              >
              > on beginSprite me
              > pQuestionNum = 1
              > pScore = 0
              > showScore(me)
              > askQuestion(me)
              > end
              >
              > on askQuestion me
              > -- get the data
              > text = pDataMember.text.line[pQuestionNum]
              >
              > -- reset all the button sprites
              > sendAllSprites(#makeVisible)
              >
              > -- get the question, answers and correct answer number
              > the itemDelimiter = ";"
              > question = text.item[1]
              > answers = text.item[2]
              > pCorrectAnswer = value(text.item[3])
              >
              > -- display the question
              > member("Question").text = question
              >
              > -- display the answers
              > the itemDelimiter = ","
              > repeat with i = 1 to 4
              > member("Answer"&&i).text = answers.item
              > end repeat
              >
              > -- start the potential points at 1000
              > pPossiblePoints = 1000
              > showPossiblePoints(me)
              > end
              >
              > -- update the possible points dispaly
              > on showPossiblePoints me
              > if pPossiblePoints < 0 then pPossiblePoints = 0
              > member("Possible Points").text = "Points:"&&pPossiblePoints
              > end
              >
              > -- update the score display
              > on showScore me
              > member("Score").text = "Score:"&&pScore
              > end
              >
              > -- see if an aswer is correct
              > on clickAnswer me, n
              > if n = pCorrectAnswer then
              > if pCorrectSound <> "" then puppetSound pCorrectSound
              > -- add to scrore
              > pScore = pScore + pPossiblePoints
              > showScore(me)
              > -- move on to next question
              > nextQuestion(me)
              > return TRUE
              > else
              > if pWrongSound <> "" then puppetSound pWrongSound
              > -- subtract from potential score
              > pPossiblePoints = pPossiblePoints - 100
              > showPossiblePoints(me)
              > return FALSE
              > end if
              > end
              >
              > -- move on to next question
              > on nextQuestion me
              > pQuestionNum = pQuestionNum + 1
              > if pQuestionNum > pDataMember.text.line.count then
              > -- no more questions
              > go to frame pEndGameFrame
              > else
              > askQuestion(me)
              > end if
              > end
              >
              > on exitFrame me
              > -- subtract from potential score
              > pPossiblePoints = pPossiblePoints - 1
              > showPossiblePoints(me)
              > go to the frame
              > end
              >
              > -- take any key presses and send to the button sprites
              > on keyDown me
              > sendAllSprites(#keyHit,the key)
              > end
              >
              > I think it is to do with the version of Director I have which is MX 2004.
              > The
              > coding was orginnally for Director 7. Any ideas?
              >


              • 5. Re: Script error: Operator expected text = pDataMember.text.line[pQuestionNum] &lt;Void&gt;
                Level 7
                correction on last post:
                the prop at line 3 should be #pDataMember, not #pDataMember2

                "alchemist" <unknown@domain.com> wrote in message
                news:eupgdp$ac6$1@forums.macromedia.com...
                >A friendly hint: Don't post lengthy code - as a rule, noone will bother
                >checking it.
                >
                > try changing the first handler with the one below, and see how it goes
                > from there.
                >
                > on getPropertyDescriptionList me
                > myList = [:]
                > myList.addProp( #pDataMember2, [#comment: "Data Member", #format:#text,
                > #default: ""] )
                > myList.addProp( #pCorrectSound, [#comment: "Correct Sound",#format:
                > #string,#default: ""] )
                > myList.addProp( #pWrongSound, [#comment:"Wrong Sound" , #format: #string,
                > #default:""] )
                > myList.addProp( #pEndGameFrame, [#comment: "End Game Frame",#format:
                > #marker,#default: #next] )
                > return myList
                > end
                >
                >
                > "Proddy2k" <webforumsuser@macromedia.com> wrote in message
                > news:euopl5$ei5$1@forums.macromedia.com...
                >> Here is the full coding:
                >>
                >> property pDataMember -- question text
                >> property pQuestionNum -- current question
                >> property pPossiblePoints -- points to add to score
                >> property pScore -- current score
                >> property pCorrectAnswer -- which is current correct answer
                >> property pCorrectSound, pWrongSound -- sounds
                >> property pEndGameFrame -- frame to go to when game is over
                >>
                >> on getPropertyDescriptionList me
                >> list = [:]
                >>
                >> addProp list, #pDataMember,\
                >> [ #comment: "Data Member",\
                >> #format: #text,\
                >> #default: VOID]
                >>
                >> addProp list, #pCorrectSound,\
                >> [#comment: "Correct Sound",\
                >> #format: #string,\
                >> #default: ""]
                >> addProp list, #pWrongSound,\
                >> [#comment: "Wrong Sound",\
                >> #format: #string,\
                >> #default: ""]
                >>
                >> addProp list, #pEndGameFrame,\
                >> [#comment: "End Game Frame",\
                >> #format: #marker,\
                >> #default: #next]
                >> return list
                >> end
                >>
                >> on beginSprite me
                >> pQuestionNum = 1
                >> pScore = 0
                >> showScore(me)
                >> askQuestion(me)
                >> end
                >>
                >> on askQuestion me
                >> -- get the data
                >> text = pDataMember.text.line[pQuestionNum]
                >>
                >> -- reset all the button sprites
                >> sendAllSprites(#makeVisible)
                >>
                >> -- get the question, answers and correct answer number
                >> the itemDelimiter = ";"
                >> question = text.item[1]
                >> answers = text.item[2]
                >> pCorrectAnswer = value(text.item[3])
                >>
                >> -- display the question
                >> member("Question").text = question
                >>
                >> -- display the answers
                >> the itemDelimiter = ","
                >> repeat with i = 1 to 4
                >> member("Answer"&&i).text = answers.item
                >> end repeat
                >>
                >> -- start the potential points at 1000
                >> pPossiblePoints = 1000
                >> showPossiblePoints(me)
                >> end
                >>
                >> -- update the possible points dispaly
                >> on showPossiblePoints me
                >> if pPossiblePoints < 0 then pPossiblePoints = 0
                >> member("Possible Points").text = "Points:"&&pPossiblePoints
                >> end
                >>
                >> -- update the score display
                >> on showScore me
                >> member("Score").text = "Score:"&&pScore
                >> end
                >>
                >> -- see if an aswer is correct
                >> on clickAnswer me, n
                >> if n = pCorrectAnswer then
                >> if pCorrectSound <> "" then puppetSound pCorrectSound
                >> -- add to scrore
                >> pScore = pScore + pPossiblePoints
                >> showScore(me)
                >> -- move on to next question
                >> nextQuestion(me)
                >> return TRUE
                >> else
                >> if pWrongSound <> "" then puppetSound pWrongSound
                >> -- subtract from potential score
                >> pPossiblePoints = pPossiblePoints - 100
                >> showPossiblePoints(me)
                >> return FALSE
                >> end if
                >> end
                >>
                >> -- move on to next question
                >> on nextQuestion me
                >> pQuestionNum = pQuestionNum + 1
                >> if pQuestionNum > pDataMember.text.line.count then
                >> -- no more questions
                >> go to frame pEndGameFrame
                >> else
                >> askQuestion(me)
                >> end if
                >> end
                >>
                >> on exitFrame me
                >> -- subtract from potential score
                >> pPossiblePoints = pPossiblePoints - 1
                >> showPossiblePoints(me)
                >> go to the frame
                >> end
                >>
                >> -- take any key presses and send to the button sprites
                >> on keyDown me
                >> sendAllSprites(#keyHit,the key)
                >> end
                >>
                >> I think it is to do with the version of Director I have which is MX 2004.
                >> The
                >> coding was orginnally for Director 7. Any ideas?
                >>
                >
                >


                • 6. Re: Script error: Operator expected text =   pDataMember.text.line[pQuestionNum]   &lt;Void&gt;
                  Level 7
                  You have asked this question both here and on the DOUG forums.
                  Part of the reason you haven't had it solved for you (or been able to
                  fix it yourself) is because you haven't provided enough information.
                  Do you get this error when you compile the script (the lightning bolt at
                  the top of all script windows) or when you run the file containing this
                  script?
                  Do you get it the first time the script runs, or after it has asked a
                  couple of questions?

                  If you run the file in the authoring environment, when an error occurs
                  you should be presented with a "Debug" button which will open the
                  current script and show local, property and global variables in one of
                  the left-hand panes. I suspect that the error is due to pQuestionNum
                  being VOID or pDataMember being VOID or of the wrong type.
                  Try adding the following couple of lines to the 'on askQuestion' handler
                  and look for output in your message window:
                  --
                  on askQuestion me
                  put "question number:", pQuestionNum
                  put pDataMember, pDataMember.type
                  put pDataMember.text
                  -- get the data
                  text = pDataMember.text.line[pQuestionNum]
                  -- ... etc.
                  • 7. Re: Script error: Operator expected text = pDataMember.text.line[pQuestionNum] &lt;Void&gt;
                    Level 7
                    Proddy2k wrote:
                    > Can anyone help me overcome this unexpected error I am facing? What
                    > does it mean?
                    >
                    > Script error: Operator expected
                    >
                    > text = pDataMember.text.line[pQuestionNum]
                    >
                    > <Void>

                    I wouldn't use the keyword "text" as a variable name.

                    Andrew