4 Replies Latest reply on Oct 13, 2016 6:13 AM by Russ Ward

    Programmatic equivalent for the Find dialog Change functions

    Russ Ward Level 4



      Is there a reasonable programmatic equivalent for the Change buttons in the Find dialog? FDK or ES? I have no urgency to find one, but I was going to use it if available. I'm looking for something simple and direct, no wild button-pushing-automation-routines or anything like that.


      I hope this isn't a dumb question. I'm amused that after all these years, it is the first time I've ever thought of a need for it.



        • 1. Re: Programmatic equivalent for the Find dialog Change functions
          Klaus Göbel Level 3

          Hi Russ,

          using "find" you'll receive a textlocation. Now you have to "manually" change the text with oDoc.Delete(TextRange) and then insert your replace-text.

          I hope, I understood your question right???

          • 2. Re: Programmatic equivalent for the Find dialog Change functions
            Russ Ward Level 4

            Hi Klaus,


            I think you have given me the answer, which is "no." I was looking for a way to programmatically emulate the "Change" buttons. While you explain the simple case of text replacement, it gets much more complicated when you are using regular expression replacements and other special replacement types. So, I think this is simply not exposed in the API, as a packaged operation. It would be nice if they would open that up.



            • 3. Re: Programmatic equivalent for the Find dialog Change functions
              Stefan Gentz [Adobe] Adobe Employee (Admin)

              Hi Russ,


              can you give a quick code example, what you have to code now and how you would like to have it in the future?




              • 4. Re: Programmatic equivalent for the Find dialog Change functions
                Russ Ward Level 4

                Hi Stefan,


                Thanks for asking! So, what we have today is a very comprehensive interface to do the Find; that is, to do all the things that you see in the top of the Find pod. But, no way to invoke the things in the bottom of the pod.


                Imagine this scenario... I want to find web pages in a document and add a fully-qualified domain. For example, if I have:


                Page: somepage.htm


                ...and I want to replace all instances with something like this:


                Page: http://somedomain/somepage.htm


                In the Find dialog box, I can use a regex like this:


                Page: [a-z]+\.htm  


                ...then in the Change area, I can use something like this, noting the regex substitution ($1)


                Page: http://somedomain/$1


                In ExtendScript, I have full ability to do the search:


                var findParams = AllocatePropVals (3);
                findParams[0].propIdent.num = Constants.FS_FindText;    
                findParams[0].propVal.valType = Constants.FT_String;    
                findParams[0].propVal.sval = "Page: [a-z]+\\.htm";    
                findParams[1].propIdent.num = Constants.FS_FindCustomizationFlags;    
                findParams[1].propVal.valType = Constants.FT_Integer;    
                findParams[1].propVal.ival = Constants.FF_FIND_USE_REGEX;    
                findParams[2].propIdent.num = Constants.FS_FindWrap;    
                findParams[2].propVal.valType = Constants.FT_Integer;    
                findParams[2].propVal.ival = false;    
                var findTR = oDoc.Find(/*some text loc*/, findParams);



                But, if I want to do the change, I have to programmatically extract the string, to the regex work, do the replacement, etc. Wouldn't it be nice if I could just do something like this, which would emulate clicking the Change button:


                var changeParams = AllocatePropVals (3);
                changeParams[0].propIdent.num = Constants.FS_ChangeType;    
                changeParams[0].propVal.valType = Constants.FT_Integer;    
                changeParams[0].propVal.ival = Constants.FS_ChangeToText;    
                changeParams[1].propIdent.num = Constants.FS_ChangeItem;    
                changeParams[1].propVal.valType = Constants.FT_String;    
                changeParams[1].propVal.sval = "Page: http://somedomain/$1";    
                changeParams[2].propIdent.num = Constants.FS_ChangeCloneCase;    
                changeParams[2].propVal.valType = Constants.FT_Integer;    
                changeParams[2].propVal.ival = false;    
                var changeTR = oDoc.Change(findTR, changeParams);


                That's what I'm thinking about. An interface to the change operations.