Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

TextStyleAdd: Substitute single letter keywords at the beginning of a sentence

Featured Replies

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

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.

  • Author
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

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.

  • Author

That worked perfectly. Thank you!

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.