Skip navigation
Currently Being Moderated

Could somebody see what is wrong that does not come to my eyes?

May 4, 2012 7:02 PM

Hello,

 

I can't see what is wrong with this code:

I have eleminated excessive codes to make it easier to read... When this code is run I can see the first 3 dialog of app.alert but nothing after than... I can see p is not equal to nP... or at least I should have fallen one time into the do While loop? shouldn't I?  The red app.alert is not displayed why?

 

-----------------

var inch = 72;

try
{   nP = this.numPages;
    var p = 0;
    var x = 0.5;
    app.alert ('p='+ p);
    app.alert ('nP='+ nP);
    app.alert ('this.numPages='+ nP);
    do
      {
       switch (nP)
         {
          case 1:
               {app.alert ('case 1 nP = '+ nP);
               Add2LastPage();
               p += 1;
               break;}
          case nP > 1:
               {app.alert ('case nP > 1 = '+ nP);
               switch (p)
                  {
                   case 0:
                        {
                        x += 0.3;
                        p += 1;
                        break;}
                   default:
                        {
                        x += 0.3;

                        x += 0.3;

                        x += 0.3;

                        p += 1;
                        break;}
                  }
               }
         }  
      }
    while (p != nP);
    Add2LastPage();
}


catch (e)
{
app.alert(e);
}

__________

 
Replies
  • George Johnson
    11,671 posts
    Aug 11, 2002
    Currently Being Moderated
    May 4, 2012 10:21 PM   in reply to JeffBPaarsa

    This following is not valid given the switch expression:

     

    case nP > 1:

     

    The good news is you can replace it with "default" and it should work OK.

     
    |
    Mark as:
  • Currently Being Moderated
    May 5, 2012 7:42 AM   in reply to JeffBPaarsa

    Why not use a for loop to go thorugh your pages?

     

    You can use the switch within the for loop.

     

    Some comments within your code will show others what you are trying to accomplish.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points