2 Replies Latest reply on Feb 25, 2011 4:23 AM by Mitch

    Loop, works on Mac but not on Windows

    Mitch

      Title

      Loop, works on Mac but not on Windows

      Post

      Hi,

      I have a simple loop at the end of a import script.  

      Go to Record [Next]

      Loop

      If [not Is Empty (Main_Page::Field_A)]

      Set Variable [$Field_A_Data; Value:Main_Page::Field_A]

      Set Field [Main_Page::Field_B; $Field_A_Data]

      End if

      Go to Record [Next; Exit after last]

      End Loop

       

      The entire import script, including the loop function works on Mac.  When using windows, the import script works but the loop function does not.  Not data is copied fro, Field_A to Field_B.

       

      I have tried different ways of copying the data from Field_A to Field_B within the loop including:

       

      Set Field [Main_Page::Field_B; Main_Page::Field_A]

       

      but still no joy.

       

      Systems:

      Mac OSX Snow Leopard - FMP Adv 11 v3 Update

      Windows Vista - FMP Adv 11 v3 Update

        • 1. Re: Loop, works on Mac but not on Windows
          philmodjunk

          Go to Record [First]
          Loop
                 If [not Is Empty (Main_Page::Field_A)]
                         Set Variable [$Field_A_Data; Value:Main_Page::Field_A]
                         Set Field [Main_Page::Field_B; $Field_A_Data]
                 End if
                 Go to Record [Next; Exit after last]
          End Loop

          I think you wan that first line to be Go To Record [first], not next.

          I see no issues that would make this script work differently on Windows. On my XP system I use similar scripts all the time.

          If Field_B and Field_A are from the same record, you should be able to replace the two steps inside the If-End If block with just:

          Set Field [Main_Page::Field_B; Main_Page::Field_A]

          One thing that I can't tell from your post is what layout is current, nor what table occurrence it refers to in Show Records From of Layout Setup... From what your script shows, this most likely should refer to Main_Page. If it refers to a different table occurrence or if your layout is sometimes run from a different layout, the results--for both Mac and Windows could be difficult to predict.

          If none of that suggests a solution, I recommend enabling the debugger and data-viewer before running this script. Watching it step through this loop step by step while you monitor the values in the fields and variables may provide a clue.

          • 2. Re: Loop, works on Mac but not on Windows
            Mitch

            Phil, you are correct.  I found that after the import, the wrong layout was current.  It only seemed to matter on the Windows Runtime, not the Mac Runtime as the scripts for each system were both identical.