Highlighted

Display file on screen when processing book

Community Beginner ,
Aug 23, 2016

Copy link to clipboard

Copied

Hi everyone,

I am working on a complex script to search and replace certain terms. In essence, it searches for the offensive term, shows it on the screen in the file and gives you a dialog box with a suggested edit. Everything works great, but when I'm processing a book, it doesn't pull up the found text range and display it on screen. If you run the script on just a single file, it works great and you can see the offensive term in context. But if you run it on the book and progress your way through the chapters, the file displayed on screen never changes. I know it's running because the display line at the bottom of the book window lists the file it's checking. It just would be nice for users to see the context of the offensive term.

I've tried calling ScrollToText and Redisplay just after finding the term and neither have any effect. I'm guessing that the focus is on the book and that prohibits the focus to switch to the file?

Any ideas or suggestions of things to try would be very much appreciated. I have scoured the scripting guide, and it's too obscure for a generic Google search to find anything.

With appreciation,

Heather Ayer

TOPICS
Scripting

Views

283

Likes

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

Display file on screen when processing book

Community Beginner ,
Aug 23, 2016

Copy link to clipboard

Copied

Hi everyone,

I am working on a complex script to search and replace certain terms. In essence, it searches for the offensive term, shows it on the screen in the file and gives you a dialog box with a suggested edit. Everything works great, but when I'm processing a book, it doesn't pull up the found text range and display it on screen. If you run the script on just a single file, it works great and you can see the offensive term in context. But if you run it on the book and progress your way through the chapters, the file displayed on screen never changes. I know it's running because the display line at the bottom of the book window lists the file it's checking. It just would be nice for users to see the context of the offensive term.

I've tried calling ScrollToText and Redisplay just after finding the term and neither have any effect. I'm guessing that the focus is on the book and that prohibits the focus to switch to the file?

Any ideas or suggestions of things to try would be very much appreciated. I have scoured the scripting guide, and it's too obscure for a generic Google search to find anything.

With appreciation,

Heather Ayer

TOPICS
Scripting

Views

284

Likes

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
Aug 23, 2016 0
Advocate ,
Aug 23, 2016

Copy link to clipboard

Copied

Hello Heather,

If oDoc is the document your script is processing, use

app.ActiveDoc = oDoc

to bring that document into view, then use ScrollToText etc.

Ciao

Jang

Likes

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
Reply
Loading...
Aug 23, 2016 0
Adobe Community Professional ,
Aug 23, 2016

Copy link to clipboard

Copied

In addition to Jang's suggestion, you may need to make sure that the document is visible. Your book code may be opening the document invisibly. To do this, add this line before Jang's:

oDoc.IsOnScreen = 1;

-Rick

Likes

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
Reply
Loading...
Aug 23, 2016 0
Mentor ,
Aug 24, 2016

Copy link to clipboard

Copied

In addition to the suggestions from Jang and Rick, another way to really force a doc to the front is to "open" it again. A simple call like:

SimpleOpen(doc.Name, false);

Russ

Likes

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
Reply
Loading...
Aug 24, 2016 0
Advocate ,
Aug 24, 2016

Copy link to clipboard

Copied

Hi Russ,

Would the SimpleOpen not revert to the last saved document ? That could cause unwanted side-effects. The scripting reference does not mention what the behavior is in these cases. Maybe the FDK ref does.

Ciao

Jang

Likes

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
Reply
Loading...
Aug 24, 2016 0
Mentor ,
Aug 24, 2016

Copy link to clipboard

Copied

Hi Jang,

Negative, SimpleOpen() will open whatever doc you specify. If the document is already open, it forces it to the front. I have found it to be a "stronger" call than setting ActiveDoc, IsInFront, etc.

Russ

Likes

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
Reply
Loading...
Aug 24, 2016 0
Advocate ,
Aug 24, 2016

Copy link to clipboard

Copied

Thanks. Good to know. I never noticed this function before. But then, most of the files I need to open are XML, DITA, SGML or some other species other than native FM - You know I like to work off the paved tracks, way out in the wilderness 😉

Likes

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
Reply
Loading...
Aug 24, 2016 0
Mentor ,
Aug 24, 2016

Copy link to clipboard

Copied

Jang, reading your post again, I see what you were saying. You were talking about the risk of a "Revert to Saved" action instead of a "bring to front" action. I don't think this is addressed in the documentation anywhere, but I have used the Open action reliably on unsaved documents since I started doing this stuff. The behavior has always been the same, in that if the doc is already open, it just comes to the front. Much like double-clicking it in a file explorer.

Russ

Likes

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
Reply
Loading...
Aug 24, 2016 0
Community Beginner ,
Aug 25, 2016

Copy link to clipboard

Copied

Many thanks to all of you for your suggestions. These seem like reasonable things to try. We'll have a go at them today, and tomorrow and I'll report back.

Thanks again for the ideas!

Heather A

Likes

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
Reply
Loading...
Aug 25, 2016 0