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.

Need a tweak for a Trim/TrimAll cf

Featured Replies

Greets all, and Happy Thanksgiving (in advance).

 

I'm trying to strip every bit of formatting, extra spaces, returns, tabs...you name it...from a field and convert it to plain, Verdana 12 pt. text but try as I might I can't get rid of leading space of a new sentence after a carriage return.

 

 like this line.

 

I incorporated Trim4 (Ray C's cf) into the following cf I threw together:

 

TrimAll (
TextStyleAdd (
TextFont (
TextSize (

Trim4 ( text )

; 12 ) ;
"Verdana" ) ;
"Plain" )
; 0 ; 0 )
 

 

 

/*

//Trim4 cf from Ray C on Brian Dunning's website

 

Let([
sT = Char(9) & Char(13) & Char(32) & Char(160);
C1 = PatternCount(sT; Left(text; 1));
Cn = PatternCount(sT; Right(text; 1));
Ca = C1 + Cn];
If(Ca;
Trim4(Middle(text; 1 + C1; Length(text) - Ca));
Text)
)

 

 

----------------------

 

What tweak needs to be made so I can nix the first, empty space?  TIA for your help!

You could always wrap the whole thing in a Substitute function (subbing CR+space with just CR).

Not related to your question, but why are you adding the Verdana 12pt attributes to the text? It would be much better, IMHO, to leave the text entirely plain and format it by selecting the font and size for the field displaying the text on the layout. This would allow you to use a different font/size for on-screen viewing and for printed reports, for example.

 

 

Note also that:

 TextStyleAdd ( text ; Plain )

is NOT AT ALL the same thing as:

 TextStyleRemove ( text ; AllStyles )

Use the GetAsCSS() function to observe the difference.

  • Author

Thanks, Fitch--good suggestion!

 

Comment: Good call; I should've thought of that. *sigh* Yet another reason I should leave coding to the professionals...

 

The field that in question is one where, 99% of the time, users will copy text from a website then paste it into this field. Since the field already has a CSS style coded to it--including it being set to Verdana 12 pt.--my intention is to strip every attribute from the pasted text so the field's text is plain and consistent. So, of course your recommendation makes perfect sense!

my intention is to strip every attribute from the pasted text so the field's text is plain and consistent.

 

Then you should move up to TextFormatRemove() which removes ALL formatting, not just styles.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

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.