5 Replies Latest reply on Jul 23, 2006 2:02 PM by wgb14

    Keeping Time & Number of lines clicked

    wgb14 Level 1
      Hi All,

      I have the following problem that i wonder if someone can help me:

      I want to create a time module that will keep the total time that a user is using the application (from the moment that the application is activated to the moment th euser presses th eexit button) and then write the result into a file (different for each user). Also, i have the following script attached to different text members containing text-phrases.


      on mousedown me

      pointClicked = _mouse.mouseLoc
      currentMember = sprite(1).member
      lineNum = sprite(1).pointToLine(pointClicked)
      lineText = currentMember.line[lineNum]

      case lineNum of
      1: put lineText into member "test"
      2: put lineText into member "test"
      3: put lineText into member "test"
      end case

      --
      end

      I would like to create a script that will count the total number of text-phrases that the user clicks (in all text-members) and then write the result to the same file as the time. Is there any way to do that? I have Buddy API xtra

      Many thanks
        • 1. Re: Keeping Time & Number of lines clicked
          wgb14 Level 1
          Hi again

          I managed to get the timer working as follows:

          on exitFrame me

          startTimer
          end
          on mousedown

          baWriteIni("Performance","Time",""&the timer&"", the moviePath & "prefs.ini")
          end

          As my timer uses ticks, i wonder if there is any way to make it record in my prefs.ini milliseconds. Any suggestiosn will be appriciated

          Also, i wonder if there is anyone that may have an answer on my above request (record in the prefs.ini the total number of phrases a user is selecting from the text-members )

          Thanks
          • 2. Keeping Time & Number of lines clicked
            wgb14 Level 1
            Although i didn't find any answers on the milliseconds problem, i did find something for the record the text phrases problem. Here it is

            property spriteNum

            on mousedown me

            pointClicked = _mouse.mouseLoc
            currentMember = sprite(1).member
            lineNum = sprite(1).pointToLine(pointClicked)
            lineText = currentMember.line[lineNum]


            set mylist = []

            case lineNum of
            1: mylist.add(lineText)

            2: mylist.append(lineText)

            end case

            put mylist into member "record" --- record is used for test purposes, the actual list will be wirtten in an external file using Buddy API
            end

            Although when I click the first line my list gets the appropriate phrase, when i click the second line the second phrase replaces the first one. I want my list to keep all phrases so i can later write it in a file. I am not sure how to do that, please help me

            Many thanks
            • 3. Re: Keeping Time & Number of lines clicked
              Lukewig Level 1
              Hi,

              > on mousedown me
              > ...
              > set mylist = []
              > ...
              > mylist.add(lineText)

              You are creating an empty list with each mouseDown, and adding one thing to it. If you want to record all phrases, then you want to create the list once and then add it it. One way of doing this is create a script called "PhraseTracker" (or similar), and define its methods and properties like this

              -- script("PhraseTracker" ) [parent script]

              property myList

              on AddPhrase (me, aPhrase)
              if myList.ilk <> #List then myList = []
              if myList.getOne(aPhrase) then
              -- already in the list so dont add it?
              else
              myList.append(aPhrase)
              end if
              end

              on GetPhrases (me)
              -- return all the phrases as a string for writing to a file etc
              if myList.ilk <> #List then return "" -- no list created
              -- build a string
              out = ""
              repeat with aPhrase in myList
              out = out & aPhrase & return
              end repeat
              return out
              end


              This script defines a new object for you to use. Now, you can change your behaviour on the text sprite to something like this

              -- Script "PhraseCollector" (behaviour attached to the text sprite)
              on mouseDown (me)
              pointClicked = _mouse.mouseLoc
              thisSprite = sprite(me.spriteNum)
              currentMember = thisSprite.member
              lineNum = thisSprite.pointToLine(pointClicked)
              lineText = currentMember.line[lineNum]

              -- add it to the 'record'
              script("PhraseTracker" ).AddPhrase(lineText)
              end

              Later, when you want to get the list, you could do something like this

              put script("PhraseTracker" ).GetPhrases()


              (note - you could achieve a simular result using global variables -- but I think you will be better of learning Lingo using a good ('object orientated') technique 8-)

              - Luke
              http://www.lingoworkshop.com/

              • 4. Re: Keeping Time &amp; Number of lines clicked
                wgb14 Level 1
                Hi

                Thanks for your answer. Your help is really valuable to me. Many thanks. I guess that is the way to use your script, am i correct?

                on mouseDown (me)
                pointClicked = _mouse.mouseLoc
                thisSprite = sprite(me.spriteNum)
                currentMember = thisSprite.member
                lineNum = thisSprite.pointToLine(pointClicked)
                lineText = currentMember.line[lineNum]

                case lineNum of

                1:script("PhraseTracker").AddPhrase(lineText)

                2:script("PhraseTracker").AddPhrase(lineText)

                3: script("PhraseTracker").AddPhrase(lineText)

                end case

                put script("PhraseTracker").GetPhrases() into member("record")

                Many thanks again
                • 5. Re: Keeping Time &amp; Number of lines clicked
                  wgb14 Level 1
                  Its working perfectly many thanks