3 Replies Latest reply on Aug 17, 2012 2:36 PM by AdalgeirArason

    In mac lion, Filemaker Pro 11.0v4 doesn't evaluate (recalculate) script results between cycles in a...

    AdalgeirArason

      Summary

      In mac lion, Filemaker Pro 11.0v4 doesn't evaluate (recalculate) script results between cycles in a loop

      Product

      FileMaker Pro

      Version

      11

      Operating system version

      11.0v4 - run on Mac mini (2.3 GHz Intel Core i5) with Mac OS X 10.7.4

      Description of the issue

      A loop is supposed to stepwise add +1 to a field in the current record and look for an exit signal (by relookup, to see if a unique combination of two fields has been found).

      It doesn't evaluate the results before starting the next cycle, so the exit signal doesn't work. The loop can only be stopped by cmd-. (command-dot).

      The script works perfectly in Filemaker 8 in PC and it always did so in my older mac, before upgrading to version 11 and lion.

      Steps to reproduce the problem

      See an uploaded demonstration file for this problem at https://sites.google.com/site/allamappa/home/filemakerquery

      The file's name is ScriptProblem.fp7

      The simplest way is to open that file and see (at least in fm 11 on the mac lion platform) how cmd-1 get's stuck in a loop, increasing a number without recognising the exit signal. The only way to stop the script is to use cmd-.

      The 'Refresh Window" part of the loop is to make it easier to see on the screen what's happening to the field while the loop goes on.

      This is how the script looks:

      Show All Records
      Go to Record/Request/Page
      [ First ]
      Loop
      Copy [ ScriptProblem::line ]
      [ Select ]
      Enter Find Mode [ ]
      Paste [ ScriptProblem::line ]
      [ Select ]
      Perform Find [ ]
      Set Field [ ScriptProblem::number; 1 ]
      Relookup Field Contents [ ScriptProblem::IDnumber ] [ No dialog ]
      Loop
      Exit Loop If [ ScriptProblem::IDnumber_occurred_before = "" ] Set Field [ ScriptProblem::number; ScriptProblem::number + 1 ]
      Relookup Field Contents [ ScriptProblem::IDnumber ] [ No dialog ]
      Refresh Window
      End Loop
      Show All Records
      Go to Record/Request/Page
      [ Next; Exit after last ]
      End Loop
      Show All Records
      Go to Record/Request/Page
      [ First ]

      Expected result

      Records in a data file will be assigned a reference number, so that any records which share an identical ID will get a unique combination of the ID and the reference number.

      I.e. something like this (ID being a text field, the other one a number field):

      ID - ref#
      A - 1
      A - 2
      E - 1
      A - 3
      E - 2
      H - 1
      K - 1
      A - 4
      K - 2
      etc.

      Actual result

      ID - ref#
      A - 1
      A - ->∞ (running until forced to stop)
      E
      A
      E
      etc.

      Exact text of any error message(s) that appear

      No error message.
      As said above, runs fine on other platforms / older fm-versions.

      Workaround

      I can only move my data files to a different platform while running the script, and back to the mac lion after the script results have been incorporated

        • 1. Re: In mac lion, Filemaker Pro 11.0v4 doesn't evaluate (recalculate) script results between cycles in a...
          philmodjunk

          This is a rather strange way to go about what you want here. There are simpler scripts that you can use to do this.

          The problem is not specific to OS Lion. I get an endless loop in Windows Xp as well.

          The problem is that Set field opens the current record for editing and changes the value of the field but the change is not automatically commited back to the database and thus the relookup steps fail to relookup the data correctly. (Note relookups are not really needed here, a relationship linking directly to the fields in the related table occurrence would work just as well.)

          With the following modifications, your script should work (at least it does in Windows Xp):

          Show All Records
          Go to Record/Request/Page[ First ]
          Loop
                 Copy [ ScriptProblem::line ][ Select ]
                 Enter Find Mode [ ]
                 Paste [ ScriptProblem::line ][ Select ]
                 Perform Find [ ]
                 Set Field [ ScriptProblem::number; 1 ]
                 Commit Records/Requests
                 Relookup Field Contents [ ScriptProblem::IDnumber ] [ No dialog ]
                 Loop
                         Exit Loop If [ ScriptProblem::IDnumber_occurred_before = "" ]
                         Set Field [ ScriptProblem::number; ScriptProblem::number + 1 ]
                         Commit Records/Requests
                         Relookup Field Contents [ ScriptProblem::IDnumber ] [ No dialog ]
                         Refresh Window
                 End Loop
                 Show All Records
                 Go to Record/Request/Page[ Next; Exit after last ]
          End Loop
          Show All Records
          Go to Record/Request/Page[ First ]

          Script was reformatted for easier reading using the ScriptPretty custom function found in the Known Bugs List database.

          • 2. Re: In mac lion, Filemaker Pro 11.0v4 doesn't evaluate (recalculate) script results between cycles in a...
            philmodjunk

            PS. It is also good practice to avoid using copy/paste in a script of this type.

            If you used this code:

            Set variable [$Line ; value: ScriptProblem::line]
            Enter Find Mode[]
            Set field [ScriptProblem::line ; $line ]

            You'd get the same results, but any data previously copied to the clipboard by the user is no longer destroyed by this script.

            • 3. Re: In mac lion, Filemaker Pro 11.0v4 doesn't evaluate (recalculate) script results between cycles in a...
              AdalgeirArason

              Hi, thanks a lot! It's solved now and I've learned.

              I know it was a cumbersome approach but it origins in much earlier versions of filemaker many years ago. Before I discovered the possibility of letting a relationship link multiple fields directly. And I'm not an expert in programming. Thank's again for your careful explanation and tips, it's really helpful.