We have no idea how it works.
Can someone help us?
you can do this without ExtendScript.
Open Search-window (ctrl-f),
type in your regular expression
select "regular expression"
select "Book". (search in)
[EDIT] You need at least FM 12 for regexp
anhand des Namens glaube ich, Du versteht Deutsch
Das macht mir die Erklärung einfacher.
Wir möchten per Script auf mehrere Bücher sehr viele RegEx anwenden.
Die Logik um den Text zu druchsuchen und in einer Schleife die RegEx anzuwenden ist nicht das Problem.
Mein Problem liegt beim Auslesen des kompletten Textes im Buch.
Vielen Dank schonmal für Deine Antwort.
my answer is in English, because not all of the other supporter here in the forum speek German.
I just summarize your answer in English:
You try to read the found text.
- You can replace the found text with search/replace, also
Or what do you want to do with that text?
When you say complete text, do you mean the whole text of the paragraph or what exactly do you mean with "complete text"
Could you plese describe a little more in detail, what you are trying to achieve?
i have many Books with many pages. All these Books i want to check completly with many regular expressions. Future Books too.
I want to write a script witch check all Books for mistakes.
For all Mistakes i have 30-40 regular expresions and i only want to start one script for all.
I hope you understand my bad english ^^
with the function "find" you only can only access a document, but not a book.
So your way will be:
- open the Book
- find all textinsets -> array
- open all textinsets one by one.
- use "find" for every single FM-file in a loop for every regexp.
Sounds easy, but the devil is in the details.
Here is an alternative approach. Regarding the amount of documents and the amount of RegEx' all this stuff could get a very time consuming process within FrameMaker. And perhaps, depending on your background, this is easier than handling text within FrameMaker.
1. Use an ExtendScript to open all documents in a directory and save each to MIF
2. Write an exe in any language of your choice. This executable is responsible for your search and replace part in the MIF file directly *)
3. Call this executable with ES function File.execute()
4. If exe has finished open MIF files again and save them back to FM
5. delete MIF files, as they are not needed any more
(Recommendation: save MIFs in the same document directory, to avoid issues with file references)
*) If you like XML, have a look at Scott Prentice' MIF2ML converter Leximation: MIFML .If you have done the MIF-Export part, you are now able to convert these to MIFML and back again.
Between these two steps you can add SAXON as XSLT processor and do all that RegEx stuff with XSLT2.0. You are able to address Strings with XPath directly. You do not need to parse MIF by your own and you don't need to program high end stuff.
I think the XML path would be the way I would go. It's worth to give it a try.
BTW: my English is not better, so go ahead.