Quantcast
Channel: Adobe Community: Message List - FrameMaker Scripting
Viewing all articles
Browse latest Browse all 3715

Re: Script needed to generate a list of paragraph and character styles from the Book Level

$
0
0

Hi Jim,

 

I think the problem you are having with getting a response is that you are asking someone to write a script for you. Normally, you would have to pay someone for this, as it is something that folks do for a living.

 

Nonetheless, I had a few minutes to spare, so I worked up the following script that I believe does the job. It is very slow, clunky, and totally non-elegant, but I think it works. It leverages the book error log mechanism which is built in and accessible by scripts, but is spendidly unattractive. I hope this gives you a starting point. It could be made much more beautiful, of course, but such would take lots more time.

 

Russ

 

 

 

ListAllFormatsInBook()

function ListAllFormatsInBook()
{
    var doc, path, fmt;        var book = app.ActiveBook;    if(!book.ObjectValid()) book = app.FirstOpenBook;    if(!book.ObjectValid())    {        alert("No book window is active. Cannot continue.");        return;    }    CallErrorLog(book, 0, 0, "-----------------------------------------------------------");    CallErrorLog(book, 0, 0, "** Book format report for:");    CallErrorLog(book, 0, 0, book.Name);    var comp = book.FirstComponentInBook;         while(comp.ObjectValid())    {        path = comp.Name;                doc = SimpleOpen (path, false);                if(doc.ObjectValid())        {            CallErrorLog(book, 0, 0, "-----------------------------------------------------------");            CallErrorLog(book, 0, 0, "-----------------------------------------------------------");            CallErrorLog(book, doc, 0, "");            CallErrorLog(book, 0, 0, "-----------------------------------------------------------");                       CallErrorLog(book, 0, 0, "-----------------------------------------------------------");            CallErrorLog(book, 0, 0, "Paragraph formats:");            fmt = doc.FirstPgfFmtInDoc;            while(fmt.ObjectValid())            {                CallErrorLog(book, 0, 0, "  - " + fmt.Name);                fmt = fmt.NextPgfFmtInDoc;            }                        CallErrorLog(book, 0, 0, "-----------------------------------------------------------");            CallErrorLog(book, 0, 0, "Character formats:");            fmt = doc.FirstCharFmtInDoc;            while(fmt.ObjectValid())            {                CallErrorLog(book, 0, 0, "  - " + fmt.Name);                fmt = fmt.NextCharFmtInDoc;            }        }                else        {            CallErrorLog(book, 0, 0, "-----------------------------------------------------------");            CallErrorLog(book, 0, 0, "!!!  Could not open: " + comp.Name + " !!!");            CallErrorLog(book, 0, 0, "-----------------------------------------------------------");        }            comp = comp.NextComponentInBook;    }
}

function CallErrorLog(book, doc, object, text)
{
    var arg;        arg = "log ";        if(book == null || book == 0 || !book.ObjectValid())        arg += "-b=0 ";    else arg += "-b=" + book.id + " ";    if(doc == null || doc == 0 || !doc.ObjectValid())        arg += "-d=0 ";    else arg += "-d=" + doc.id + " ";    if(object == null || object == 0 || !object.ObjectValid())        arg += "-O=0 ";    else arg += "-O=" + object.id + " ";    arg += "--" + text;        CallClient("BookErrorLog", arg);
}        

Viewing all articles
Browse latest Browse all 3715

Trending Articles