Skip to main content
bagonterman
Inspiring
July 9, 2014
Answered

select next folder not consecutive

  • July 9, 2014
  • 1 reply
  • 352 views

So I have a UI with a button that when clicked it skips to the next folder. This works if you have consecutive folder numbers but sometimes the numbers are not consecutive. I need a way to select whatever is next. I will give you a snippet of what i am currently doing.

mySkipGroup.addBtn.onClick = function(){

         myPgLoc=app.document.presentationPath.slice(0,-3);

     myPgNum=app.document.presentationPath.slice(-3);

     myPgNum=Number (myPgNum)+1;

     myPgNum = myPgNum.toString();

            if (myPgNum.length==3){

                myPgNum=myPgNum;

                }

            if (myPgNum.length==2){

                myPgNum=("0"+myPgNum);

                }

            if(myPgNum.length==1){

                myPgNum=("00"+myPgNum);

                }

           

         if(pgInput.text!=""){

         pgtoSkip=pgInput.text;

        

         if (pgtoSkip.length==3){

                pgtoSkip=pgtoSkip;

                }

            if (pgtoSkip.length==2){

                pgtoSkip=("0"+pgtoSkip);

                }

            if(pgtoSkip.length==1){

                pgtoSkip=("00"+pgtoSkip);

                }

         //alert(myPgLoc+pgtoSkip);

         app.document.setPresentationMode("browser",myPgLoc+pgtoSkip);

         }

     else{

        app.document.setPresentationMode("browser",myPgLoc+myPgNum);

        }

    }

the presentation Mode is looking for an exact location.

This topic has been closed for replies.
Correct answer bagonterman

mySkipGroup.addBtn.onClick = function(){

        myPgLoc=app.document.presentationPath.slice(0,-3);

    myPgNum=app.document.presentationPath.slice(-3);

    myPgNum=Number (myPgNum)+1;

    myPgNum = myPgNum.toString();

    pgLocIndex=myPgLoc.slice(0,-14);

    direct=myPgLoc.slice(0,-50);

    folderIndx=new Folder([pgLocIndex]);

    folderIndx=folderIndx.getFiles();

    for (i=0; i<folderIndx.length; i++){

    var myF = folderIndx;

    if(app.document.presentationPath.match (myF)){

        myPgNum=folderIndx[++i];

        myPgNum2=myPgNum.toString();

        break;}

    }

          

        if(pgInput.text!=""){

        pgtoSkip=pgInput.text;

      

          if (pgtoSkip.length==3){

                pgtoSkip=pgtoSkip;

                }

            if (pgtoSkip.length==2){

                pgtoSkip=("0"+pgtoSkip);

                }

            if(pgtoSkip.length==1){

                pgtoSkip=("00"+pgtoSkip);

                }

      

        app.document.setPresentationMode("browser",myPgLoc+pgtoSkip);

        }

    else{

        //alert(direct+myPgNum2);

        app.document.setPresentationMode("browser",direct+myPgNum2);

        }

    }

This is the solution that I came up with to my problem. I created an array of items from the folder then use the path from the next in the array. So if the next folder is 0000-4 or 0000-12 it goes to the next folder whether its 12 or 14 it goes to next.

1 reply

bagonterman
bagontermanAuthorCorrect answer
Inspiring
July 10, 2014

mySkipGroup.addBtn.onClick = function(){

        myPgLoc=app.document.presentationPath.slice(0,-3);

    myPgNum=app.document.presentationPath.slice(-3);

    myPgNum=Number (myPgNum)+1;

    myPgNum = myPgNum.toString();

    pgLocIndex=myPgLoc.slice(0,-14);

    direct=myPgLoc.slice(0,-50);

    folderIndx=new Folder([pgLocIndex]);

    folderIndx=folderIndx.getFiles();

    for (i=0; i<folderIndx.length; i++){

    var myF = folderIndx;

    if(app.document.presentationPath.match (myF)){

        myPgNum=folderIndx[++i];

        myPgNum2=myPgNum.toString();

        break;}

    }

          

        if(pgInput.text!=""){

        pgtoSkip=pgInput.text;

      

          if (pgtoSkip.length==3){

                pgtoSkip=pgtoSkip;

                }

            if (pgtoSkip.length==2){

                pgtoSkip=("0"+pgtoSkip);

                }

            if(pgtoSkip.length==1){

                pgtoSkip=("00"+pgtoSkip);

                }

      

        app.document.setPresentationMode("browser",myPgLoc+pgtoSkip);

        }

    else{

        //alert(direct+myPgNum2);

        app.document.setPresentationMode("browser",direct+myPgNum2);

        }

    }

This is the solution that I came up with to my problem. I created an array of items from the folder then use the path from the next in the array. So if the next folder is 0000-4 or 0000-12 it goes to the next folder whether its 12 or 14 it goes to next.