3 Replies Latest reply on Dec 15, 2011 9:40 AM by jebber6685

    Is there a way to "mix up" the record sequence of a found set?

    jebber6685

      Title

      Is there a way to "mix up" the record sequence of a found set?

      Post

      All,

      Is there a way to "mix up" the record sequence of a found set? I would like scipt that would " mix up" the sequence of a found set of records. 

       

      I am not speaking of using the Random function to GoToRecord that would go to a random record number in the sequence. I am referring to a method that would mix up the record sequence randomly but my Go To Record would go to first record as it should but it would possibly be a different record from the last time the script ran.

      Is somthing like this possible?

      I am developing a quiz and want the questions to be mixed up when the Quizee starts the questions over again

      Any help here would be greatly appreciated.

      I have FMPro Advanced 11.0 v3
      OS - Windows Vista on desktop, Windows 7 on laptop

        • 1. Re: Is there a way to "mix up" the record sequence of a found set?
          Sorbsbuster

          Why not create a number field called 'SortOrder', then run a script as part of the 'Start New Quiz' script that runs down the found set and sets the SortOrder number using the Random Function.  Then sort by that number, and GTR [First].

          • 2. Re: Is there a way to "mix up" the record sequence of a found set?
            LaRetta_1

            I would be concerned if this were multi-user and you are setting a field.  You would have to (possibly) deal with record locking AND all Users would see the same order or over-write other Users' sort order.  However, the idea is sound and if you create an unstored calculation (result is number) with something like:

            Int ( Random * Get ( FoundCount ) ) + 1

            ... then you can sort on that field.  Each new window, screen redraw or different User will get a different sorted number set and no need to use script (except single line with Sort).  I will make an assumption that you do not have 10,000 questions?  Only if the numbers gets really high would sorting on unstored cause performance issues.  In fact, Random re-calculates twice - once when sorted and once when finally displayed and the result numbers will not match the numbers it sorts by so do not bother trying to display this calculation. 

            It is a strange behavior with Random but in this situation, it can be an advantage, producing true random sets for Users.  To stop the double-evaluation on the entire record set, perform the sort on a null layout (no fields) before switching to the layout showing the questions.  If you would like sample file, we can provide one.

            • 3. Re: Is there a way to "mix up" the record sequence of a found set?
              jebber6685

              Both the responses from LaRetta and Sorbsbuster are great.

               

              Thanks for your input. This is much appreciated. 

               

              Jeff