Thank's again Ariel,
I am a beginner in Java Script and I don't know what I am doing wrong.
Please take a look:
main();
function main(){
mySetup();
mySnippet();
myTeardown();
}
function mySetup(){
}
function mySnippet(){
if (app.documents.length != 0){
if (app.selection.length == 1){
switch (app.selection[0].constructor.name){
case "InsertionPoint":
case "Character":
case "Word":
case "TextStyleRange":
case "Line":
case "Paragraph":
case "TextColumn":
case "Text":
case "Story":
myProcessText(app.selection[0]);
break;
case "TextFrame":
myProcessText(app.selection[0].texts.item(0));
break;
default:
alert("The selected object is not a text object. Select some text and try again.");
break;
}
}
else{
alert("Please select some text and try again.");
}
}
}
function myTeardown(){
}
function myProcessText(myTextObject){
}
var myDocument = app.documents.item(0);
var myPage = myDocument.pages.item(0);
var myTextFrame = myPage.textFrames.item(0);
var myTextObject = myTextFrame.parentStory.characters.item(0);
var myStory = myDocument.stories.item(0);
var myStringArray = myTextFrame.lines.everyItem().contents;
myPara = app.selection[0];
myLines = myPara.lines;
for (var i =0; i<myLines.length; i++){
myFinds = myLines.findText(ת);
myFinds[-1].contents = "z";
}
Sami
Hi,
Assuming your text is inside one or more text frames which are connected. Select one of them and run this:
-------------
myLines = app.selection[0].parentStory.lines;
for (k=0; k<myLines.length; k++){
if(myLines.characters[-1] == "\r") // if there is an end of paragraph
myLines.characters[-2].contents = "z"; // change a second last character to "z"
else myLines.characters[-1].contents = "z"; // otherwise change a last character to "z"
}
------------
This is just for show the way.
Hope you step into 