Copy link to clipboard
Copied
Why would this result in an infinite loop? I thought that wehn it got to the last Pgf object it should become invalid and stop.
var doc = app.ActiveDoc;
var pgf = doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;
while ( pgf.ObjectValid() ) {
Console('Hello');
}
pgf = pgf.NextPgfInFlow;
Thanks,
Mark
Copy link to clipboard
Copied
Whoops, never mind, I had a misplaced end bracket of the while. This is fixed now:
var doc = app.ActiveDoc;
var pgf = doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;
while ( pgf.ObjectValid() ) {
Console('Hello');
pgf = pgf.NextPgfInFlow;
}
I learned a new way to do an infinite loop!
Copy link to clipboard
Copied
Hi Mark,
After I ran into this and similar problems a couple of times, I changed my styling to always put the opening curly bracket on the next line. In that way, the closing bracket is at the same indentation level. Makes it much easier to spot an enclosion error.
while ( condition )
{
if ( other condition )
{
do something;
}
else
{
do something else;
}
get next item;
}
More whitespace, but that is not an issue for the computer.
Kind regards
Jang