16 Replies Latest reply on Jul 4, 2010 6:11 PM by aliandri

    search text on RTF with lingo

    aliandri

      dear all ...

      can help me?..

      I make glossary with RTF text because on RTF Text is easy to change content but can help me to make search text or word on RTF text with lingo..?

      Thankyou

        • 1. Re: search text on RTF with lingo
          Sean_Wilson Adobe Community Professional

          What is it you want to do that offset(member("name").text, "word) doesn't achieve? Have you tried using a JavaScript RegExp object to perform text searches?

          • 2. Re: search text on RTF with lingo
            aliandri Level 1

            thank you for your attantion but i don't know how to use them cause i'm beginner...

            can give me a sample because i try to learn about that and i try it but show error Command Note Define...

             

            Thank you

            • 3. Re: search text on RTF with lingo
              Sean_Wilson Adobe Community Professional

              Please explain what you want to do with your search results. For example, what is it your search needs to do: display which text members contain a particular word; highlight words in a text member; scroll the text member to display the first instance of a word; ... ?

              • 4. Re: search text on RTF with lingo
                aliandri Level 1

                on my movie...

                i place input text field call text1 who concern about text/word searching and box shape for button to execute searching

                another text field fill a full text call text2 ....

                so... if i fill text1 with separate text/word and hit the button so ... that text or word will see on text2 if text2 consist of text1....

                if text1 nothing on text2 so will shoe message text/word not found...

                 

                thankyou...

                • 5. Re: search text on RTF with lingo
                  Sean_Wilson Adobe Community Professional

                  You might attach something like the following to your button:

                  on mouseUp me
                    sMessage = "search text not found"
                    -- assume member names are "text1" and "text2"
                    sSearch = member("text1").text
                    sText   = member("text2").text
                    tOffset = offset(sSearch, sText)
                    if (tOffset > 0) then sMessage = "search text found"
                    alert sMessage
                  end
                  
                  • 6. Re: search text on RTF with lingo
                    aliandri Level 1

                    Thankyou... it's work ....

                     

                    can i help again  ?

                    -- assume member names are "text1" and "text2"

                      sSearch = member("text1").text

                      sText   = member("text2").text

                      tOffset = offset(sSearch, sText)

                     

                    if that text/word is found on text2 and i want show highlight on text2 too...

                    • 7. Re: search text on RTF with lingo
                      Sean_Wilson Adobe Community Professional

                      Please explain - with a picture if necessary - what you mean by "show highlight".

                      • 8. Re: search text on RTF with lingo
                        aliandri Level 1

                        like this ... (show highlight on yellow color)

                         

                        sample highlight.jpg

                        • 9. Re: search text on RTF with lingo
                          Sean_Wilson Adobe Community Professional

                          Changing the BG colour of a chunk of text is not easy. It can be done with some imaging-lingo hoop-jumping, or by having a pool of shape sprites that can be dynamically allocated, sized and positioned.

                           

                          Place the following in a JavaScript typed #movie script:

                          function jsSearch (aString, aMatch) {
                            var aPattern = new RegExp(aMatch, "gi");
                            var found;
                            var results = list();
                            while((found = aPattern.exec(aString)) != null) {
                              results.append(found.index);
                            }
                            return results;
                          }
                          

                          and this in a "regular" Lingo #movie script:

                          on mHighlightMatches aMember, aString
                            -- error check inputs
                            if ilk(aMember, #member) = 0 then
                              aMember = member(aMember)
                              if ilk(aMember, #member) = 0 then
                                exit
                              end if
                            end if
                            
                            if stringP(aString) = 0 then aString = string(aString)
                            if stringP(aString) = 0 then exit
                            
                            -- will only work with #text nmembers
                            if (aMember.type <> #text) then exit
                            
                            aMember.color = rgb(0, 0, 0)
                            len = length(aString)
                            lMatchPositions = jsSearch(aMember.text, aString)
                            if count(lMatchPositions) = 0 then
                              alert "Search text not found"
                            else
                              repeat with aStart in lMatchPositions
                                aMember.char[aStart..(aStart + len)].color = rgb(255, 255, 0)
                              end repeat
                            end if
                          end
                          

                          and now your button script might look like:

                          on mouseUp me
                            mHightlightMatches(member("text2"), member("text1").text)
                          end
                          • 10. Re: search text on RTF with lingo
                            aliandri Level 1

                            thank you for your information...

                            i try this and corrected a error but i can't correct on line consist of

                            ....

                            if count(lMatchPositions) = 0 then
                                alert "Search text not found"
                              else
                                repeat with aStart in lMatchPositions
                                  aMember.char[aStart..(aStart + len)].color = rgb(255, 255, 0)
                                end repeat
                              end if
                            end

                             

                            show message Handler not found in object and stop run on line aMember.char[aStart..(aStart + len)].color = rgb(255, 255, 0)

                            i change with static value like this aMember.char[0..3].color = rgb(255, 255, 0) 

                            but still error...

                             

                            i try to searching to corrected but i can't found it....

                             

                            can explain me...?

                             

                            Thankyou

                            • 11. Re: search text on RTF with lingo
                              Sean_Wilson Adobe Community Professional

                              Which version of Director on which platform?

                               

                              What #type of member holds your text - #text, #field or something else?

                              • 12. Re: search text on RTF with lingo
                                aliandri Level 1

                                thank you....

                                i used Director MX Ver. 10.1 on platform Windows XP

                                 

                                i used #text with option for text1 is editable, framing fixed and text2 isn't editable, framing scrolling

                                 

                                i find on help about color() instruction n i try that code with a simple movie but still not work....

                                 

                                Please can explain that ?

                                or can i send my movie to your email...?

                                 

                                thank you..

                                • 13. Re: search text on RTF with lingo
                                  Sean_Wilson Adobe Community Professional

                                  I am also using 10.1 on XP and I tested what I posted - I have no idea what's going wrong for you. Feel free to upload your movie file somewhere - and provide a URL -  so that I (or someone else) can take a look.

                                  • 14. Re: search text on RTF with lingo
                                    aliandri Level 1

                                    please download this file...

                                     

                                    http://www.ziddu.com/download/10539703/offse.zip.html

                                     

                                    that file is my project...

                                    it's my error...

                                    Thankyou...complie_director.JPG

                                    • 15. Re: search text on RTF with lingo
                                      Sean_Wilson Adobe Community Professional

                                      The error was due to trying to access member.char[0]

                                       

                                      Try the updated handler below:

                                      on mHighlightMatches (aMember, aString)
                                        -- error check inputs
                                        if ilk(aMember, #member) = 0 then
                                          aMember = member(aMember)
                                          if ilk(aMember, #member) = 0 then
                                            exit
                                          end if
                                        end if
                                        
                                        if stringP(aString) = 0 then aString = string(aString)
                                        if stringP(aString) = 0 then exit
                                        
                                        -- will only work with #text nmembers
                                        if (aMember.type <> #text) then exit
                                        
                                        aMember.color = rgb(0, 0, 0)
                                        len = length(aString) - 1
                                        lMatchPositions = jsSearch(aMember.text, aString)
                                        if count(lMatchPositions) = 0 then
                                          alert "Search text not found"
                                        else
                                          repeat with aStart in lMatchPositions
                                            aStart = aStart + 1
                                            aMember.char[aStart..(aStart + len)].color = rgb(255, 255, 0)
                                          end repeat
                                        end if
                                      end
                                      
                                      1 person found this helpful
                                      • 16. Re: search text on RTF with lingo
                                        aliandri Level 1

                                        a million Thank you...

                                        it's work....