Jump to content
Sign in to follow this  
Quito

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

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

That worked perfectly. Thank you!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Similar Content

    • By rick altman
      I have a field that receives a bunch of first names from a portal, thanks to the List function. The result might look like this:
       
      Alice, Bill, Chuck
       
      However, I need for the list to read:
       
      Alice, Bill, and Chuck
       
       
      I need to find the last comma in the text and add an "and" to it. I have been messing around with the Position function stuffed inside of a Substitute function, but I can't get it right. Can someone help?
       
      FMPA14
       
       
      Rick A.
      Pleasanton CA
    • By tom robinson
      I have a script that loops thru [ go to next ] tab designated fields on a layout and generates a substitution list as such ;
      "[\""&Get ( ActiveLayoutObjectName ) & "\"; " & Get ( ActiveFieldTableName ) & "::" & Get ( ActiveFieldName )&"];"
      appending  "Substitute(report flow data::report" and  ")" at end  
      (report flow data:: report) being a template loaded with "key words"
       
      example;
       
      Substitute(report flow data::report
      ["rdate"; report flow data::flowtest_date];
      ["rgpd"; report flow data::gallons per day;
      ["syaddress"; selected system::c_NameAndAddress];
      ["wdesc"; selected_water::c_waterDescBasic]
      )
      the key words to be substituted are the individual fields given name and for easy remembering that fields tooltip as well , is it possible to script edit the fields name thus  editing the "key word" 
       
      This custom function "substitute data" substitutes with the scripted text chunk pasted into the function.
      how to utilize variable $$sublist  in place of text chunk
      apparently one can only substitute text ? it appears that a calculated number doesn't work.

    • By Erika
      Hi!
      English is not my native language and I'm using FileMaker in a other language so some spelling/translation errors might occur.
        I have searched and tried to find a solution for this but couldn't find any.   I have a text field, let's call it "Table::Colors", where users either write values manually or paste values. Most of the time the user paste in values. I want to make a script/calculation that changes the pasted value so it becomes correct.   ---   The user usually paste something like this: "1Green   2Dark blue   10Red3   15Yell0w   Purple4"   ---   I have a script that runs when the user enters/exits the field that looks like this: "Insert text [Table::Colors; Substitute(Table::Colors;["¶";", "];["1";""];["2";""];["3";""];["4";""];["5";""];["6";""];["7";""];["8";""];["9";""];["0";""])"   I also have an auto-enter calculation on the field itself and have set it to replace existing value. It looks like this:
      "TextFormatRemove(If(Right(Table::Colors;2) = ", " ; Left (Table::Colors ; Length(Table::Colors) - 2 ) ; Table::Colors ))"   When the user exits the field the value now looks like this: "Green, Dark blue, Red, Yellw, Purple"   ---   However I want it to look like this: "Green, Dark blue, Red3, Yell0w, Purple4"   Basically I want to remove numbers in the beginning of each line but not the numbers that are in the middle or last.   Is there a good way to do this?
    • By FMN
      Hello,
       
      In the address section of my database, when you select either Canada or USA it provides a list of relevant ‘Provinces’ or ‘States’ in the Province/State field. Currently the provinces/states are written in full but I would like that once a selection is made, the field automatically inputs the abbreviation - ex. someone selects ‘Saskatchewan’ and it auto-enters/replaces it to ‘(SK)’ on commitment.
       
      I managed somewhat to achieve this using the substitute function but only for one entry, I was not able to enter multiple substitutions – ex. Substitute (Province ; “Saskatchewan” ; “(SK)”). Is there a way to enter multiple substitutions as a conditional value? Is this the best way to go about it?
       
      FYI, my address section is linked to conditional value lists with the following fields:
       
      Country (list of countries)
      Prov/State (list of provinces and states)
      Prov/StateAbb (list of provinces and state in abbreviated form)
       
      Thank you in advance for your help!
    • By life036
      Hi All, I have this fairly simple field, it's a calculation that returns a list, and it works well:
      If ( IsEmpty ( IP Addresses::IPv4 Address ); "No Static IP"; List ( IP Addresses::IPv4 Address ) ) However, in the resulting list that displays, I'd like to substitute the carriage returns with commas, and I've come up with this bit of code to make the substitution:
      Substitute ( IP Address Display; "¶" ; ", " ) Is this correct? If so, where do I place the substitute statement? Will it go into the same calculation I use to define the field, or do I have to put this into a brand new field of its own?
       
      Thanks in advance,
      C
×
×
  • Create New...

Important Information

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