Hi,
I noticed that after one traversal of all paragraphs as given by function 1, framemaker gets stuck and maybe due to that I am unable to execute the while loop in the second function. ($.writeln("CHECK2"); doesn;t get executed)
Please let me know if I am missing out on closing some dangling variables etc. I have attached the code as well.
Thanks,
Sebin
var doc = app.ActiveDoc;
doc.ShowCondIndicators =1;
var txtFile = "C:/gen_seb.txt";
var file = new File(txtFile);
file.open("w"); // open file with write access
var hash = generate_list(doc);
find_defined_list_attributes(doc);
file.close();
function generate_list(doc)
{
var list = {};
var pgf= doc.FirstPgfInDoc;
var cndfmt = doc.FirstCondFmtInDoc;
var count = 0 ;
//doc.CondFmtIsShown = 1;
doc.ShowAll = 0;
while (pgf.ObjectValid()){
var test = pgf.GetText(Constants.FTI_String);
var text, str;
text = "";
for (var i=0; i < test.len ; i +=1)
{
var str=test[i] .sdata.replace(/^\s+|\s+$/g, '') ;
text = text + str;
}
if (pgf.Name == 'Name_1')
{
var tr = new TextRange ();
tr.beg.obj = tr.end.obj = pgf;
tr.beg.offset = 0;
tr.end.offset = Constants.FV_OBJ_END_OFFSET;
var props = doc.GetTextPropVal(tr.beg,Constants.FP_InCond);
if(props.propVal.isval.length >0)
{
var cnt = 0;
var con_shown = 0;
var propLength= props.propVal.isval.length;
while(cnt<propLength)
{
if((props.propVal.osval[cnt].CondFmtIsShown))
{
con_shown = 1;
break;
}
else
cnt++;
}
if(con_shown == 1)
{
file.writeln(text);
var regexp = /\(\S+\)/gi;
var regmatch = text.match(regexp);
regmatch=String(regmatch);
regmatch= regmatch.replace(/\(|\)/g, '');
list[regmatch] = [0,0];
}
}
}
pgf=pgf.NextPgfInDoc;
}
return reg_list;
}
function find_defined_list_attributes(doc)
{ $.writeln("CHECK1");
var pgf= doc.FirstPgfInDoc;
while (pgf.ObjectValid())
{ $.writeln("CHECK2");
pgf=pgf.NextPgfInDoc;
}
}