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

How can I create an FM-style error log by scripting ?

Advocate ,
Feb 09, 2022 Feb 09, 2022

I have been automating a lot of tedious work for my clients since a long time. In many cases I needed to write an error report to inform the user of stuff they needed to correct in their FM files. I would like to do this in the same manner as the Error Log you get when updating an FM book and some problems occur (files not being opened, color settings that are inconsistent, unresolved cross-references etc.).

 

I check from a simple script and find that this error log is not a document, even though it does contain cross-references to the locations of errors (e.g. unresolved cross-references) in the checked documents. I would like to know a couple of things before I dig into this any further:

1. Is there a way to create this type of view from scripting ?

2. How do I enter text  into that view if it is not a Doc object ?

 

Of course if any of you have a sample script that they would like to share with me, that would be wonderful.

 

Jang

TOPICS
Scripting
694
Translate
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

Community Expert , Feb 09, 2022 Feb 09, 2022

Hi Jang,

I see that there is only one file bookerrorlog (+ one for Chinese Traditional, Chinese Simplified and Korean). IMHO there is only one BookErrorLog client (and one ditamaperrlog.dll) - but the generated document will be saved with a different name. All of these templates in $HOME\fminit do not use a file extension, but they are clearly FM files. All are Read Only, but you can unlock them as Rick told (e.g. to modify paragraph styles. They must not use a file extension. All the files FM l

...
Translate
Community Expert ,
Feb 09, 2022 Feb 09, 2022

Hi Jang,

Here is a simple function that I use:

 

CP.writeBookErrorLog = function (objId, docId, bookId, msg) { 
    
    /// msg = CP.writeBookErrorLog (objId, docId, bookId, msg);
    
    msg = 'log -b=' + bookId + ' -d=' + docId + ' -o=' + objId + ' --' + msg;
    CallClient ('BookErrorLog', msg);
    
    return msg; // Return for troubleshooting.
};

 

You need to pass in the ids of each of your objects; for example, book.id, doc.id, pgf.id, etc. If you aren't running it on a book, pass in 0 for the bookId. msg is the text that you want to appear.

 

The book error log is actually a FrameMaker document. You can see that by pressing Esc F l k to unlock it. Here is some code I use to get its object handle so I can save it, etc.

 

 

CP.getBookErrorLogDoc = function () {
	
	var regex, doc;
	
	// Regex for findingthe book error log.
	regex = /Book Error Log/;
	
	doc = app.FirstOpenDoc;
	while (doc.ObjectValid () === 1) {
		if (regex.test (doc.Label) === true) {
			return doc;
		}
		doc = doc.NextOpenDocInSession;
	}    
};

 

 

Translate
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
Advocate ,
Feb 09, 2022 Feb 09, 2022

I tried to find out if the error log is a read-only FM document by checking app.ActiveDoc but that object is invalid. Does that have to do with the read-only status of this document, then ?

 

There are other error logs that behave in the same way (like when importing EDD into a document and some errors or warnings are generated). Surely they do not use the 'BookErrorLog' client, so this would imply there are a bunch of those ErrorLog clients for various purposes?

Translate
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
Community Expert ,
Feb 09, 2022 Feb 09, 2022

Hi Jang,

I see that there is only one file bookerrorlog (+ one for Chinese Traditional, Chinese Simplified and Korean). IMHO there is only one BookErrorLog client (and one ditamaperrlog.dll) - but the generated document will be saved with a different name. All of these templates in $HOME\fminit do not use a file extension, but they are clearly FM files. All are Read Only, but you can unlock them as Rick told (e.g. to modify paragraph styles. They must not use a file extension. All the files FM likes to open for internal use (bookerrorlog, equation, compare, custom, thesaurs, txttmplt, vertqab - the vertical tool bar) do not have a file extension.

Translate
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
Advocate ,
Feb 09, 2022 Feb 09, 2022

Hello Klaus,

I also found only those two ErrorLog clients. I was already thinking about creating my own template and making it read-only after inserting my error messages into it. So I can experiment with the available templates in the fminit directory as you mention.

Thanks for that info.

Jang

Translate
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
Community Expert ,
Feb 09, 2022 Feb 09, 2022

See also the FDK Programmers Guide and Reference PDFs, where the Book Error Log syntax is detailed.

Translate
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
Advocate ,
Feb 09, 2022 Feb 09, 2022

Thanks Rick,

that is very helpful info. I will have a go at repurposing the BookErrorLog for my needs

Kind regards

Jang

Translate
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
Advocate ,
Feb 10, 2022 Feb 10, 2022
LATEST

With the pointers from Rick and Klaus, I managed to adapt the BookErrorLog to do what I wanted it to do. It is, as Klaus indicated, simply a FrameMaker document which is opened from the fminit directory. And even though it is read-only, I can still make changes to it via scripting. So now my conversion log has exactly that title, and all issues that were found are hyperlinked to the location where they were found. Screenshot.png

Translate
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