Newbies eatapman Posted April 22, 2008 Newbies Posted April 22, 2008 Hello. The calculation below was working perfectly in version 8. In 9, it's broken and returns a "?". It's a calc I picked up from this forum (I think) that wonderfully formats text for a later InDesign import. Note: The "Body Copy" is the field name reference. The paste here can't negotiate the special characters. Thanks for any help!! Let([ k=Substitute(Body Copy;["¶¶¶";"¶"];["¶¶";"¶"];["¶¶";"¶"];["";""]); a=Substitute(GetAsCSS ( k ); ["";""];[""";"""];["“";"“"];["”";"”"]; ["<";""&Let([T="<"]; [">";">"; S=PatternCount(T;"SPAN"); X=PatternCount(T;""); B=MIN(1;PatternCount(T;"WEIGHT: BOLD")); I=MIN(1;PatternCount(T;"STYLE:ITALIC")); U=MIN(1;PatternCount(T;"DECORATION:UNDERLINE"))]; Case(X;T;S AND (B OR I OR U);"";S;"";T))&""]); b=Evaluate("""&a&"""); c="""&Substitute(b; ["";""];[""";"""];["“";"“"];["”";"”"]; ["";""&Let(; ["";""&Let(; ["";""&Let(; ["";""&Let(; ["";""&Let(; ["";""&Let(; ["";""&Let(; ["";""&Let(; [" ";""];T&:&""])&"""; rawRTF=Evaluate ( c ) ]; //This last part converts the CSS escaped characters into the equivalent rtf characters. RTF has far fewer escaped characters than CSS Substitute(rawRTF ;[" ";¶] ;["�";"~"];["�";"¡"];["�";"¢"];["�";"£"];["�";"¥"];["�";"§"];["�";"¨"];["�";"©"];["�";"ª"];["�";"«"] ;["�";"¬"];["�";"®"];["�";"¯"];["�";"°"];["�";"±"];["�";"´"];["�";"µ"];["�";"¶"];["�";"·"];["�";"¸"] ;["�";"º"];["�";"»"];["�";"¿"];["�";"À"];["�";"Á"];["�";"Â"];["�";"Ã"];["�";"Ä"];["�";"Å"];["�";"Æ"] ;["�";"Ç"];["�";"È"];["�";"É"];["�";"Ê"];["�";"Ë"];["�";"Ì"];["�";"Í"];["�";"Î"];["�";"Ï"];["�";"Ñ"] ;["�";"Ò"];["�";"Ó"];["�";"Ô"];["�";"Õ"];["�";"Ö"];["�";"Ø"];["�";"Ù"];["�";"Ú"];["�";"Û"];["�";"Ü"] ;["�";"ß"];["�";"à"];["�";"á"];["�";"â"];["�";"ã"];["�";"ä"];["�";"å"];["�";"æ"];["�";"ç"];["�";"è"] ;["�";"é"];["�";"ê"];["�";"ë"];["�";"ì"];["�";"í"];["�";"î"];["�";"ï"];["�";"ñ"];["�";"ò"];["�";"ó"] ;["�";"ô"];["�";"õ"];["�";"ö"];["�";"÷"];["�";"ø"];["�";"ù"];["�";"ú"];["�";"û"];["�";"ü"];["�";"ÿ"] ;["ı";"ı"];["Œ";"Œ"];["œ";"œ"];["Ÿ";"Ÿ"];["ƒ";"ƒ"];["ˆ";"ˆ"];["ˇ";"ˇ"];["˘";"˘"];["˙";"˙"];["˚";"˚"] ;["˛";"˛"];["˜";"˜"];["˝";"˝"];["Ω";"Ω"];["π";"π"];["–";"endash "];["—";"emdash "];["‘";"‘"];["’";"’"];["‚";"‚"] ;["“";"“"];["”";"”"];["„";"„"];["†";"†"];["‡";"‡"];["•";"•"];["…";"…"];["‰";"‰"];["‹";"‹"];["›";"›"] ;["⁄";"⁄"];["€";"€"];["™";"™"];["∂";"∂"];["∆";"∆"];["∏";"∏"];["∑";"∑"];["√";"√"];["∝";"∞"];["∫";"∫"] ;["≈";"≈"];["≠";"≠"];["≤";"≤"];["≥";"≥"];["◊";"◊"];["";""];["fi";"fi"];["fl";"fl"];["<";"<"];[">";">"];[""";"""] ;[" ";"tab "];["&";"&"] ;["“";"ldblquote "] ;["”";"rdblquote "] ;["‘";"lquote "] ;["’";"rquote "] ;["{";"{"] ;["}";"}"] ;[¶;"par tab "] ) )
Fitch Posted April 23, 2008 Posted April 23, 2008 Something doesn't look right up near the top between the a= ... and the S= ... There's that "&Let([T=" in the middle of the Substitute function... looks wrong... and seems to be missing closing bracket on following line and closing parentheses for the Sub. Can you upload the file with the working calc? There should be no difference in 8 vs. 9 for this calc.
Newbies eatapman Posted April 23, 2008 Author Newbies Posted April 23, 2008 I'm uploading a sample file. If you open in 8.5 and modify the Body Copy field, the calculation works great. Open in Advanced 9.0v3, modify the Body Copy it fails with a "?". I only have Advanced and don't yet have any regular FMP 9 clients to test this on... not that it should matter. Thanks for any help! FMP_9_prob.zip
Lee Smith Posted April 23, 2008 Posted April 23, 2008 same thing happens with 8.5 and 9.03 and Tiger. Lee
comment Posted April 23, 2008 Posted April 23, 2008 I can confirm the difference in results between 8.5 and 9. The reason for this, AFAICT, is the GetAsCSS() function: it seems that in 8.5 the function returns a trailing space and a carriage return, and these were eliminated in version 9. I am guessing that the function's author expected the result of GetAsCSS() to contain these trailing artifacts, and their absence breaks one of the subsequent substitutes. I am afraid I cannot suggest a fix, since the function is utterly unreadable and uncommented.
Fitch Posted May 1, 2008 Posted May 1, 2008 I see different result in 8.5 vs 9 as well. If you break the calculation into separate fields -- i.e. the variables in the Let statement a,b,c, etc. -- you can at least get a sense of what the calc's author was driving at. Put k into a field, then make a field for GetAsCSS ( k ) etc. Now look in particular at the "a" section: this calc resembles a recursive function in that it generates a series of Let statements for each bit of formatted text. It's impressively clever but as Michael says, unreadable. It would take me hours to reverse engineer it.
comment Posted May 1, 2008 Posted May 1, 2008 Well, maybe it could be hacked by adding a conditional statement that would append a " ¶" to the GetAsCSS ( k ) part when the current version is 9.
Fitch Posted May 1, 2008 Posted May 1, 2008 Yes, once I wait for the evil-calc hangover to wear off I may try that just for kicks. Unless you beat me too it, which I would not mind at all.
Recommended Posts
This topic is 6048 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