Beenden
  • Globale Community
    • Sprache:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

[InDesign CS3] - How to select the partially text from the selection

Gast
Feb 11, 2010 Feb 11, 2010
Hi,

I have an XML embedded InDesign file in which some page numbers are given under link tag. The first page information, before endash(–), will be link to "start" attribute and sendcond page information, after the endash(–), will be link to "end" attribute.

The first page informatio is 125 and the second page information is 26 in the below example.

<link start="c51351-549" end="c51351-550">125–26</link>

Everything I have done but not able to select both the informations individually to link means I have to first select the 125 and link, and after that I have to select 26 and make a link. I'm using the followin code to select the information which select both 125 and 26 with endash.

var root  = myDoc.xmlElements[0];
var xpath = "//link";
var node  = null;
try
{
  var proc  = app.xmlRuleProcessors.add ([xpath]);
  var match = proc.startProcessingRuleSet (root);
  while( match!=undefined )
  {
   node = match.element;
   myDoc.select(node.texts);
   sourceText=myDoc.selection[0];

Please, could you look into this and do the needful.

Thanks,

Anil Yadav

THEMEN
Skripterstellung
1.2K
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Beitragender ,
Feb 11, 2010 Feb 11, 2010

Hi Anil Yadav,


Select the XML Element [link] and execute the below code:


var myText = app.selection[0].texts[0];
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences.findWhat = "[0-9]+";
var myFound = myText.findGrep();
for(var Len = 0; Len <
myFound.length; Len++)
{
   
myFound[Len].select();
    alert(
myFound[Len].contents)
}

I hope this will give you the idea.


Regards,

Ramkumar .P

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Gast
Feb 16, 2010 Feb 16, 2010

Thank you very much!!!

Anil Yadav

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Neu hier ,
Feb 18, 2010 Feb 18, 2010

hi Ram,


how to find the paticular word from element content.


eg)


<para>select the partially text</para>


From above content i have to select "partially", only.


Thanks

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Engagiert ,
Feb 18, 2010 Feb 18, 2010

replace your text in findWhat

Like below 

var myText = app.selection[0].texts[0];
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences.findWhat = "partially";
var myFound = myText.findGrep();
for(var Len = 0; Len <
myFound.length; Len++)
{
   
myFound[Len].select();
    alert(
myFound[Len].contents)
}
Shonky

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Neu hier ,
Feb 18, 2010 Feb 18, 2010

yes, Thanks Shonky

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community Expert ,
Feb 18, 2010 Feb 18, 2010
app.selection[0].paragraphs[0].words[2].select();

(where your cursor is anywhere inside that paragraph.) Apparently, "<para>select" is considered the first word (#0) ...

Something that hasn't been mentioned so far: for most purposes, it is not really necessary to select something with a script -- only if you want the user to see what got selected.

For instance, to underline the word 'partially', one would simply use

app.selection[0].paragraphs[0].words[2].underline = true;

-- which works fundamentally different. If you select the first word and run the script, the fourth one gets underlined but the selection stays on the first word.

[Ed.] (For the fourth time! What's wrong with this Jive editor!?)

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
LEGENDE ,
Feb 24, 2010 Feb 24, 2010
AKTUELL

[Ed.] (For the fourth time! What's wrong with this Jive editor!?)

It's crap

robin

www.adobescripts.com

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines