Skip navigation
JesRoberts
Currently Being Moderated

Hyphenated Word

Jul 24, 2012 1:21 AM

Hi Friends,

 

How to get the Before and After hyphenation words in indesign scripting.

 

Example:AAAA-BBBBj(Automaticaly hyphenated)

How to get AAA & BBBB and save in separate variables.

 

Please give idea.

 
Replies
  • Currently Being Moderated
    Jul 24, 2012 1:32 AM   in reply to JesRoberts

    @JesRoberts – you could test for the "lines.length" property of the word. If there is more than one line, the word is split. But that does not give you the parts (could be more than two). So you have to test for the lines index of every single character of the word.

     

    Uwe

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 24, 2012 1:47 AM   in reply to JesRoberts

    uh..

    i did something like this a while ago, but i can't find the code.

    the problem is that the automated hypen does not apear in the text variable.

    so.. (assuming that AAAABBBB is stored in myVariable)

     

    myVariable.lines[0] will get the line, ending with the first part of the word,and

    myVariable.lines[1].. you get the ideea.

     

    unfortunatly using

    myVariable.lines[0].words[-1] will give you the entire word (AAAABBBB) so the trick i used was to insert a space at the end of the line like:

    myVariable.lines[0].insertionPoints[-1].contents=" "; then get the first and last part of the word using

    .lines[0].words[-1] and .lines[1].words[0] then remove the added space (.lines[0].characters[-1].remove())

     

    ps. it's just a guide to get you started, in the actual code you will have to be a bit more careful.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 24, 2012 2:07 AM   in reply to JesRoberts

    Hi Friend,

     

    Use the below code to select the first part and second part seperately.

     

    Javascript Code

    var myTxt = app.selection[0];
    var myChar1 = app.selection[0].lines[0].characters[-1];

    var myChar2 = app.selection[0].lines[1].characters[0];

    myTxt.characters[0].select();
    myChar1.select(1633969202); // SelectionOptions.ADDTO

    alert("First part selected");

    myChar2.select();

    myTxt.characters[-1].select(1633969202);

    alert("Second part selected");


    Regards,

    Ramkumar .P

     



     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (1)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points