Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Calculation broken in FMP 9

Featured Replies

  • 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 "]

)

)

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.

  • 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

same thing happens with 8.5 and 9.03 and Tiger.

Lee

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.

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.

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.

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

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.