Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

Here's my problem of the week:

I have a text field that the user typically pastes a block of text into, and I would like to reset the font/size of the text so that it shows up properly on different layouts. But Filemaker 7 now retains formatting information with the pasted text, so even though it should be displayed in Verdana 14 pt on one layout and Verdana 11 pt on a different layout, it now displays in the pasted font/size on both layouts.

In Filemaker 6, this could be cured in a script using Set Field (field, field), but this trick no longer works. I can use an auto-enter calculation to reset the font/size, but this doesn't "get rid" of the formatting, and the text appears as 14 pt on both layouts. I can use a tedious approach with copy and paste:

Copy [select; TextField]

Set Field [TextField; ""]

Paste [select; no style; TextField]

{Note that the Clear script command can leave behind some residual formatting, but set field does not}

There Has To Be A Better Way! Filemaker Help only suggests exporting and reimporting your data to remove text formatting, which is even more absurd than the copy/paste strategy. Any suggestions?

-Terence

Posted

Check out The Shadow's last attachment in this thread . It has a CopyStyles() custom function. You could use this to reset the style of any field to the style from another field using an Auto Entered calc.

Posted

Thanks for the link. That implementation of CopyStyles() doesn't actually solve my problem -- it will change the font/size/color/style, but doesn't actually remove the formatting so the text won't appear in the format defined by the layout.

However, it did point me to the solution: GetAsCSS, which returns unformatted text. For anyone who winds up dealing with my same problem, I've attached two custom functions. GetAsUnformattedText ( InputText ) will convert a piece of text to a CSS, remove the CSS information, and then use a second function (HTMLtoText) to convert any special characters (such as <,>,&, etc.) back to their original forms. It should work on Mac and Windows platforms, but I suspect the conversion matrix of special characters may require some editing on Windows to make sure all the characters are what they're supposed to be. Thanks to Ender and The Shadow for pointing me in the right direction.

-Terence

Edit: My first post of this function had a bug, in that the Position function isn't case sensitive, so the HTMLtoText function would convert upper and lower case special characters to whichever occurred first in the conversion matrix. The updated version has a workaround, and a few extensions to the conversion matrix that I inadvertently left off the original. It is posted on the Tips section.

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