• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Hyphenated Word

Guest
Jul 24, 2012 Jul 24, 2012

Copy link to clipboard

Copied

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.

TOPICS
Scripting

Views

892

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Jul 24, 2012 Jul 24, 2012

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



Votes

Translate

Translate
Community Expert ,
Jul 24, 2012 Jul 24, 2012

Copy link to clipboard

Copied

@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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 24, 2012 Jul 24, 2012

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 24, 2012 Jul 24, 2012

Copy link to clipboard

Copied

LATEST

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



Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines