Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 2116 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi,

Using TextStyleAdd, I want to change the style of a single letter at the beginning of a sentence.  For example:

// SOAP

[ "S:" ; TextStyleAdd ( "S:" ; Bold ) ] ;

[ "O:" ; TextStyleAdd ( "O:" ; Bold ) ] ;

[ "A:" ; TextStyleAdd ( "A:" ; Bold ) ] ;

[ "P:" ; TextStyleAdd ( "P:" ; Bold ) ] ;

But I get this:

P:             -      P:           (correct)

SOAP:     -      SOAP:    (incorrect)

SOFA:     -      SOFA:    (incorrect)

Is there a way of adding search constraints to TextStyleAdd?  Or, is there a hidden character at the beginning of each line I can capture?

All the very best,

Daniel

Posted
3 hours ago, Quito said:

a single letter at the beginning of a sentence

It depends on how you define a "sentence".

If it's just the first letter of the entire field, then it's simple: isolate it using the Left() function and apply the style; then output the rest, using the Right() function. No substitution is required for this.

If it's something else, then it gets interesting.

Posted
20 hours ago, comment said:

It depends on how you define a "sentence".

If it's just the first letter of the entire field, then it's simple: isolate it using the Left() function and apply the style; then output the rest, using the Right() function. No substitution is required for this.

If it's something else, then it gets interesting.

Thank you Gopala and Comment,

Basically, I would like to style certain words or phrases in a text field.  I want to style whole words only. Selecting the phrase by adding delimiters (space, comma, dot, semicolon, apostrophe, etc) is simple and works fine. 

The problem is isolating single letter words followed by a colon, such as:

S:

O:

A:

P:

Because TextStyleAdd doesn't search for whole words, I end up with words ending in S:  O:  A:  P: also being styled (See attached file).

So, the script should do something like:

If there is a whole word, formed by a single letter (any of these four letters S, O, A or P), at the beginning of the field, followed by a colon, make it Bold

Hope this helps.

All the very best,

Daniel

 

Screen Shot 2019-02-05 at 09.38.36.png

Posted
2 hours ago, Quito said:

If there is a whole word, formed by a single letter (any of these four letters S, O, A or P), at the beginning of the field, followed by a colon, make it Bold

Then how about =

Substitute ( "§" & Yourfield ;
[ "§S:" ; TextStyleAdd ( "S:" ; Bold ) ] ;
[ "§O:" ; TextStyleAdd ( "O:" ; Bold ) ] ;
[ "§A:" ; TextStyleAdd ( "A:" ; Bold ) ] ;
[ "§P:" ; TextStyleAdd ( "P:" ; Bold ) ] ;
[ "§" ; "" ]
)

You can use any character that you know is not going to be used in the field. I usually use Char ( 6320 ) which is an unassigned Unicode code point, but "§" is easier to use and to read.

  • Thanks 1

This topic is 2116 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.