Jump to content
Server Maintenance This Week. ×

Need a tweak for a Trim/TrimAll cf


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

Recommended Posts

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!

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This topic is 3813 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.