Brian Dunning's FileMaker Custom Functions

BoldItalicEncode ( Text )

Encode any bold or italic text with tags

  Average rating: 4.4 (36 votes) Log in to vote

Tom Robinson   Tom Robinson - Show more from this author

Share on Facebook Share on Twitter

  Sample input:
BoldItalicEncode ( "hello. this is bold, this italic, and this both" )
  Sample output:
hello. this is [bold], this {italic}, and this [{both}]

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Wrap any bold text in the input text with square brackets, and italic text with curly.

This particular custom function was written for converting formatted text to something a web database could use. You could modify it to generate HTML tags from formatted text too.

It's also a particularly fiendish example of using the evaluate function.

 

Comments

Paolo   Paolo
Mar 2, 2015
Hello,

that is exactly what I was looking for.

Tried to convert to italian (my fm pro version). But I always get an error executing it ("missing field or "(" )

CercaeSost(
Valutazione(CercaeSost(RicavaComeCSS("CIAO");
["\"";"\\\""];
["[";"("];
["]";")"];
["{";"("];
["}";")"];

["<SPAN STYLE= ";"Dichiara([w=\""];
["</SPAN>";"\";

p=Posizione(w;\">\";1;1);
s=Sinistra(w;p-2);
t=Destra(w;Lunghezza(w)-p);
b=ContaRicorrenze(s;\"font-weight: bold\");
i=ContaRicorrenze(s;\"font-style:italic\")];
Casi(2*b+i;\"\";\"{\";\"[\";\"[{\")&t&Casi(2*b+i;\"\";\"}\";\"]\";\"}]\"))&"])&"\"\"");

["<BR>";"¶"];
["&amp;";"&"];
["&eacute;";"é"];
["&gt;";">"];
["&hellip;";"…"];
["&iuml;";"ï"];
["&lsquo;";"‘"];
["&ldquo;";"\“"];
["&lt;";"<"];
["&mdash;";"—"];
["&ndash;";"–"];
["&quot;";"\""];
["&rsquo;";"’"];
["&rdquo;";"\”"]
)


Any suggestion ?
Many thanks,
Paolo
 
The Author   The Author, New Zealand
Mar 2, 2015
From a quick glance you've got extraneous spaces, e.g. 't=D estra', '[& quot'.
 
Orlando   Orlando, Berkeley, CA
Jul 1, 2015
Hello Tom,
Thank you so much again for this great custom function! It has served us nicely throughout these years while using FileMaker 11!

For some reason I'm not able to running it under FMP 13. I get a question mark and this error message:
'A number, text constant, field name or "(" is expected here.

Any idea what could be going on?

Thanks a lot!

Orlando
 
Chris   Chris, Worcestershire UK
Aug 5, 2015
This stopped working for me in FileMaker Pro 14, and I just work out why: http://help.filemaker.com/app/answers/detail/a_id/14502/~/filemaker-pro-14-and-filemaker-pro-14-advanced-release-notes

The top note (1.a) explains that the newer version no longer gives the tags as capitals, but as lower case. So, we need to change the tags to lower case as well. Specifically:
["<SPAN STYLE=";"Let([w=\""];
["</SPAN>";"\";
becomes:
["<span style=";"Let([w=\""];
["</span>";"\";
and
["<BR>";"¶"];
to:
["<br>";"¶"];
Making these changes got it working for me again.

Thanks so much to the author of this function, and to this great site for hosting it.
 
Bleep   Bleep
Oct 25, 2022
Hello, I was wondering if anyone is still using these custom functions? I'm running it on FM19 and I'm not able to run it either in custom function, Data Viewer or in calculation. I get a question mark in data viewer, and 'A number, text constant, field name or "(" is expected here." in calculation.
 
Edoardo Volpi Kellermann   Edoardo Volpi Kellermann, Evk
Aug 31, 2024
Hello, I copied and pasted the function, without changing a comma, into a new custom function "BoldItalicEncode" on Filemaker Pro.
Unfortunately, if I try to apply it on a text field (I created a calculated text field 'BoldItalicEncode ( text )') it gives me '?' as a result.
Any suggestions?
I use FIlemaker Pro 19.6.3.302 on Mac Os Sonoma 14.6.1
 
Edoardo Volpi Kellermann   Edoardo Volpi Kellermann, Evk
Aug 31, 2024
I duplicated the function and fixed it as Chris suggested, changing all uppercase TAGS to lowercase, but it doesn't work:

===
CercaeSost(

Valutazione(CercaeSost(RicavaComeCSS(Text);
["\"";"\\\""];
["[";"("];
["]";")"];
["{";"("];
["}";")"];

[" ["";"\";

p=Position(w;\">\";1;1);
s=Left(w;p-2);
t=Right(w;Length(w)-p);
b=PatternCount(s;\"font-weight: bold\");
i=PatternCount(s;\"font-style:italic\")];
Choose(2*b+i;\"\";\"{\";\"[\";\"[{\")&t&Choose(2*b+i;\"\";\"}\";\"]\";\"}]\"))&"])&"\"\"");

["
";"¶"];
["&";"&"];
["é";"é"];
[">";">"];
["…";"…"];
["ï";"ï"];
["‘";"‘"];
["“";"\“"];
["<";"<"];
["—";"—"];
["–";"–"];
[""";"\""];
["’";"’"];
["”";"\”"]
)
===
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: