Rich S Posted November 26, 2013 Posted November 26, 2013 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!
Fitch Posted November 26, 2013 Posted November 26, 2013 You could always wrap the whole thing in a Substitute function (subbing CR+space with just CR).
comment Posted November 26, 2013 Posted November 26, 2013 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. 1
Rich S Posted November 27, 2013 Author Posted November 27, 2013 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!
comment Posted November 27, 2013 Posted November 27, 2013 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.
Recommended Posts
This topic is 4082 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 accountSign in
Already have an account? Sign in here.
Sign In Now