Copy link to clipboard
Copied
Hi everyone,
I have developed a script to display the undo history actions in seprate alert.
Inside the for loop the alert is working good.
But, outside the loop it displays only the last action of undo history in alert.
how do i get the same result outside the loop????
I have attached the sample code below
var undo = app.activeDocument.undoHistory;
for (var i = undo.length-1; i>=0; i--)
{
var result= undo[i];
alert(result); //displays all the actions one by one in seprate alert
}
alert(result); //displays only the last action
Thanks in advance....
Regards,
-Jothi
This has nothing to do with InDesign scripting, as suggested to you on multiple occassions before, it would serve you better if you start learn basics of programming.
-Manan
Hi Manan,
Sorry! for the late reply. I'm done with my work and there are always a way out.
Thanks,
Jothi
Copy link to clipboard
Copied
Hi,
Script is running correctly. First your loop is running and it is storing last value of undo[i] in result. Therefore, outside the loop it will alert value of undo[i]. You cannot get the result outside the for loop. UndoHistory is a set of multiple history and to get multiple history you need to do processing inside the loop only. So your script is running correctly. What exactly you want to do.? But getting same result outside the loop is possible as
app.activeDocument.undoHistory[0]
app.activeDocument.undoHistory[1]
app.activeDocument.undoHistory[2]
app.activeDocument.undoHistory[3]
But you don't know when to stop, it may possible you write as alert(app.activeDocument.undoHistory[4]), and app.activeDocument.undoHistory[4] does not exists so it will alert undefined.
Copy link to clipboard
Copied
This has nothing to do with InDesign scripting, as suggested to you on multiple occassions before, it would serve you better if you start learn basics of programming.
-Manan
Copy link to clipboard
Copied
Hi Manan,
Sorry! for the late reply. I'm done with my work and there are always a way out.
Thanks,
Jothi