2 Replies Latest reply on Feb 7, 2012 8:03 AM by RonCates

    Simple Solution but Stumped

    smunshaw

      Title

      Simple Solution but Stumped

      Post

      Hi there,

      I'm writing a script that should be quite simple but I'm stumped.  I'd like to create a script that allows a "custom dialogue" box to pop up each time there are no records within the found set and continues to do so until there are records available.  Right now my script only works great on the first custom dialog but only works once on the second dialog box before going to my third page.  This is what I have.  

      Set Error Capture [On]

      Perform Find []

      If [Get (FoundCount) = 0]

          Show Custom Dialog ["There Are No Members in this State]

          Enter Find Mode [Pause]

          Perform Find []

      End If

      Go to Layout ["Page 2 Search"]

      Enter Find Mode [Pause}

      Constrain Found Set []

      If [Get (FoundCount) = 0]

          Show Custom Dialog ["No Data Available"]

          Enter Find Mode [Pause]

          Perform Find []

      End If

      Constrain Found Set []

      Go To Layout ["Data List"]

      Enter Browse Mode []

      Anyone have some advise for this newbie?

      Thanks!

       

        • 1. Re: Simple Solution but Stumped
          RonCates

           So it sounds like you are looking for a looping find button. This is the script I came up with for that. Here is a script I wrote for a custom find buttong that behaves very similar to using filemaker's native find. If zero records are found it offers a modify find or cancel dialogue and continues to do so until a found set is established or the script is cancelled. Maybe you could set this up to run as a subscript. As in goto page1, run find script, goto page2 etc.

           

          Perform Script [User abort]

          Perform Script [Set error capture]

          Loop

              If [ Get ( WindowMode ) = 0 ]

                  Set Variable [ $$layout; Value:Get ( ScriptParameter ) ]

                  Perform Script [ "Found Set Save" ] <--Sub script that saves the original found set so it can be restored if the find is cancelled

                  Enter Find Mode [ ]

              Else

                  If [ $mod = 1 ]

                      Modify Last Find

                  Else

                      Perform Find [ ]

                  End If

              End If

              If [ Get ( FoundCount ) < 1 ]

                  Show Custom Dialog [ Title: "No Records Found!"; Message: "There were no records found matching your find criteria."; Buttons: OK, Cancel

                  If [ Get ( LastMessageChoice ) = 2 ]

                      Perform Script [ "Found Set Restore"]

                      // Show All Records

                      Exit Script [ ]

                  Else

                      Set Variable [ $mod; Value:1 ]

                      Modify Last Find

                  End If

              Else

                  Exit Script [ ]

              End If

          End Loop

          • 2. Re: Simple Solution but Stumped
            RonCates

            Here it is again with the save and restore found set script refferences taken out. It's actually not a simple loop. It was quite the challenge when i did it. If you want to know more about the technique I used to save and restore the found set take a look here

            http://fmforums.com/forum/topic/82109-scripting-snapshots-cant-make-it-elegant-any-suggestions/page__fromsearch__1

             

            Set Error Capture [On]

            Loop

                If [ Get ( WindowMode ) = 0 ]

                    Enter Find Mode [ ]

                Else

                    If [ $mod = 1 ]

                        Modify Last Find

                    Else

                        Perform Find [ ]

                    End If

                End If

                If [ Get ( FoundCount ) < 1 ]

                    Show Custom Dialog [ Title: "No Records Found!"; Message: "There were no records found matching your find criteria."; Buttons: OK, Cancel

                    If [ Get ( LastMessageChoice ) = 2 ]

                        Exit Script [ ]

                    Else

                        Set Variable [ $mod; Value:1 ]

                        Modify Last Find

                    End If

                Else

                    Exit Script [ ]

                End If

            End Loop