Jump to content

How can a text field in a tab control be searched?


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

Recommended Posts

Hello,

I have a layout with about a dozen tab controls, each dealing with a different FileMaker subject matter. In each tab, there is a text field intended to store notes about FM. I’d like to be able to do a search for specific words in each of these text fields and, if the word is found, I’d like it to be highlighted. Is this feasible? Or should I take a different approach for storing these notes and being able to search them?

Thanks.

Link to comment
Share on other sites

A tab control is a tool for dividing the layout real estate into different areas of interest. For example, in a layout of a People table you can use different panels for personal information (e.g. name and address), education details, work history and so on. All these areas contain information about the same person. There would be little or no reason to select the "Education" panel  after you have searched for "Harvard". 

I am not sure exactly what kind of data your solution stores, but it sounds like you should be using separate records instead of tab panels.

 

 

Edited by comment
Link to comment
Share on other sites

8 hours ago, The Learner said:

Hello,

I have a layout with about a dozen tab controls, each dealing with a different FileMaker subject matter. In each tab, there is a text field intended to store notes about FM. I’d like to be able to do a search for specific words in each of these text fields and, if the word is found, I’d like it to be highlighted. Is this feasible? Or should I take a different approach for storing these notes and being able to search them?

Thanks.

I have seen something similar a long time ago implemented in FM. It's not functionality FM supports out of the box though. From memory, you would have to read the note field into memory, search it, then replace the words you're interested in with the same word but now wrapped in a highlighted background (TextStyleAdd ( text ; HighlightYellow ) ) and write the full text back into the note.

The thing to remember with this is that you'll have to undo this every time. Alternatively, you could use a separate table for this with throwaway records/fields that get used once only, and which are overlaid over the normal note field. If there are multiple notes to search through, and you also want other (normal) text fields to be searched, it gets messy very quickly.

In that case you'd probably want to use a temporary record (using global fields)  that has all the fields the normal record has and duplicate everything before showing the data on the layout. You can then use a save button to save any altered data. But you'd first have to clean the data of any highlighted text.

 

Link to comment
Share on other sites

Than you both for your comments.

In fact, my original question may have been a bit misleading. As Comment wrote, the issue is not about the text field being in a tab control or not; it's about whether or not a text field can be searched and found words highlighted.

The approach described by OlgerDiekstra is way too complicated for me as I am far from an expert on FM. As for the link provided by Comment, it refers to a function called HiliteMulti. It looks like this function is no longer present in FM, at least I can't find it in my FM16 version. Was the function ever present in FM and removed, or is it still present under a different name, or maybe it's only in FM 17 or 18?

Whatever the case, I was hoping that a simple text field in FM could be searched and the found word highlighted, the same way a text in Word format can be searched. If it cannot be done, storing notes about my solution in the solution itself is not very appealing.

I'll be quite happy to look into other suggestions if any.

Thanks again.

Link to comment
Share on other sites

You need the Advanced version of Filemaker in order to add a custom function to your solution (once added, it can be used by any version). In the absence of a custom function, you can use a looping script to populate a global field. Or, if you are willing to severely limit the number of phrases that need to be highlighted, you may be able to use a "regular" calculation to perform the task (a custom function can be recursive, so it can handle up to 50,000 phrases).

Note that regardless of the method you choose, you will need to use 2 fields: one for the original note, and one for showing the text of the original note with the highlights applied to it. You can layer the fields so that users will see the highlighted text, but enter the original note field when they choose to edit the contents. The suggestion to replace the original text with the highlighted version is unacceptable, because (1) it would not allow each user to highlight their own phrases, and (2) it would trigger unnecessary modifications of the record thus causing any LastModified fields you may have to become useless.

 

Edited by comment
Link to comment
Share on other sites

Thanks a lot for your explanations. I'll try to use the looping script approach for now, until I upgrade to the latest FM version. Being retired, I can afford devoting a few months to writing a script, even if chances are I'll never get it right.😃😃 At my age, I've learned to be patient.

Link to comment
Share on other sites

You can use the two custom functions - HiliteMulti and its prerequisite HiliteSingle - as the roadmap for your script. It shouldn't take more than an hour or two to get it right. Post again if you get stuck.

 

Edited by comment
Link to comment
Share on other sites

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