4 Replies Latest reply on Sep 17, 2010 10:31 AM by R12GS

    Script loops endless (because it can't delete records?)

    R12GS

      Title

      Script loops endless (because it can't delete records?)

      Post

      This post was (perhaps incorrectly) titled "OSX Script doesn't run on WinXP (FM11)"

      (Sept16, 2010)  I'm pretty sure it is a permissions issue, not platform issue.  Please see post #3 below.

      Hello,

      I have a script that has been running for years on OS X, but trying to run it today from a Win XP; it seem to get stuck in an endless loop.  The winXP machine has FMPro 11.  OSX machine has FM11 Adv.

      Can someone give me a hint which script steps might be incompatible with WinXP?  Or where can I find a list of differences between WinXP and OSX (to get a hint which step is causing the problem).


      THANKS!!!

      ===================================

      Set Error Capture [ On ] 

      Sort Records [ Specified Sort Order: backorders::part; ascending ] [ Restore; No dialog ]

      Go to Record/Request/Page

      [ First ]

      Loop If [ IsEmpty(backorders::part) ]

      Delete Record/Request

      [ No dialog ] If [ IsEmpty(backorders::po_history) ]

      End If Set Field [ backorders::po_history; GetAsNumber(backorders::PO_Number_extract) & " (" & GetAsNumber(backorders::

      quantity) & ") " ]

      End If Exit Loop If [ Get(RecordNumber) = Get(FoundCount) ] If [ backorders::part = GetNthRecord( backorders::part ; Get(RecordNumber) + 1) ]

      Else

      Set Variable [ $recnum; Value:Get( RecordNumber ) ] Go to Record/Request/Page

      [ Next ] Set Field [ backorders::po_history; Trim(GetNthRecord( backorders::po_history; Get(RecordNumber) - 1)) & " " &

      GetAsNumber(backorders::PO_Number_extract) & " (" & GetAsNumber(backorders::quantity) & ") " ] Set Field [ backorders::quantity; backorders::quantity + GetNthRecord( backorders::quantity; Get(RecordNumber) - 1) ]

      Go to Record/Request/Page [ $recnum ] [ No dialog ]

      Delete Record/Request

      [ No dialog ]

      Go to Record/Request/Page [ $recnum ] [ No dialog ]

      Go to Record/Request/Page

      [ Next; Exit after last ]

      End If End Loop

        • 1. Re: Script loops endless (because it can't delete records?)
          philmodjunk

          Set Error Capture [ On ] 
          Sort Records [ Specified Sort Order: backorders::part; ascending ] [ Restore; No dialog ]
          Go to Record/Request/Page [ First ]
          Loop 
             If
          [ IsEmpty(backorders::part) ]
                 Delete Record/Request [ No dialog ] 
                 If [ IsEmpty(backorders::po_history) ]
                 End If 
                 Set Field
          [ backorders::po_history; GetAsNumber(backorders::PO_Number_extract) & " (" & GetAsNumber(backorders::quantity) & ") " ]
             End If 
             Exit Loop If
          [ Get(RecordNumber) = Get(FoundCount) ] 
             If [ backorders::part = GetNthRecord( backorders::part ; Get(RecordNumber) + 1) ]
             Else
               
          Set Variable [ $recnum; Value:Get( RecordNumber ) ] 
                Go to Record/Request/Page [ Next ] 
                Set Field [ backorders::po_history; Trim(GetNthRecord( backorders::po_history; Get(RecordNumber) - 1)) & " " & GetAsNumber(backorders::PO_Number_extract) & " (" & GetAsNumber(backorders::quantity) & ") " ] 
                Set Field [ backorders::quantity; backorders::quantity + GetNthRecord( backorders::quantity; Get(RecordNumber) - 1) ]
                Go to Record/Request/Page [ $recnum ] [ No dialog ]
                Delete Record/Request [ No dialog ]
                Go to Record/Request/Page [ $recnum ] [ No dialog ]
                Go to Record/Request/Page [ Next; Exit after last ]
             End If
          End Loop

          I had to clean up your script format before I could read it enough to make sense of it. Let me know if some part of it doesn't match what you actually have.

          There isn't anything there that I can see that would behave differently on a windows platform than a Mac. I do spot a branch of your script where you could get trapped in an infinite loop, however.

          If this expression is false: Get(RecordNumber) = Get(FoundCount) ] 
          and this one is true:  backorders::part = GetNthRecord( backorders::part ; Get(RecordNumber) + 1)

          Then I see nothing in your script that will exit the loop...

          • 2. Re: Script loops endless (because it can't delete records?)
            R12GS

            Hi Phil,

            Thanks for looking over my script.  I have since discovered that it is possibly related to the priviledges, that it works with the [full] priviledge set (me, on OSX) but not the "lesser" priviledge set that the users (on WinXP) log in with.  The script doesnt TELL the user whats going on, it just grinds forever in an endless loop.

            Current script steps are this:

            Set Error Capture [ On ] 
            Sort Records [ Specified Sort Order: backorders::part; ascending ] [ Restore; No dialog ]
            Go to Record/Request/Page [ First ]
            Loop 
               If
             [ IsEmpty(backorders::part) ]
                   Delete Record/Request [ No dialog ] 
               End If 
               Exit Loop If
             [ Get(RecordNumber) = Get(FoundCount) ] 
               If [ backorders::part = GetNthRecord( backorders::part ; Get(RecordNumber) + 1) ]
               Else
                 
             Set Variable [ $recnum; Value:Get( RecordNumber ) ] 
                  Go to Record/Request/Page [ Next ] 
                  Set Field [ backorders::po_history; Trim(GetNthRecord( backorders::po_history; Get(RecordNumber) - 1)) & " " & GetAsNumber(backorders::PO_Number_extract) & " (" & GetAsNumber(backorders::quantity) & ") " ] 
                  Set Field [ backorders::quantity; backorders::quantity + GetNthRecord( backorders::quantity; Get(RecordNumber) - 1) ]
                  Go to Record/Request/Page [ $recnum ] [ No dialog ]
                  Delete Record/Request [ No dialog ]
                  Go to Record/Request/Page [ $recnum ] [ No dialog ]
                  Go to Record/Request/Page [ Next; Exit after last ]
               End If
            End Loop

            =======================

            I'm pretty sure that the problem is happening at this step:

            Delete Record/Request [ No dialog ] 

            because there are always records where "IsEmpty(backorders::part)" is 'true' but none of these get deleted.

            But in the priviledge set, "Create, Edit and Delete records in all Tables" is allowed.

            Is there anyplace else that does not allow these users to delete records?

            THANKS!

            • 3. Re: Script loops endless (because it can't delete records?)
              philmodjunk

              Remove or disable the first step: Set Error Capture [on]

              and run the script to see what error message might pop up.

              If the file is opening in read only mode because the file is in a directory your windows users don't have permission to modify, you'll need to change that. If it's a FileMaker privilige set that is keeping them from deleting records, you should either edit the privilege set to permit deleting records or click the "run with full access permissions" option found at the bottom of the script editor window for this script.

              • 4. Re: Script loops endless (because it can't delete records?)
                R12GS

                Thanks Phil!  I rally appreciate your thoughtful, and complete answers!

                The SOLUTION was this:

                "click the "run with full access permissions" option found at the bottom of the script editor window for this script."

                SIMPLE, SIMPLE SIMPLE.

                Everything's running perfectly now.  THANK YOU!