• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Programmatic equivalent for the Find dialog Change functions

Mentor ,
Sep 30, 2016 Sep 30, 2016

Copy link to clipboard

Copied

Hi,

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.

Russ

TOPICS
Scripting

Views

708

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Oct 12, 2016 Oct 12, 2016

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???

Votes

Translate

Translate
Enthusiast ,
Oct 12, 2016 Oct 12, 2016

Copy link to clipboard

Copied

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???

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Oct 12, 2016 Oct 12, 2016

Copy link to clipboard

Copied

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.

Russ

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 12, 2016 Oct 12, 2016

Copy link to clipboard

Copied

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?

Cheers,

*Stefan.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Oct 13, 2016 Oct 13, 2016

Copy link to clipboard

Copied

LATEST

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.

Russ

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines