Jump to content
Sign in to follow this  
bcervin

Font: paste into FM ignore incoming font, replace with FM default

Recommended Posts

I tried to sum the problem up in the title, but to make it clearer.

We have helvetica as our default font, and regularly copy/paste text from other programs into FM. From the web/word/pdf etc. We would like the pasted text to adopt the default font but currently we are pasting the text with the font from the original text/document. Is there a setting or method for consistantly / easily adopting the default font upon pasting?

Many thanks,

Brendan.

Share this post


Link to post
Share on other sites

Command Option V, key combination

uses the field formatting.

Cmd v uses the clipboard style, and ignors the fields formats and styles

Script step is Past w/o format

To read more on this, do a search of your Online FileMaker Help for Paste

HTH

Lee

Share this post


Link to post
Share on other sites

Set up an auto-enter calculation on the text field with the calculation

TextFormatRemove( fieldname )

and set the calculation to replace existing contents.

Share this post


Link to post
Share on other sites

Thanks guys,

Those tips helped. I got it. Unfortunately we already have a large database and many layouts, some have customised font/size as required. But most don't need it, it will be a big job running through all the layouts and scripting the fields.

In the mean time the paste cmd-opt-v is handy.

Many thanks, Brendan.

Share this post


Link to post
Share on other sites

TextFormatRemove( self ) will work in FileMaker 9+ (though had problems with Data Separation files, fixed in 10)

This will not remove the Layout object formatting of fields. It will however remove the Browse mode "custom formatting" of text characters, i.e., someone selected some text manually in Browse mode and changed its formatting. These are two different things.

Share this post


Link to post
Share on other sites

Fenton, that help'd a lot. The only thing is the pain to re-edit all the fields appearing in the UI. Thanks!

Let me ask you (and anybody else), do you use this solution for your projects or let the users edit the fields format? (or paste with format).

Share this post


Link to post
Share on other sites

Yes, it is kind of a pain to redo existing fields, after you've implemented the TextFormatRemove(field). You can use ReplaceFieldContents, replacing the field with itself (via Calculation) after you've put your cursor in each field. This is tedious if several fields need it. But even worse, it is a very dangerous thing to do. If you are not careful, if you hit Replace when the default "current contents" is selected, you'll ruin that field, and there is no Undo. This makes me very nervous, especially if I'm forced to do it on live data.

A safer and easier method is to write the auto-enter calculation so that it can be triggered by another field, one that does not matter. This will work even when the field is a global. The following auto-enter calculation can be used on any field, just copy/paste. You would need a global field (number) in the table, for the z_gTrigger. Adjust the name to suit.

Let ( t = z_gTrigger; TextFormatRemove ( Self ) )

Then all you need to do is a Replace on the global "trigger" field. Since it is in all the calculations, all the fields with the auto-enter will be cleaned at once. After doing so, the global field does not need to be on the layout, nor have a value, as the regular auto-enter handles it after that.

*Requires FileMaker 9 for the Self function; if you have 8, you'll have to specify the field. If you have 7, you can use the Evaluate (Quote (field)) method (which is undocumented, but works.

Evaluate ( Quote (Test3); z_gTrigger ))

P.S. I've set up this file. You can try the button next to the global field once. But after that, you'd have to turn off the auto-enter for a field, as it will be cleaned automatically.

FormatRemove.fp7.zip

Share this post


Link to post
Share on other sites

In regard to when I use this, I'd say I use it when necessary, and only when necessary. One reason to limit its use to only fields which need it is that it can slow down an Import, if the [x] Allow auto-enter option is on. But often that is not on, so it would make no difference.

I suppose you would not implement if the user wanted to use formatted text. But sometimes I've been told by the business owner, "I don't want all this junk in the fields, whether the users want it or not." :(-]

Share this post


Link to post
Share on other sites

Wow Fenton, it's a nice function! But it's a little out of my understanding. Just to clarify, the trigger function is a way to "call" the function when needed and not load FM with a script after each field commited. Right? Or is it a way to clean all the existing database with different formats and keep the script preventing new changes?

I'll have to learn a lot before being able to understand those formulas ... I'll learn post by post. Thanks!

Share this post


Link to post
Share on other sites

The "trigger" global field, in the Let, is so you can clean multiple already populated (with junk) fields in an existing database via a single Replace into the global trigger field. That is what my example files shows (tho there ain't very many to see).

TextFormatRemove ( Self )

is all you really need to make cleaning work on new/edited entries. But it seemed you needed to clean existing data in several fields, hence the more complex (but not so much) method.

Always back up your file before trying this on real files.

Share this post


Link to post
Share on other sites

I have taken a slightly different approach on a system I made. I replaced the paste command using custom menus in filemaker advanced with a script that pastes without format. Then you just apply that menu set to any layout that you want that function on.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

  • Who Viewed the Topic

    1 member has viewed this topic:
    jarvphot 
×

Important Information

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