for loop closure issues with .anchor

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

smathis

for loop closure issues with .anchor

Post by smathis »

I'm having issues passing this var
Code: Select all              var currentAnchor = currentPath.subPathItems[0].pathPoints.anchor;

Through this function's return code to get around the for loop's scope. I've tried an anonymous function but it isn't playing nice with the var. I've added functions to try and set the scope. Everything else with 'i' is working as expected with data capture into a log file except refreshing these particular values. Do I need to address them differently instead of getting both x,y position of .anchor? Is it how I'm processing .anchor itself?

Code: Select allfunction returnPoint(i) {
               return function() { push(i); };
                }
pathLoop (currentPath, currentAnchor, totalPoints);

function pathLoop (currentPath, currentAnchor, totalPoints, i){
    //Point Loop       
         for(i=0; i <= totalPoints; i++){
           //currentAnchor= returnPoint(i);
              fileOut.write("CurrentAnchor Output" +currentAnchor+"\n");
                     fileOut.write("Point "+i+ "of " +totalPoints+"\n")
                    };
            };