FMPRO-L Archives

August 2016, Week 2

FMPRO-L@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Brian Beer <[log in to unmask]>
Reply To:
FileMaker Pro Discussions <[log in to unmask]>
Date:
Wed, 10 Aug 2016 10:25:20 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (80 lines)
Hello,

I have a custom function that I have been using for years in v11.  It is a modification of a function from the Dunning site.  When I try to use it in v15 I get “A number, text constant, field name or “(“ is expected here”

The point at which it fails is right after 
> Evaluate(Substitute( GetAsCSS(Text);
> [“

Removing the first substitution just moves the error to the next one.  I’m stumped.  Any ideas?  TIA, Brian

Function:

/*
Overview:
---------

Wrap any bold text in the input text with <b> tags, and italic text with <em> tages:  ‘plain <b>bold</b> <em>italic</em> <b><em>both</b></em>’


Author:
-------

2012-07-18 Brian Beer

Based entirely on (copied from) BoldItalicEncode ( Text ) <http://www.briandunning.com/cf/709>
By:
2006-11-25 Tom Robinson <http://www.tomrobinson.co.nz/>
2007-09-20 Fix when running under v9 (thanks to Orlando Antonio Sánchez for bringing to my attention and initial investigation)
*/

Substitute(

/*
1. Convert the text to CSS
2. Prepare for execute by encoding quotes 
3. Each line generated has a trailing ampersand (ready for the next line), so at the end we add a null string
*/

/* The code we’re generating uses:
w=whole text
p=position of ‘>’
s=style portion of text
t=text portion of text
b=bold flag
i=italic flag
*/

Evaluate(Substitute( GetAsCSS(Text);
["\"";"\\\""];
["<span style= ";"Let([w=\""];
["</span>";"\";

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;\"\";\"<em>\";\"<b>\";\"<b><em>\")&t&Choose(2*b+i;\"\";\"</em>\";\"</b>\";\"</em></b>\"))&"])&"\"\"");

/* Now change <BR> to </p><p> */

["<br>";"</p><p>"];

/* Now fix improperly nested p tags */
["</p><p></em></b>";"</em></b></p><p>"];
["</p><p></em>";"</em></p><p>"];
["</p><p></b>";"</b></p><p>"]

)

Brian H. Beer
Assistant Director, Marketing and Data Services
Penn State University Press
820 North University Drive
USB 1, Suite C
University Park, PA 16802
814-867-2210
FAX: 814-863-1408
http://www.psupress.org

ATOM RSS1 RSS2