2 Replies Latest reply on Mar 30, 2013 12:52 AM by historychef

    "Let" fails using variable but succeeds with $variable

    historychef

      Summary

      "Let" fails using variable but succeeds with $variable

      Product

      FileMaker Pro

      Version

      12.0v3

      Operating system version

      Mac OS X 10.6.8

      Description of the issue

      Using Evaluate with a Let statement within a custom function succeeds if I use "$local" variables, but not with ordinary Let variables

      Steps to reproduce the problem

      Consider the following definition of a custom function, in which "initialContents" is a parameter:

      Let (
           [ $$__DQN = $$__DQN + 1
           ; a = "$$__DQ" & Right( 1000000 + $$__DQN; 6 )
           ]
           ; Evaluate( "Let (" & a & " = " & Quote( initialContents ) & "; a )" )
      )

      Expected result

      $$__DQ000001 (the number will vary)

      Actual result

      ?

      Workaround

      Let (
           [ $$__DQN = $$__DQN + 1
           ; a = "$$__DQ" & Right( 1000000 + $$__DQN; 6 )
           ; $a = a
           ]
           ; Evaluate( "Let (" & a & " = " & Quote( initialContents ) & "; $a )" )
      )

        • 1. Re: "Let" fails using variable but succeeds with $variable
          Fred(CH)

               Hi Stephen.

               I think the explanation of this issue is the following :

               Considering that an Evaluate call is a new calculation, the Let variables ar not transmitted form the main calculation to this second calculation.

               So, in you example, precisely in the Evaluate sub calulation, the a variable is unknown.

               If i did'nt misunderstood, this behavior is normal.

               Bye, Fred

               PS : Excuse me for my bad english.

          • 2. Re: "Let" fails using variable but succeeds with $variable
            historychef

                 Fred's explanation makes sense. Apparently, Evaluate does not inherit the context in which it appears. Normally, expressions in a Let statement can reference the Let variables defined in the first part of the statement (which explains why the unquoted "a" in the constructed Let statement works), but when Evaluate executes the constructed statement, it does it with no knowledge of the outer Let context. Thanks for your cogent analysis.