Skip to main content
Inspiring
June 20, 2014
Answered

How can tell the script full color to underline text

  • June 20, 2014
  • 3 replies
  • 734 views

I write a script for del  square brackets and then make some markups, then i want the underline has a specify color

before del square brackets like this:

ASSETS

Non-current assets

Investments in subsidiaries                    45 [448,520]              [448,520]

Current assets

Amounts due from subsidiaries              17 [29,577,718]   [24,414,028]

Other receivables and prepayments      17 [7,095]                     [3,072]

Restricted cash                                       18 [2,786,304]      [1,033,136]

Cash and cash equivalents                    19 [173,502]            [505,184]

                                                                    [32,544,619]   [25,955,420]

Total assets                                               [32,993,139]     [26,403,940]

I want get the result like this:

ASSETS

Non-current assets

Investments in subsidiaries                  45          448,520         448,520

Current assets

Amounts due from subsidiaries            17     29,577,718     24,414,028

Other receivables and prepayments     17             7,095              3,072

Restricted cash                                     18     2,786,304        1,033,136

Cash and cash equivalents                   19        173,502           505,184

                                                                      32,544,619     25,955,420

Total assets                                                  32,993,139      26,403,940

but not work, two lines have error, can someone help me to fix it?

app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "\\[(.)";
app.changeGrepPreferences.changeTo = "$1";
app.changeGrepPreferences.underline = true;
app.changeGrepPreferences.underlineColor = swatches.item "underline"; // <----- the script has an error in this line
app.selection[0].changeGrep();
app.findGrepPreferences = app.changeGrepPreferences = null;

app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "(.)\\]";
app.changeGrepPreferences.changeTo = "$1";
app.changeGrepPreferences.underline = true;
app.changeGrepPreferences.underlineColor = swatches.item "underline"; // <----- the script has an error in this line
app.selection[0].changeGrep();
app.findGrepPreferences = app.changeGrepPreferences = null;

This topic has been closed for replies.
Correct answer Kai Rübsamen

Harvey, Ronalds line is correct. Did you realize, that you must select something?

A question in this case:

If I try this in the UI I would simply write: \[(.)|(.)]


But if I try this via script, the last part in the alternation is not honored. This is true only, when the underline color is applied in the same search.

So this one will find the first square bracket, apply the colors, but will not find the last square bracket.

app.findGrepPreferences = app.changeGrepPreferences = null;

app.findGrepPreferences.findWhat = "\\[(.)|(.)]";

app.changeGrepPreferences.underline = true;

app.changeGrepPreferences.underlineColor = "underline";

app.changeGrepPreferences.changeTo = "$1";

app.selection[0].changeGrep();

app.findGrepPreferences = app.changeGrepPreferences = null;

This one will find and delete the brackets correctly:

app.findGrepPreferences = app.changeGrepPreferences = null;

app.findGrepPreferences.findWhat = "\\[(.)|(.)]";

//~ app.changeGrepPreferences.underline = true;

//~ app.changeGrepPreferences.underlineColor = "underline";

app.changeGrepPreferences.changeTo = "$1";

app.selection[0].changeGrep();

app.findGrepPreferences = app.changeGrepPreferences = null;

Any ideas what is going on here?

Thanks

–Kai

3 replies

HarveyLiuAuthor
Inspiring
June 20, 2014

thanks, it is a suddently dawn on me!

HarveyLiuAuthor
Inspiring
June 20, 2014

not work

Kai Rübsamen
Kai RübsamenCorrect answer
Participating Frequently
June 20, 2014

Harvey, Ronalds line is correct. Did you realize, that you must select something?

A question in this case:

If I try this in the UI I would simply write: \[(.)|(.)]


But if I try this via script, the last part in the alternation is not honored. This is true only, when the underline color is applied in the same search.

So this one will find the first square bracket, apply the colors, but will not find the last square bracket.

app.findGrepPreferences = app.changeGrepPreferences = null;

app.findGrepPreferences.findWhat = "\\[(.)|(.)]";

app.changeGrepPreferences.underline = true;

app.changeGrepPreferences.underlineColor = "underline";

app.changeGrepPreferences.changeTo = "$1";

app.selection[0].changeGrep();

app.findGrepPreferences = app.changeGrepPreferences = null;

This one will find and delete the brackets correctly:

app.findGrepPreferences = app.changeGrepPreferences = null;

app.findGrepPreferences.findWhat = "\\[(.)|(.)]";

//~ app.changeGrepPreferences.underline = true;

//~ app.changeGrepPreferences.underlineColor = "underline";

app.changeGrepPreferences.changeTo = "$1";

app.selection[0].changeGrep();

app.findGrepPreferences = app.changeGrepPreferences = null;

Any ideas what is going on here?

Thanks

–Kai

Legend
June 20, 2014

Hi Harvey,

Try this ..

app.changeGrepPreferences.underlineColor = "underline";

Regards

Ronald