5 Replies Latest reply on Apr 19, 2014 5:16 PM by philmodjunk

    Excess windows opened / hanging  / crashing to OS

    JonathanWexler

      Title

      Excess windows opened / hanging  / crashing to OS

      Post

           Using FMP v10 (Windows)

           Developing a script, which seems to be opening  a whole bunch of windows, and either hanging with the hourglass, or crashing to the OS (Windows).  I start with the window label (In top left corner) being <filename> and while running the script it progresses to about <filename>-75.  I am following advice I have read, but it is not working out for me. Anything obviously wrong (or could be done differently)?  Thanks for your help

           The script is as follows (text in red is explanation I have added for this post):

           DaveP Open Items
           #Empty script paramater turns on all column switches not yet    and selects "sort first by customer"
           #But first, we must get YTPM and MTD shipments, using the BobR layout
           #YTPM is year-to-prior-month; shipments are exclusive of shipping charges
           Set Field [ LineItems::DaveP_Open1_asOfDate; Get ( CurrentDate ) ] asOfDate is global
           New Window [ ]
           Freeze Window
           Set Variable [ $mtdShipments; Value:0 ]
           Set Variable [ $ytpmShipments; Value:0 ]
           Go to Layout [ “BobR Invoices” (Invoices) ]
           #Filter for current year
           Enter Find Mode [ ]
           Set Field [ Invoices::BobR_RevenueDate; ">="&Date(1;1;Year(LineItems::DaveP_Open1_asOfDate)) ]
           Perform Find [ ]
           View As [ View as Form ]
           Go to Record/Request/Page [ First ]
           Loop
           #Update MTD and YTPM
           If [ Month(Invoices::BobR_RevenueDate)<month(lineitems::davep_open1_asofdate)]
           Set Variable [ $ytpmShipments; Value:$ytpmShipments+Invoices::Job Total ]
           Else
           Set Variable [ $mtdShipments; Value:$mtdShipments+Invoices::Job Total ]
           End If
           Go to Record/Request/Page [ Next; Exit after last ]
           End Loop
           Enter Browse Mode this and the following worked before adding the piece above
           #Start working on report
           Go to Layout [ “DaveP Open Items” (LineItems) ]
           Perform Script [ “Filter Unshipped Line Items” ]
           #save totals for use in report
           Set Field [ LineItems::DaveP_Open1_otherStats; $ytpmShipments ]
           Set Field [ LineItems::DaveP_Open1_otherStats[2]; $mtdShipments ]
           If [ Get(ScriptParameter)="DueDate" ]
           Sort Records [ Specified Sort Order: LineItems_Invoices::Shipping Window End; ascending
           LineItems_Invoices::DaveP_Sales1_customer; ascending
           LineItems::Invoice Number; ascending ] [ Restore; No dialog ]
           Else
           Sort Records [ Specified Sort Order: LineItems_Invoices::DaveP_Sales1_customer; ascending
           LineItems::Invoice Number; ascending ] [ Restore; No dialog ]
           End If
           #Go to Preview mode for earlier versions which do not support summary reports in Browse mode.
           If [ GetAsNumber ( Substitute ( Get ( ApplicationVersion ); "."; "x" ) ) < 1000 ]
           Enter Preview Mode
           [ Pause ]
           Enter Browse Mode
           Go to Layout [ original layout ]
           End If

        • 1. Re: Excess windows opened / hanging  / crashing to OS
          JonathanWexler

               Woke up in middle of the night, realizing that I forgot the "Close Window [current window]" after the "End Loop", but adding this made no difference - same behavior. 

                

               I should also mention that the script is initiated at the "On layout enter" event associated with the "DaveP Open  Items"  layout used in the latter half of the script.  So maybe the script is getting triggered multiple times, but how else can all this get done???

               JonathanW

          • 2. Re: Excess windows opened / hanging  / crashing to OS
            JonathanWexler

                 Looks like PhilModJunk answered this in 2010 vis-à-vis "Script Trigger OnLayoutLoad triggers on exit when opening ..." Let me try the workaround suggested there.

                  

                 Thanks PhilModJunk

                 Jonathan

                  

            • 3. Re: Excess windows opened / hanging  / crashing to OS
              philmodjunk

                   Yes go to layout will trip the OnLayoutEnter trigger and produce an infinite loop here. Check and see if New Window might be tripping this same trigger as well.

                   I'm puzzled by many parts of your script.

                   What problem is solved by opening the new window?

                   Why are you using a looping script to compute totals that can be computed via relationships combined with either summary fields or aggregate functions?

              • 4. Re: Excess windows opened / hanging  / crashing to OS
                JonathanWexler

                     PhilModJunk

                     Yes, you commented in 2010 that NewWindow had the effect of reopening the layout of the previously current window.

                     And I did this as a loop because

                     1) I am desperate to try to manage the "schema footprint" (this is a 15 year-old data base, poorly designed and suffering from too many workarounds/additions/abandoned_efforts/simple_mistakes as is).

                     2) the logic is likely to get even more convoluted.

                     Thanks

                     JonathanW

                • 5. Re: Excess windows opened / hanging  / crashing to OS
                  philmodjunk

                       But why open the new window at all? (There can be very good reasons to do so. I am checking to see if you really need to do that or if you can simplify your life by not opening a new window.)

                       1) It might avoid adding more table occurrences, but is much slower (possibly 10xs or more and much more complex a way to get this done.) In my opinion you are adding 1 to 2% complexity to your database relationship in place of a many times more complex method and one that is much slower.

                       Plus, if you are using FileMaker 12 or newer, you can compute these two totals without adding any additional table occurrences and relationships as you can use ExecuteSQL() with an aggregate function to compute these two totals.

                       2) The logic is likely to be be even more convoluted? That might be the case as I cannot see all the details involved here, but from what I can see, it does not look even close to that to me.