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

find and between change

Participant ,
Sep 07, 2015 Sep 07, 2015

I want to change in my text frames written in paragraph style "EBT" text

Between 1 to 3 of "ABC" text

Between 4 and 7 "BIM" text

Between 7 and 10 "KLM" text

should write

where and how an error

var myDoc = app.activeDocument;

var myFrame = myDoc.allPageItems;

for(var i=0;i<myFrame.length;i++){

//if(myFrame.appliedObjectStyle == tmc) {

//if(i==5){break;}

app.findGrepPreferences = app.changeGrepPreferences = null;

app.findGrepPreferences.appliedParagraphStyle = "myParS";

app.findGrepPreferences.findWhat = "EBT";

if ((i > 0) && (i <= 3)) {var changeX = app.changeGrepPreferences.changeTo  = "ABC";}

if ((i > 3) && (i <= 7)) {var changeX = app.changeGrepPreferences.changeTo  = "BIM";}

if ((i > 7) && (i <= 10)) {var changeX = app.changeGrepPreferences.changeTo  = "KLM";}

myFrame.texts[0].changeGrep();

app.findGrepPreferences = app.changeGrepPreferences = null;

TOPICS
Scripting
823
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

correct answers 1 Correct answer

Enthusiast , Sep 09, 2015 Sep 09, 2015

Dirty solution ... 😉

var myDoc = app.activeDocument;

var myFrame = myDoc.allPageItems;

for(var i=0;i<myFrame.length;i++){

    app.findGrepPreferences = app.changeGrepPreferences = null;

    app.findGrepPreferences.appliedParagraphStyle = "myParS";

    app.findGrepPreferences.findWhat = "EBT";

    var j = parseInt(myFrame.texts[0].contents, 10);  //****************** + ****************

    if ((j > 0) && (j <= 3)) {app.changeGrepPreferences.changeTo  = "ABC"; myFrame.changeGrep(); }

    if ((j

...
Translate
Enthusiast ,
Sep 08, 2015 Sep 08, 2015

Hi,


1- it lacks a hook closure at the end "}"


2- you do not process myFrame[0] in your code, if this frame content "EBT", it will be erased

if ((i > 0) && (i <= 3)) {var changeX = app.changeGrepPreferences.changeTo  = "ABC";}


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
Participant ,
Sep 08, 2015 Sep 08, 2015

there I noticed the error

all the "ABC" doing text

if the end of the "break continue" Did I need to add

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
Enthusiast ,
Sep 08, 2015 Sep 08, 2015

Sorry but i don't understand your problem ...

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
Participant ,
Sep 09, 2015 Sep 09, 2015

the problem is to place the order

but I was able to solve a number of rotating post (parseInt)

var myDoc = app.activeDocument;

var myFrame = myDoc.allPageItems;

for(var i=0;i<myFrame.length;i++){

app.findGrepPreferences = app.changeGrepPreferences = null; 

app.findGrepPreferences.appliedParagraphStyle = "myParS";

app.findGrepPreferences.findWhat = "EBT";

var j = parseInt(myFrame.texts[0].contents, 10);  //****************** + ****************

if ((j > 0) && (j <= 3)) {app.changeGrepPreferences.changeTo  = "ABC";}

if ((j > 3) && (j <= 7)) {app.changeGrepPreferences.changeTo  = "BIM";}

if ((j > 7) && (j <= 10)) {app.changeGrepPreferences.changeTo  = "KLM";}

myFrame.changeGrep(); 

app.findGrepPreferences = app.changeGrepPreferences = null;

}

but to stop after 10 "break" command in the summer when the results fiasco

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
Enthusiast ,
Sep 09, 2015 Sep 09, 2015

Have you a screen of your doc ?

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
Participant ,
Sep 09, 2015 Sep 09, 2015

11, and 12 don't change

                      before                                                                            after

ADF1.jpg

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
Enthusiast ,
Sep 09, 2015 Sep 09, 2015
LATEST

Dirty solution ... 😉

var myDoc = app.activeDocument;

var myFrame = myDoc.allPageItems;

for(var i=0;i<myFrame.length;i++){

    app.findGrepPreferences = app.changeGrepPreferences = null;

    app.findGrepPreferences.appliedParagraphStyle = "myParS";

    app.findGrepPreferences.findWhat = "EBT";

    var j = parseInt(myFrame.texts[0].contents, 10);  //****************** + ****************

    if ((j > 0) && (j <= 3)) {app.changeGrepPreferences.changeTo  = "ABC"; myFrame.changeGrep(); }

    if ((j > 3) && (j <= 7)) {app.changeGrepPreferences.changeTo  = "BIM"; myFrame.changeGrep(); }

    if ((j > 7) && (j <= 10)) {app.changeGrepPreferences.changeTo  = "KLM"; myFrame.changeGrep(); }

    app.findGrepPreferences = app.changeGrepPreferences = null;

}

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