FrameMaker becomes unresponsive while running the script for the 2nd time
Bhavna Raghwani
bhavna.raghwani at gmail.com
Mon Jan 26 00:21:01 PST 2015
Hi Framers,\
I am trying to run to traverse through the paragraph tags in the book
files and check for a condition applied on them using the following script:
var openedBook = app.ActiveBook
//openBookFiles(openedBook)
//savePdf(openedBook,bookFile + ".pdf")\
var arr_ChapterIds=new Array();
var bookChapter=openedBook.FirstComponentInBook
var chapterId = bookChapter.id
var pgfText = null;
var msg = null;
var totalPgfs = 0;
/* Calculating the number of chapters in the book */
while(chapterId)
{
var chapterId = bookChapter.id
var chapterName = bookChapter.Name
chapterId=openFile(chapterName)
if(chapterId!=0 && chapterId!="")
{
arr_ChapterIds.push(chapterId)
}
bookChapter = bookChapter.NextComponentInBook;
chapterId = bookChapter.id;
}
// Err(arr_ChapterIds.length);
/*Processing the tasks for each chapter*/
for(i=0; i<arr_ChapterIds.length;i++)
{
var objcid=arr_ChapterIds[i];
cid=objcid.id;
cname=objcid.Name;
/* Traversing through the paragraphs*/
var pgf = objcid.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;
while(pgf.ObjectValid() == true)
{
totalPgfs = totalPgfs + 1;
var formatName = pgf.Name;
var textRange = new TextRange();
textRange.beg.obj = pgf;
textRange.beg.offset = 0;
textRange.end.obj = pgf;
textRange.end.offset = Constants.FV_OBJ_END_OFFSET;
var textItems = objcid.GetTextForRange(textRange,
Constants.FTI_String);
if(textItems.length > 0)
{
pgfText = textItems[0].sdata;
if(pgfText.length > 50)
pgfText = pgfText.substring(0, 50);
}
else pgfText = "(No text!)";
if(pgf.Name=="Related_Topics" && textItems.length>0)
{ Err ("Related Topics tag is applied for:"+pgfText+"\n\n");}
pgf = pgf.NextPgfInFlow;
}
var getChangeBarVal=objcid.AutoChangeBars;
if (getChangeBarVal==1)
Err("Change Bars are on for:"+cname+"\n\n");
else
Err("Change Bars are off for:"+cname+"\n\n");
}
function openFile(chapterName)
{
openProp = GetOpenDefaultParams()
retParm = new PropVals()
fileOpen=Open(chapterName,openProp,retParm)
return fileOpen;
}
This script runs fine for the first time and displays the result on the
FrameMaker console. However, here are the issues that I am facing:
- After the execution is finished for the first time and as I try to
save the book file, FrameMaker displays an error message
- If I run the script the next time, FrameMaker becomes completely
unresponsive needing a forced shutdown
There are many paragraph tags that the script traverses through and
probably stores in a variable. Therefore, I think it may be a memory issue.
Can you please go through the script and help me in debugging the issue.
Thanks.
Regards,
Bhavna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.frameusers.com/pipermail/framers-frameusers.com/attachments/20150126/6b6eef5c/attachment.htm>
More information about the framers
mailing list