app.response answer determines function change var
I am not sure if this is doable or not, thinking about this the wrong way or i am just completely missing something. I normally like to try to figure out where i went wrong but this has gotten me stuck.
I am trying to take the standard trim bookmark name function and make is user changeable to select what part of the bookmark is being changed via a popup question. I set up folder level. When i try to run in Adobe Pro 9.0 i receive "An internal error occurred" message. In console i receive "redeclaration of const TrimBookmark2:Console:Exec". Any help would be appreciated
function TrimBookmark()
{
var Title = new String(bkm.name);
bkm.name = cResponse;
// bkm.name = Title.substr(0, NumChars);
// bkm.name = Title.substr(-NumChars,NumChars);
// bkm.name = Title.slice(NumChars,Title.length);
// bkm.name = Title.slice(0,-NumChars);
if (bkm.children != null)
{
for (var i = 0; i < bkm.children.length; i++)
{
TrimBookmark(NumChars, bkm.children, nLevel + 1);
}}}
function TrimQuestion()
{
var cResponse = app.response({
cQuestion: "Enter A to set bookmark to the FIRST number of characters" + "\n" + "\n" +
"Enter B to set bookmark to the LAST number of characters" + "\n" + "\n" +
"Enter C to trim the BEGINING of the bookmark" + "\n" + "\n" +
"Enter D to trim the END of the bookmark",
cTitle: "Select Option",
cLabel: "Select Option:"
});
if (cResp == "A") {
event.value = Title.substr(0, NumChars);
}
else if (cResp == "B") {
event.value = Title.substr(-NumChars,NumChars);
}
else if (cResp == "C") {
event.value = Title.slice(NumChars,Title.length);
}
else if (cResp == "D") {
event.value = Title.slice(0,-NumChars);
}
var root = this.bookmarkRoot;
var NumCharsToTrimTo = 2;
TrimBookmark(NumCharsToTrimTo, root, 0);
}
app.addMenuItem({
cName: "TrimBookmark",
cUser: "Trim Bookmark",
cParent: "View",
cExec: "TrimQuestion();",
cEnable: "event.rc = (event.target != null);"
});
