Question
Issue Indesign Script. Trying to mirror words
Hi
I’m learning to script and i write this script (I know, it’s a “nonsense” script).
The script tries to mirror all the words in a document, for example: nonsense > esnesnon.
//SCRIPT//
var g ={};
g.doc = app.activeDocument;
elementosDocumento();
function elementosDocumento() {
for(var i = 0; i < g.doc.pages.length; i ++){ // First loop through the pages of the document
var page = g.doc.pages.item(i); // variable que acumula la página
var pageItems = page.allPageItems; // variable que acumula todos los elementos de la página
for (var j = 0; j < pageItems.length; j ++){ // Second loop, through the items of the current page
var currentItem = pageItems[j]; // variable que acumula el elemento actual
/* Incluir código para actuar con el elemento*/
var currentItemClass = currentItem.constructor.name;
if (currentItemClass == "TextFrame") {
var textBox = currentItem.parentStory;
var textBoxParagraphs = textBox.paragraphs;
var selectedWord_Arr = new Array ();
var mirrorWord = "";
for (var i = 0 ; i < textBoxParagraphs.length ; i++) {
var wordsCount = textBoxParagraphs[i].words;
for (var s = 0; s < wordsCount.length ; s++) {
var myWord = wordsCount[s].characters;
for (var x = 0; x < myWord.length; x++) {
selectedWord_Arr[x] = myWord[x];
}
selectedWord_Arr.reverse();
for (var y = 0; y < selectedWord_Arr.length; y++) {
mirrorWord = mirrorWord + selectedWord_Arr[y].contents;
}
wordsCount[s].contents = mirrorWord;
selectedWord_Arr = [];
mirrorWord = "";
}
}
}
/*FIn incluir código actuar con el elemento*/
}
}
}
I have problems with the characters that are not letters or numbers. When it’s not a number or letter the script adds a number (see the captions) and the character ¿why?
Thanks in advance


