Please help on UndoStack usage

Have fully read the DzUndoStack page, and found a lot of methods, but can not find any example, so don't know how to apply them in script.

Here is my exercise:

// This is a Undo test scriptvar aUndoLog = new Array (UndoStack)var sUndo= aUndoLog.toString () //var nUndoIndex = new aUndoLog.getCurrentIndex()//var nNumOfItems = new getNumItems(aUndoLog)aUndoLog.forEach (printEach)print (aUndoLog)print (sUndo)function printEach (sData, nIndex, aList){    print (nIndex, sData, aList)    }

the result is sad:

Executing Script...
0 [object Object] [object Object]
[object Object]
[object Object]

It seems the varible aUndoLog was not correctly defined by just typing UndoStack, so it was returned a generic string representation [object Object]? Then how to define it?

Meanwhile, the UndoStack methods getCurrentIndex() and getNumItems() all got error message if executed:
        TypeError: Result of expression 'aUndoLog.getCurrentIndex' [undefined] is not a constructor.
and
        ReferenceError: Can't find variable: getNumItems

What are the correct usage for these methods?

 

 

I want to see some Undo and UndoStack examples, can anyone help? Thanks!

Comments

  • cridgitcridgit Posts: 1,757
    edited May 2022

    Redacted

    Post edited by cridgit on
  • UndoStack is itself a global variable, so in geernal you can access it directly, no need to assign it to a user-defined variable.

  • functionfunction Posts: 269
    edited January 2022

    Got it. Thank you cridgit! and Thank you Richard!

    Post edited by function on
Sign In or Register to comment.