4 Replies Latest reply on Feb 12, 2014 10:07 AM by philmodjunk

    Script works only with debugger

      Title

      Script works only with debugger

      Post

           I hope someone else has experienced this problem and can give me a hint about fixing it.  I have a script that works just fine if I'm in the debugging mode, but fails when the debugger is not engaged.  If you have any idea what might cause this behavior, please give me a hint.

        • 2. Re: Script works only with debugger
          philmodjunk

               I have seen a few cases where the fact that the debugger refreshes the window with every step affects how the script functions. But we'd need to see the actual script to know if that might be a factor.

               To post a script to the forum:

                 
          1.           You can upload a screen shot of your script by using the Upload an Image controls located just below Post A Answer.
          2.      
          3.           You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here. (with this approach, you can get multiple script steps on the same line, please edit the pasted text by inserting some returns to separate those steps.)
          4.      
          5.           If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
          6.      
          7.           If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
          • 3. Re: Script works only with debugger

                 Thanks for the replies.

                 General info:  No errors.  Macintosh with OS X 10.9.1.  FMP Advanced v12.  New database.

                 The primary script is PerformReportSearch (see below).  That script calls two subscripts (see below).  The subscript "EnterSubtitle" is the culprit.  (The intended purpose is to allow the user to enter a phrase that will be printed in the report's footer region.)   Without the Debugger, I never get a chance to enter the phrase.  However, with the Debugger running, everything works OK and the phrase I enter dutifully appears at the bottom of the report.

                 I suppose it's natural to claim that FM has a bug, but I fully expect that there is simply something that I am missing.  I certainly hope that it's "my fault" so the problem can be easily rectified; I really want to include this feature in the application.

                  

            PerformReportSearch

                                       
            •                               

              #-----Added January 19, 2014. (Reconciled February 10, 2014.)

                                       
            •                          
            •                               

              #-----Called from the "Perform Search" button in the ReportSearch Screen. Script which

                                            

              completes the Search process.

                                       
            •                          
            •                               

              Perform Script [ “CheckForBothSearchDates” ]

                                       
            •                          
            •                               

              Close Window [ Name: "EnterReportSearchValues"; Current file ]

                                       
            •                          
            •                               

              Perform Script [ “EnterSubtitle” ]

                                       
            •                          
            •                               

              Freeze Window

                                       
            •                          
            •                               

              #-----Go to "SearchDonations(Donations)" where values from Globals will be entered in the

                                            

              Find Mode

                                       
            •                          
            •                               

              Go to Layout [ “ReportSearchDonations” (Donations) ]

                                       
            •                          
            •                               

              #-----Added February 4, 2014. Start with all Donation records before search is started.

                                       
            •                          
            •                               

              Show All Records

                                       
            •                          
            •                               

              Enter Find Mode [ ]

                                       
            •                          
            •                               

              Set Field [ Donors::DonorLast; Globals::gLast ]

                                       
            •                          
            •                               

              Set Field [ Donors::DonorCity; Globals::gCity ]

                                       
            •                          
            •                               

              Set Field [ Donors::DonorState; Globals::gState ]

                                       
            •                          
            •                               

              Set Field [ Donors::DonorCategory; Globals::gCategory ]

                                       
            •                          
            •                               

              #-----Added February 3, 2014. Converts the gStartDate and gEndDate to a range expression

                                            

              and enters that expression in the DonationsDate field.

                                       
            •                          
            •                               

              If [ Globals::gStartDate>0 and Globals::gEndDate > 0 ]

                                       
            •                          
            •                               

              #-----Set $Range variable to the values in gStartDate and gEndDate and enter that range in

                                            

              the DonationsDate field.

                                       
            •                          
            •                               

              Set Variable [ $Range; Value:GetAsText(Globals::gStartDate) & "..." &

                                            

              GetAsText(Globals::gEndDate) ]

                                       
            •                          
            •                               

              Set Field [ Donations::DonationDate; $Range ]

                                       
            •                          
            •                               

              End If

                                       
            •                          
            •                               

              Set Error Capture [ On ]

                                       
            •                          
            •                               

              #-----Find the records.

                                       
            •                          
            •                               

              Perform Find [ ]

                                       
            •                          
            •                               

              #-----Added for debugging.

                                       
            •                          
            •                               

              Set Variable [ $DonationsFound; Value:Get ( FoundCount ) ]

                                       
            •                          
            •                               

              #-----Sort by DonorSort field (LastFirst) and print.

                                       
            •                          
            •                               

              Sort Records [ Keep records in sorted order; Specified Sort Order: Donors::DonorSort;

                                            

              ascending Donations::DonationDate; ascending ] [ Restore; No dialog ]

                                       
            •                          
            •                               

              #-----Check value of ReportFlag and go to appropriate print layout.

                                       
            •                          
            •                               

              If [ $$ReportFlag = "AD" ]

                                       
            •                          
            •                               

              Go to Layout [ “Report-All Donations” (Donations) ]

                                       
            •                          
            •                               

              End If

                                       
            •                          
            •                               

              If [ $$ReportFlag = "SID" ]

                                       
            •                          
            •                               

              Go to Layout [ “Report-SummaryIndividualTotals” (Donations) ]

                                       
            •                          
            •                               

              End If

                                       
            •                          
            •                               

              If [ $$ReportFlag = "ML" ]

                                       
            •                          
            •                               

              Go to Layout [ “Report-Mailing” (Donations) ]

                                       
            •                          
            •                               

              End If

                                       
            •                          
            •                               

              Print [ ]

                                       
            •                          
            •                               

              Go to Layout [ “Donors-List” (Donors) ]

                                            

              CheckForBothSearchDates

                                            
                                                   
              •                                         

                #-----Subscript for "PerformReportSearch". (Reconciled February 7, 2014.)

                                                   
              •                                    
              •                                         

                #-----Checks to see that both a StartDate and EndDate have been entered.

                                                   
              •                                    
              •                                         

                If [ Globals::gStartDate > "" and Globals::gEndDate = "" ]

                                                   
              •                                    
              •                                         

                Beep

                                                   
              •                               
                                       
            •                     
                                       
            •                               

              Show Custom Dialog [ Title: "BothDatesRequired"; Message: "An entry is required for BOTH a Start Date and an End Date. Press Add Dates to add dates or Cancel to stop report process."; Default Button: “Add Dates”, Commit: “No”; Button 2: “Cancel”, Commit: “No” ]

                                       
            •                          
            •                               

              If [ Get ( LastMessageChoice ) = 2 ]

                                       
            •                          
            •                               

              #-----CANCEL was clicked.

                                       
            •                          
            •                               

              Go to Layout [ “Donors-List” (Donors) ]

                                       
            •                          
            •                               

              Halt Script

                                       
            •                          
            •                               

              End If

                                       
            •                          
            •                               

              If [ Get ( LastMessageChoice ) = 1 ]

                                       
            •                          
            •                               

              #-----ADD was clicked.

                                       
            •                          
            •                               

              Go to Field [ Globals::gEndDate ]

                                       
            •                          
            •                               

              Halt Script

                                       
            •                          
            •                               

              End If

                                       
            •                          
            •                               

              End If

                                       
            •                          
            •                               

              If [ Globals::gStartDate = "" and Globals::gEndDate > "" ]

                                       
            •                          
            •                               

              Beep

                                       
            •                          
            •                               

              Show Custom Dialog [ Title: "BothDatesRequired"; Message: "An entry is required for BOTH a

                                            

              Start Date and an End Date. Press Add Dates to add dates or Cancel to stop report process.";

                                            

              Default Button: “Add Dates”, Commit: “No”; Button 2: “Cancel”, Commit: “No” ]

                                       
            •                          
            •                               

              If [ Get ( LastMessageChoice ) = 2 ]

                                       
            •                          
            •                               

              #-----CANCEL was clicked.

                                       
            •                          
            •                               

              Go to Layout [ “Donors-List” (Donors) ]

                                       
            •                          
            •                               

              Halt Script

                                       
            •                          
            •                               

              End If

                                       
            •                          
            •                               

              If [ Get ( LastMessageChoice ) = 1 ]

                                       
            •                          
            •                               

              #-----ADD was clicked.

                                       
            •                          
            •                               

              Go to Field [ Globals::gStartDate ]

                                       
            •                          
            •                               

              Halt Script

                                       
            •                          
            •                               

              End If

                                       
            •                          
            •                               

              End If

                                            

              EnterSubtitle

                                       
            •                     
                                       
            •                               

              #-----Subscript from "PerformReportSearch" script.

                                       
            •                          
            •                               

              New Window [ Name: "EnterSubtitle"; Style: Floating Document; Close: “Yes”; Minimize:

                                            

              “No”; Maximize: “No”; Zoom Control Area: “No”; Resize: “Yes” ]

                                       
            •                          
            •                               

              Show/Hide Toolbars [ Hide ]

                                       
            •                          
            •                               

              Move/Resize Window [ Current Window; Height: 490; Width: 720; Top: (Get

                                            

              ( WindowDesktopHeight ) / 4)-(Get(WindowContentHeight)/4)+50; Left: (Get

                                            

              ( WindowDesktopWidth )/2)-(Get ( WindowContentWidth ) / 2)+150 ]

                                       
            •                          
            •                               

              Go to Layout [ “EnterSubtitle” (Globals) ] 

                                       
            •                     

                  

            • 4. Re: Script works only with debugger
              philmodjunk

                   Looks like you need a Pause/Resume Script after the last line of EnterSubtitle. When you step through the script in the debugger, the debugger is pausing the script at every step anyway and it works, but without the debugger there's nothing in your script to pause so that a user can enter data and then resume the script.

                   An alternative approach is to end the script with the last line of EnterSubtitle. Then an "Ok" button on that layout can perform a script with the rest of your steps in it.