Calc" to value of Calc Evaluated."/> Calc" to value of Calc Evaluated."/>
Brian Dunning's FileMaker Custom Functions

EvalCalcInserts ( Text )

Replace "Calc" to value of Calc Evaluated.

  Average rating: 3.9 (51 votes) Log in to vote

Koji Takeuchi   Koji Takeuchi
TonicNote, Inc.
https://tonic-note.com

Share on Facebook Share on Twitter

  Sample input:
mailbody = "Hello, nameFirst nameLast."
EvalCalcInserts ( mailbody )
  Sample output:
"Hello, Koji Takeuchi."

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

EvalCalcInserts ( Text )
2011.07.25, Koji Takeuchi


description:
Replace "Calc" to value of Calc Evaluated.
ex.
nameFirst = "Koji"
nameLast = "Takeuchi"
EvalCalcInserts ( "Hello, nameFirst nameLast." )
= "Hello, Koji Takeuchi."

mailbody = "Hello, nameFirst nameLast."
EvalCalcInserts ( mailbody )
= "Hello, Koji Takeuchi."

 

Comments

unin   unin, japan
Jul 28, 2011
non recursive version.

Case (
PatternCount ( Text ; "<calc>" ) = PatternCount ( Text ; "</calc>" ) ;
Evaluate (
Substitute ( Quote ( Text ) ; [ "<calc>" ; "\" & Evaluate (\"" ] ; [ "</calc>" ; "\") & \"" ] )
)
; Text
)

Not same result in some case.
1. if <calc></calc> is contained in evaluated result.
2. if there is error, return '?'
3. Using variable
<calc>Let($a=0;"")</calc>
first:<calc>Let($a=$a+1;$a)</calc>
second:<calc>Let($a=$a+1;$a)</calc>
 
Travis Preister   Travis Preister
Nov 8, 2016
Neat function! But I also like the idea of a non-recursive version. I think this will give the same results as the original:

If ( PatternCount ( Text ; "<calc>" ) = PatternCount ( Text ; "</calc>" ) ;

Evaluate ( Evaluate ( Substitute ( Quote ( Quote ( Text ) ) ; [ "<calc>" ; "\\\"\" & \" & \" & Substitute ( \"If ( EvaluationError ( Evaluate ( \\\"•\\\" ) ) = 0 ; Evaluate ( \\\"•\\\" ) ; \\\"•\\\" )\" ; \"•\" ; \"" ] ; [ "</calc>" ; "\" ) & \" & \" & \"\\\"" ] ) ) ) ;

Text

) // End If
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Under construction. Email me your wish list for improvements.