5 Replies Latest reply on Aug 31, 2009 8:32 AM by MaineSteve

    Possible bug with Get Next Record

    MaineSteve

      Summary

      Possible bug with Get Next Record

      Description of the issue

      I have a very frustrating problem here and I've tried to isolate it to see if I have a script problem.  But nothing appears to be wrong with the script, so I'm submitting the problem here for consideration. I currently have 10.0v3 and am trying to have a script go to the Next or Previous record using Record/Request/Page.  I have two buttons and they both call the same script.  Clicking on Button 1 sets a script Parameter to "NextButton", clicking on Button 2 passes a script Parameter of "PrevButton".  The Parameter is put into a variable called $NavParameter, then a script is called in another file which uses an If evaluation to determine if Record/Request/Page Next or Record/Request/Page Previous should be used. For the most part the scripts work fine.  As expected clicking on Button 1 indexes the current record in the other file to the next record, clicking on Button 2 goes to the previous record.  But then something happens and when clicking on Button 1 (Next) it bounces back one record previous.  Clicking on Button 1 (Next) indexes it to the next record again, but another click on Button 1 puts it back one.  It's stuck in a loop like that no matter how many times I click on the button.  I have used Button 2 (Previous) to go from the end of the file to the beginning without problems.  Random placement anywhere within the file also works flawlessly for Previous.  It's only Next that has this problem and it has it in the same places every single time, so at least the "loops" are 100% predictable even if I don't understand why its happening. OK, here's what I've done to isolate the problem: 1.  I went to the secondary file and manually ran the script from there, which cut out the button clicking and variable setting.  I got the same loop behavior. 2.  I switched from using a variable to using a field with the same value, just in case something was getting messed up with the variable.  I got the same loop behavior. 3.  I moved the Goto Record/Request/Page Next step out of the variable evaluation and had it sit at the very top of my script with an Exit Script step just below it.  In other words, I have a script with one standard script step, no other stuff at all.  Running this script does index to the next record without any loop problems. 4.  Moving the Goto Record/Request/Page Next step back into the If evaluation brings back the same behavior again. The only thing I can conclude is that there's a bug here.  After stripping out everything there are two cases, both of which should work identically but one doesn't: CASE 1 If Variable = "Next" then Goto Next Record   ELSEGoto Previous Record CASE 2 Goto Next Record It really is that simple a problem that I'm having. Case 1 just says "check this variable and do either A or B based on the result".  Extremely basic, simple stuff.  Case 2 just skips the evaluation, but uses the same exact script step to move to the next record.  And yet one works consistently wrong, the other works consistently correct.  And Previous works 100% either way. The worst thing about this is there *is* a common factor as to where the "loops" are encountered.  But it makes absolutely no sense! I have an ID field which contains unique ID numbers.  The loops seem to be right before there is a gap in the ID numbers (from deleted records). If I skip over this by manually indexing to a run of consecutive IDs I don't have a problem again until it hits a gap in the IDs. Yet this field is not being used in any way shape or form, so how can these loops be consistently prior to hitting a gap in a user created field?  The ID numbers are assigned by Filemaker (serial numbers), but still... there shouldn't be any correlation between these things and yet there is. Anyway... I've wasted enough time on this problem for one day.  Hopefully there is something I can do to get around this problem.  Any ideas of what to try will be dutifully put to the test. Thanks, Steve  

        • 1. Re: Possible bug with Get Next Record
          mrvodka
             First I would try saving the file as compact first. Second post your script in its entirety here.
          • 2. Re: Possible bug with Get Next Record
            comment_1
              

            MaineSteve wrote:
            The Parameter is put into a variable called $NavParameter, then a script is called in another file which uses an If evaluation to determine if Record/Request/Page Next or Record/Request/Page Previous should be used.

            Actually, the puzzling part here is that you say it does work sometimes. Local script $variables are limited in scope to the script in which they were defined. Even global $$variables are limited to their origin file. Therefore your test, performed in another script in another file:

             

            If Variable = "Next" then Goto Next Record

               ELSE

            Goto Previous Record

             

            should fail consistently, and always select the Else branch.

             

            • 3. Re: Possible bug with Get Next Record
              MaineSteve
                

              I thought the variable was valid for the duration of the script, regardless of what files' scripts subsequently are called, but once the original script is complete the variable is purged.  I'm new to using the variable setting command, though, I am trying to shed some very old FM Pro habits (I've been using FM Pro since it was just called Filemaker 4, just after dinosaurs ruled the Earth

               

              As I said, in order to rule out the setting/recalling the variable as a source of problems I removed it completely and went with the old tried and true method of setting a GLOBAL field.  I've also gone directly to the file where the Next/Previous is being performed and therefore isolated the script steps even further.  This is literally all that I am running now:

               

              If [Master Link:: DEBUG Value 1 = "NextButton"]

                  Go to Record/Request/Page [Next]

              Else

                  Go To Record/Request/Page [Previous]

              End If

              Commit Records/Requests

               

              Seriously... that's all the script says!  Normally a script in Master File sets DEBUG Value 1 based on which button is clicked on.  However, with the test I am doing now that script isn't being called (and nothing else is either) so the variable "NextButton" is a static value.  There should be no reason, and I mean none, preventing this script from working.

               

              In order to further isolate the problem I changed the script to be this:

               

              If [Master Link:: DEBUG Value 1 = "NextButton"]

                  Go to Record/Request/Page [Next]

              Else If [Master Link:: DEBUG Value 1 = "PreviousButton"]

                  Go To Record/Request/Page [Previous]

              End If

              Commit Records/Requests

               

              Note that this modified script requires the variable DEBUG Value 1 be changed to "PreviousButton" in order to go to the previous record.  Since I have no other scripts running, and the above noted script doesn't call for that value to change, the "Else" behavior is no longer a default action.  Which did produce an interesting result.

               

              I set the current record to be one at the beginning of a stretch of records I know works with the Next Record script step.  Running the script works in that it indexes the current record to the next record.  And again, and again until it gets to the last record with a contiguous ID number in my user defined field.  The first script noted would bounce back one record, then forward, then back, then forward, then back, etc.  The new script, with the ELSE IF statement, does not produce any movement at all.  In other words, I now know for sure that both the initial IF the ELSE IF are being evaluated as "false".  That rules out Filemaker getting confused and thinking the ELSE was "true". 

               

              Therefore, I can see now that when the script comes to a record that has a non-contiguous ID in my user defined field the If [Master Link:: DEBUG Value 1 = "NextButton"] logic check is failing, even though the variable DEBUG Value 1 is indeed still set to "NextButton" and there is indeed a subsequent record to advance to.  The file's inherent, standard FM Pro next/previous record navigation buttons work fine so there's absolutely no reason why this step should be failing.

               

              I really don't like to jump up and down and say "I found a bug", but I think this is clearly a bug.  My only guess as to what is causing this is...

               

              The user defined ID field I keep mentioning is set by an auto-generated serial number at the time a new record is created. Through subsequent use of the database I have deleted some of these records, which has left gaps in the ID sequence.  This is not a problem for my purposes because I only need the ID to be unique.  But it appears that somewhere, buried in the guts of Filemaker Pro's code, something cares that there is a break in the sequence of the records' creation.  This, in turn, is setting a "false" for the initial IF script step when it should be "true".  I even changed the user specified ID number to be sequential and it still failed, so it's definitely got nothing to do with that field or the variable within it.  It's something out of the view of the end user.

               

              Steve 

              • 4. Re: Possible bug with Get Next Record
                comment_1
                  

                MaineSteve wrote:
                I really don't like to jump up and down and say "I found a bug", but I think this is clearly a bug.

                I don't think so, but I really cannot read all of this as carefully as I'd like to in order to find the fault - IF it can be found there. My guess woud be that the other file cannot "see" the global value - but that's only a guess.

                 

                I'd suggest you make a simple demo showing the issue, and post it somewhere (unfortunately, this forum does not allow attachments).

                 

                One thing I can tell you for certain: going to previous/next record considers the current found set and sort order only - any data in the records themselves, including serial ID, is completely ignored.

                • 5. Re: Possible bug with Get Next Record
                  MaineSteve
                    

                  Remember that this is inconsistent behavior.  The script works fine, absolutely as expected, until it comes to very specific records.  As soon as it hits one of those records the script fails to perform as it did for the previous record.  Therefore we can rule out things like not being able to "see" the global value since FM Pro is not supposed to alternate between being able to "see" and being blind.  It should either always "see" the variable or never.  Not back and forth depending on which record is current.

                   

                  And you're absolutely correct that previous/next is not supposed to consider the data within the records themselves.  Yet clearly FM Pro is treating some records differently than others when it comes to this behavior.  The points of failure are 100% consistently tied to which record is next in the list, which obviously should not be the case.  That's why I am theorizing that it has to do with some low level data associated with the records which shouldn't be getting in the way but, for whatever reason, is.

                   

                  I'll see what I can do about making a sample of the two database files in question. 

                   

                  Steve