rob Posted December 15, 2016 Posted December 15, 2016 So person performs a find for part of the text they wish to find. The resulting display should bold just the part that they searched for in that field. I have tried to search for examples but don't even know what to search for. Hints would be appreciated. I think I need pattern count but that just gives me a number.
LaRetta Posted December 16, 2016 Posted December 16, 2016 You can use a custom function. Here is one which will work: /* boldSelectedText ( text ; search ) purpose: bolds the search characters within a text string */ Let ( [ bolded = TextStyleAdd ( search ; Bold ) ; len = Length ( search ) ; pos = Position ( text ; search ; 1 ; 1 ) ] ; If ( Length ( text ) ; If ( pos ; Left ( text ; pos -1 ) & bolded & boldSelectedText ( Right ( text ; Length ( text ) - pos - len +1 ) ; search ) ; text ) ) ) I've attached a file which shows how it works. I am sure there are better custom functions. You would need to capture the search criteria. You can have the User enter the search string into a global field or enter find mode and then capture that value for your calculation. You could also use a script. Instead of creating a calculation in your data table, I would use a PLACEHOLDER field. I've provided a few examples. PLACEHOLDER fields are great to eliminate calculations used only for display. Keep in mind that PLACEHOLDERS 1) must remain empty and 2) will not display in preview or print. BoldSearched.fmp12 1
comment Posted December 16, 2016 Posted December 16, 2016 There are some nuances worth mentioning here. For example, the default Filemaker find looks for words that begin with the search phrase. Highlighting the search phrase as pattern is more inclusive. Say you searched for "little" and the found record contains "Doctor Doolittle belittled his little friend". Highlighting the pattern "little" will result in "Doctor Doolittle belittled his little friend" - but the first two highlighted occurrences played no part in the search. 2
rob Posted December 19, 2016 Author Posted December 19, 2016 Yep, Laretta, that is what I needed. Comment thank you also. Laretta showed that problem in demo file but I use find looking for text anywhere by surrounding with *.
LaRetta Posted December 19, 2016 Posted December 19, 2016 Hi Rob, I suggest that you also check out this custom function which preserves the case (whether capitalized or not) of the search phrase. In all, it is a better custom function. Sorry I didn't find this CF before I wrote mine above. HiliteSingle ( text ; searchString ; color ) Note that you should use the CF Comment has listed further down in the link instead of the original one. And you'll need to change from highlight to bold but I'm sure you can handle that! :-)
Lee Smith Posted December 19, 2016 Posted December 19, 2016 I like this one by Ray Cologon here http://www.nightwingenterprises.com/demos2014/demo1309.html 1
Recommended Posts
This topic is 2964 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