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

Text Variable - other contents in the textframe

Contributor ,
Jan 26, 2018 Jan 26, 2018

Copy link to clipboard

Copied

Hi,

     I can check the below code whether a textframe contains text variable or not.

    I need to get the extra contents of that textframe which contains text variable.  How can i check this?

Code to find Text Variable:

var paraTxtVarBool = findSpecialCharacters(txtFram, "~Y"); 

function findSpecialCharacters(sel, findGrp)

{

    var found = 0;

   

    try{

        app.findGrepPreferences = app.changeGrepPreferences = null; 

        app.findChangeGrepOptions.includeMasterPages = true; 

        app.findGrepPreferences.findWhat = findGrp 

        res = sel.findGrep(); 

       

        if(res.length > 0)

        {

            found = 1;

        }    

        app.findGrepPreferences = app.changeGrepPreferences = null;     

    }catch(e){return found}

    return found;   

}

TOPICS
Scripting

Views

440

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
Community Expert ,
Jan 27, 2018 Jan 27, 2018

Copy link to clipboard

Copied

Hi Sudha,

look at parentTextFrames[0].texts[0] of the first or last insertion point of the found text.

From there you could extract the value of contents .

Regards,
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
Contributor ,
Jan 28, 2018 Jan 28, 2018

Copy link to clipboard

Copied

Hi,

     thank you.. I will check and get back...

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 ,
Feb 07, 2018 Feb 07, 2018

Copy link to clipboard

Copied

Hi,

     The above code returns the contents of the text frame of text variable found.  But how can i check whether that a text frame contains extra contents or not when it contains text variable?? Also the text frame may contains more than one text variable. In that case how to check??

     We can see visually but how to confirm that in scripting?

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
Community Expert ,
Feb 08, 2018 Feb 08, 2018

Copy link to clipboard

Copied

Hi Sudha,

look for textVariableInstances in a text frame or a story.

You could read out the associatedTextVariable from that and even the resultText.

storyOffset will give you the first insertion point in the story.

storyOffset.index the position of the insertion point relative to its parent, a story or a cell ( if found in a table ).

What do you mean with extra contents?
For all text formatted you could inspect textStyleRanges or even single characters with texts[0] of a story or a text frame and inspect the contents.

textFrame.texts[0].textVariableInstances.everyItem().getElements();

textFrame.texts[0].textStyleRanges.everyItem().getElements();

textFrame.texts[0].characters.everyItem().getElements();

Maybe some screenshots would help to illustrate your problem?

Regards,
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
Contributor ,
Feb 11, 2018 Feb 11, 2018

Copy link to clipboard

Copied

LATEST

Hi,

     Thank you for the replay...

     Refer the screenshot for text with text variable.   Others text except text variable.

     TextVariable.png

     I have followed the below steps.

     1. Get the count of paragraph style text variable.

     2. Get  the count of character style text variable.

     3. Get the count of contents length.

     4. If i get difference in count of both para and char text variable count and contents length, considering that textframe contents extra contents.

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