April 22, 200817 yr Newbies 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 "] ) )
April 23, 200817 yr 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.
April 23, 200817 yr Author Newbies 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
April 23, 200817 yr 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.
May 1, 200817 yr 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.
May 1, 200817 yr 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.
May 1, 200817 yr 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.
Create an account or sign in to comment