Rewolfer Posted January 3, 2013 Posted January 3, 2013 Hello fellow FMP programmers! When passing styled script variables I stumbled on the following effect (FileMaker Pro Advanced 12; Windows7). Paste into DataViewer: Let ( $$testStyle = "hello " & TextStyleAdd ( "world" ; Bold ) ; "" ) & Let ( $$testCombination = "Combination: " & Evaluate( Quote( $$testStyle )) ; "" ) & Let ( $$testEvaluate = "Evaluate: " & Evaluate( "$$testStyle" ) ; "" ) & Let ( $$testQuote = "Quote: " & Quote ( $$testStyle ) ; "" ) Paste onto any layout: <<$$testStyle>> <<$$testCombination>> <<$$testEvaluate>> <<$$testQuote>> As you can see, evaluate and quote keep the bold text style. If used in combination any style is lost. Is this intended behavior? Any work arounds? Thanks for any reply, Rewolfer.
Raybaudi Posted January 3, 2013 Posted January 3, 2013 I do not know if that is intended behavior, but it's commonly known... There was even a custom function: Unformat (text) that had the simple calculation: Evaluate ( Quote ( text ) )
Rewolfer Posted January 3, 2013 Author Posted January 3, 2013 I wasn't aware of the custom function. Thanks for pointing that out. What makes me wonder is that only the combination of evaluate and quote strips all styles. This behavior forces me to ditch the quote-function when working with evaluations. Sigh. Rewolfer.
comment Posted January 4, 2013 Posted January 4, 2013 What exactly are you trying to achieve here? The Evaluate() function looks at the expression parameter as a formula. Any styling applied to a formula or any of its parts is meaningless when the formula is evaluated. IOW, "4 + 5" evaluates as 9, and "4 + 5" also evaluates as 9, not 9. You have managed to set up a rather confusing example with the $$testEvaluate variable, but it doesn't change the basic principle.
Rewolfer Posted January 6, 2013 Author Posted January 6, 2013 Hello comment, I agree with you when the evaluation is purely numerical. But concatinations / texts should preserve their formatting (as they do with evaluate() and quote() so it's apparently not "meaningless"). The set of custom functions I use to assign script parameters handles lots of evaluations. It works perfectly (the text as such is rendered okay) but all formatting is lost because of the combination of Evaluate ( Quote ( $$anything )). I guess it's the way it is. Thanks for the reply, Rewolfer.
comment Posted January 6, 2013 Posted January 6, 2013 all formatting is lost because of the combination of Evaluate ( Quote ( $$anything )). To be precise, all formatting is lost because the Quote() function does not preserve it the way it preserves special characters. If, for example you have a text field containing: Hello "quoted" world then Quote ( Textfield ) will return = "Hello "quoted" world" which when evaluated, will turn into: Hello "quoted" world because now the word "world" is part of a formula and the styling is meaningless. To get what you want (I think), the Quote() function would have to go one step further and return = "Hello "quoted" " & TextStyleAdd ( "world" ; bold ) which would then evaluate back into the original text, including styling. I am still not sure what the purpose is here, but you may want to look at the GetAsCSS() and GetAsSVG() functions, that do break the text into separately styled segments - although the results are not at all easy to reuse.
Recommended Posts
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