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

Infinite loop with pgf.ObjectValid

New Here ,
Feb 13, 2014 Feb 13, 2014

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

TOPICS
Scripting

Views

495

Translate

Translate

Report

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
New Here ,
Feb 13, 2014 Feb 13, 2014

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!

Votes

Translate

Translate

Report

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 13, 2014 Feb 13, 2014

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

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