5 Replies Latest reply on Jul 2, 2013 7:24 AM by philmodjunk

    OnWindowOpen subtlety?



      OnWindowOpen subtlety?


           There seems to be a subtlety about the OnWindowOpen event that escapes me. Here's what I did:
           File X has two scripts:
           1) WindowOpenTrigger, which appends "WindowOpenTrigger" to a field named "stuff".
           2) AppendParamToStuff, which gets the ScriptParameter and appends it to stuff.

           X has a script trigger for OnWindowOpen; it calls the WindowOpenTrigger script.

           File Y has two scripts:
           1) OpenX, which is just Open File["X"]
           2) SayHelloAndOpenX, which Performs Script "AppendParamToStuff" in X with a parameter "Hello from Y", and then Open File["X"]

           Test 1
           I make sure stuff is empty, close both files, open Y, check that X does not appear in the Window menu, and run OpenX. As expected, stuff contains "WindowOpenTrigger".

           Test 2
           Same steps, but run SayHelloAndOpenX instead of OpenX. This time, stuff contains "Hello from Y" only. A window for Y has clearly been opened, but without the OnWindowOpen trigger being executed. How can this be?

        • 1. Re: OnWindowOpen subtlety?

               It would help to see a more detailed listing of the scripts. That allows us to rule out details--say with how the data is "appended" to stuff and also to recreate the issue if needed.

               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.
          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.
          5.           If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
          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.


               If you use opton 2. PLEASE edit the pasted text by inserting a few returns here and there so that each script step starts a new line.

          • 2. Re: OnWindowOpen subtlety?

                 Here you go:

                 ***SCRIPTS IN FILE X***
                 Set Field [ X::stuff; X::stuff & "WindowOpenTrigger" ]

                 Set Variable [ $param; Value:Get ( ScriptParameter ) ]
                 Set Field [ X::stuff; X::stuff & $param ]

                 ***SCRIPTS IN FILE Y***
                 Perform Script [ “AppendParamToStuff” from file: “X”; Parameter: "Hello from Y" ]
                 Open File [ “X” ]

                 Open File [ “X” ]

            • 3. Re: OnWindowOpen subtlety?

                   Been thinking about this one. It's always worked this way. In fact, this is the trick for forcing open a file where opening it the conventional whay traps the user in a script that can't be aborted and that closes the file or quits FileMaker.

              • 4. Re: OnWindowOpen subtlety?

                     Thanks for looking at this. I still think it's perverse to be able to open a file without triggering OnWindowOpen. Wouldn't the modern way of dealing with the situation you describe be Tools/Debugging Controls/Disable Script Triggers?

                • 5. Re: OnWindowOpen subtlety?

                       Yes, but this technique predates such an option as the ONFirstWindowOpen "trigger" existed before we had script triggers and FileMaker Advanced. I think this happens because the window isn't automatically activated by the perform script call from the other file.

                       The work around, BTW, is to have your script explicitly call the script you want to have triggered by this method.