2 Replies Latest reply on Mar 10, 2014 12:38 PM by mattduke101@gmail.com

# Evaluate with Quote/escaping characters confusion ...

Hello all - I'm still a relative newby to FM12 and I'm having a problem grasping this basic calculation issue.

This formula ...

Evaluate ( Quote ( "2 * 5" ) )

... returns 2 * 5

Now as far as I know, the Quote function wraps any parameter passed to it in quotes, but escapes any quotes in between, and I kind of proved this by substituting what I think the Quote does in the formula above by running ...

Evaluate ( ""2 * 5"" )

... which also returns 2 * 5 as I expected

However, from my understanding the escape character removes both itself and the character that immediately follows it from whatever is being evaluated.

Given this, then, I ran this formula without the escape characters or the quotes that directly follow them ...

Evaluate ( "2 * 5" )

... but this returns 10, (which I know is the expected answer!)

Could someone help me out by perhaps explaining how the escaping works (i.e. the how Quote mechanism works in this instance)?

-Matt-

• ###### 1. Re: Evaluate with Quote/escaping characters confusion ...

Matt -

"However, from my understanding the escape character removes both itself and the character that immediately follows it from whatever is being evaluated. "

This is where your confusion comes from. This statement is not correct. The escape causes FileMaker not to process the following character as part of the expression, but merely to pass it through directly. So in your example, it tells FileMaker, "Don't treat the double quote as the beginning / end of a text string; rather, just pass it directly through as a double quote."

Why does that matter? Because Evaluate processes its parameter as though it were a calculation expression. The catch is, its parameter has to be a legitimate text string. So it has to be a field, variable, or combination of field(s), variable(s), and text string(s) properly formatted. So, if I write:

"2 * 5"

Evaluate treats this as the expression

2 * 5

and calculates it as a mathematical expression. If I write:

"\"2 * 5\""

Evaluate treats this as a literal text string. In similar fashion, if I were to write:

"\$foo = 2 * 5"

Evaluate would set the variable \$foo equal to 10. If I write:

"\$foo = \"2 * 5\""

Evaluate would set the variable \$foo equal to the text string "2 * 5" (without the quotes).

Hope that helps.

Mike

1 of 1 people found this helpful
• ###### 2. Re: Evaluate with Quote/escaping characters confusion ...

Thanks for your quick reply, Mike. The key sentence for me is "just pass it directly through as a double quote" ... this explains it!

Cheers, Matt.