Hey Robert,
While you are very close, you don’t quite have the proper syntax here.
Where you have this line:
app.doScript(String(main()),ScriptLanguage.JAVASCRIPT,[],UndoModes.ENTIRE_SCRIPT,’main’);
You should have:
app.doScript(main, ScriptLanguage.javascript, undefined, UndoModes.entireScript, “main”);
To break it down:
Part 1.) app.doScript(
Part 2.) main,
This is the name of your function. No need for any quotes or parenthesis here.
Part3.) ScriptLanguage.javascript,
Pretty much the same thing as what you have…
Part 4.) undefined,
This is where you enter any of your function inputs. If any exist, they must be input in the form of an array. I entered “undefined” but you could use the empty array like you did (I believe that the”doScript” method can work either way)
Part5.) “main”);
This can say anything at all, this is simply the label that will be displayed next to the word “Undo” if you go into your edit menu to undo the script. This could say anything. If you entered “wombats” here then your edit menu would read “Undo wombats” and that would undo your entire script.
I hope that this all makes sense. Feel free to ask any questions that you may have!