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

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

Guest
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">12526</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

TOPICS
Scripting
1.2K
Translate
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 ,
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

Translate
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
Guest
Feb 16, 2010 Feb 16, 2010

Thank you very much!!!

Anil Yadav

Translate
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
New Here ,
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

Translate
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
Engaged ,
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

Translate
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
New Here ,
Feb 18, 2010 Feb 18, 2010

yes, Thanks Shonky

Translate
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
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!?)

Translate
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
LEGEND ,
Feb 24, 2010 Feb 24, 2010
LATEST

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

It's crap

robin

www.adobescripts.com

Translate
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