1 Reply Latest reply on Oct 22, 2014 8:29 AM by TSGal

    The substitute script step does always execute / evaluate the last element of the command

    5104117733

      Summary

      The substitute script step does always execute / evaluate the last element of the command

      Product

      FileMaker Pro

      Version

      13

      Operating system version

      MacOs Yosemite

      Description of the issue

      When you use the substitute command in a formula the last expression of the command is being evaluated always and not only when there is something to be replaced. This is a major performance issue!

      Steps to reproduce the problem

      Substitute( "test" ; "abc" ; Let( $$variable = 5 ; "" ) )

      Expected result

      substitute returns test, $$variable is not set

      Actual result

      substitute return test, $$variable is 5

      Workaround

      check the existence of the to be replaced value before actually substituting the value. This is also a bit a performance issue, hence you actually need to search the occurrences in the text twice if there are any occurrences to be replaced.

      if ( PatternCount( "test" ; "abc" ) > 0 ; Substitute( "test" ; "abc" ; Let( $$variable = 5 ; "" ) ) ; "test" )