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

Selected textFrame contains a dash?

Engaged ,
Mar 02, 2016 Mar 02, 2016

Is there a way that I can search through the selected text items and if the text frame contains a dash push the entire contents of the text frame into an array?

If it doesn't contain a dash it would just skip it.

so for example:

The following text would be selected....

SNJ1-UP   RYT245-587    WRX1-107   J:37

There would be 4 items in the selection...

and it would push the content to an array dashFrames[]; which would have 3 text frame items in it...

dashFrames[0]  =  SNJ1-UP

dashFrames[1]  =  RYT245-587

dashFrames[2]  =  WRX1-107

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

Community Expert , Mar 02, 2016 Mar 02, 2016

Do you mean something like this?

// 4 textFrames should be selected

var tF = app.activeDocument.selection;

if (tF.length == 4) {

    var count = 0;

    var dashFrames = new Array ();

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

    if (tF.typename == "TextFrame") {

        if (tF.contents.match ("-")) {

            dashFrames[count] = tF.contents;

            count++;

            }

        }

    }

}

// alert (dashFrames)

// result: RYT245-587,WRX1-107,SNJ1-UP

Have fun

Translate
Adobe
Community Expert ,
Mar 02, 2016 Mar 02, 2016

Do you mean something like this?

// 4 textFrames should be selected

var tF = app.activeDocument.selection;

if (tF.length == 4) {

    var count = 0;

    var dashFrames = new Array ();

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

    if (tF.typename == "TextFrame") {

        if (tF.contents.match ("-")) {

            dashFrames[count] = tF.contents;

            count++;

            }

        }

    }

}

// alert (dashFrames)

// result: RYT245-587,WRX1-107,SNJ1-UP

Have fun

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 ,
Mar 03, 2016 Mar 03, 2016
LATEST

Yup works perfect! Only thing I modified was the specific length of 4. My specs changed and I need that to be more dynamic now. THANKS pixxxel schubser‌!

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