14 Replies Latest reply on May 2, 2016 5:39 AM by tays01s

    Startup

    tays01s

      I'm trying to ensure my solution opens on the 'Home' window or 'Home | open' if there isn't a license but I always get a generic window + the Home window. I've set File options > Script triggers (tried both OnFirst or just OnWindowOpen) to NST Startup script:

       

      If [ Home::Account = "Full access" ]

      Perform Script [ “Home” ]
      Else If [ Home::License_ID Home::License_ID_decryp ]

      Perform Script [ “Home | open” ]

      Else

      Perform Script [ “Home” ]

      End If

       

       

      and the Home script is:

      If [ not IsEmpty(FilterValues (WindowNames;"Home")) ]

      Select Window [ Name: "Home"; Current file ]

      Else

      New Window [ Style: Document; Name: "Home"; Height: 495; Width: 333; Top: 0; Left: 0; Close: Yes; Minimize: Yes; Maximize: Yes; Zoom Control Area: Yes; Resize: Yes ]

      #Need to create a 'Front_small' layout with scripts/buttons leading to smaller layouts.

      Go to Layout [ “Home_U” (Home) ]

      End If

      Set Zoom Level [ 100%; Camera: Back; Resolution: Full ]

      Perform Script [ “Window_format” ]     (just ensures formatting bar/ ruler etc don't show)

       

        • 1. Re: Startup
          siplus

          You might have more than one record in your Home table and sitting right on it, with an empty License_ID field.

          • 2. Re: Startup
            electon

            Could it be that the full access account myst be "[Full Access]" in square brackets?

            That's how FileMaker names this account by default.

            • 3. Re: Startup
              electon

              That is if you rely on Get ( AccountPrivilegeSetName ) for this one.

              • 4. Re: Startup
                erolst

                tays01s wrote:

                 

                If [ Home::Account = "Full access" ]

                Perform Script [ “Home” ]
                Else If [ Home::License_ID Home::License_ID_decryp ]

                Perform Script [ “Home | open” ]

                 

                […]

                 

                 

                and the Home script is:

                If [ not IsEmpty(FilterValues (WindowNames;"Home")) ]

                Select Window [ Name: "Home"; Current file ]

                 

                Note that you could simplify your logic and processes in both scripts:

                 

                If [ Get ( AccountPrivilegeSetName ) = "[Full Access]" or Home::License_ID = Home::License_ID_decryp ]

                  Perform Script [ “Home” ]

                Else

                  Perform Script [ “Home | open” ]

                End If

                 

                and

                 

                Set Variable [ $homeWindowTitle ; "Home" ]

                If [ not IsEmpty ( FilterValues ( WindowNames ; $homeWindowTitle ) ) ]

                  Select Window [ Name: $homeWindowTitle ; Current file ]

                Else

                  New Window [ Style: Document; Name: $homeWindowTitle ; ………

                • 5. Re: Startup
                  tays01s

                  Thanks. Just to answer points:

                  1. There's only 1 Home record.

                   

                  2. I've tried switching to Get ( AccountPrivilegeSetName ) = "[Full Access]" etc, but still get 2 windows.

                   

                  3. Re. modifying the last (Home) script I don't quite get how it simplifies the script?

                   

                  Overall, I've still to stop the initial generic window appearing. NB. I've noticed that Kiosk mirrors the FM file at closing. But I have closed everything but the Home window prior to closing the file then creating the Kiosk mode Runtime.

                  • 6. Re: Startup
                    electon

                    So where does the script fail? Did you step through it?

                    I imagine it must be quite easy to debug.

                     

                    tays01s wrote:

                    Overall, I've still to stop the initial generic window appearing. NB. I've noticed that Kiosk mirrors the FM file at closing. But I have closed everything but the Home window prior to closing the file then creating the Kiosk mode Runtime

                     

                     

                     

                     

                    The fact that you closed the solution with the Home layout does not mean next time you open it the window will still be called Home. This you setup at the beginning of the startup script.

                    Maybe what you need is Get ( LayoutName ) = "Home"

                     

                    The initial generic window ( check in FileOptions / Go To Layout "" ) maybe you set it to open with a specific layout.

                    • 7. Re: Startup
                      tays01s

                      Script debugger: With this on prior to opening the file, it shows that a generic window is opened before the first line of the script has been executed.

                       

                      I've tried inserted a 1st line into the script: Go to layout (Get(layoutname) = "Home"

                      but still end up with 1 generic window and 1 "Home" window.

                       

                      File options > Switch to layout: This wasn't checked, but if I specify "Home", again, I get 1 generic/ 1 Home windows.

                       

                      BTW, though it hasn't made any difference, should my script trigger be 'on window' or 'onfirst window'?

                      • 8. Re: Startup
                        tays01s

                        PS. I should have said, I very much don't want a generic window, because the startup script is meant to prevent Users getting into the solution if they've received an illegal copy whose license doesn't match their hardware/details.

                        • 9. Re: Startup
                          electon

                          tays01s wrote:

                           

                          Script debugger: With this on prior to opening the file, it shows that a generic window is opened before the first line of the script has been executed.

                          That's normal behavior and unavoidable. You will always land on some layout when opening the solution.

                          tays01s wrote:

                           

                           

                          I've tried inserted a 1st line into the script: Go to layout (Get(layoutname) = "Home"

                          but still end up with 1 generic window and 1 "Home" window.

                          That's normal too, but because your script is looking for a window name "Home" and not layout name "Home" it will always create a new window. If you don't rename your window at startup it will default to the file name.

                          tays01s wrote:

                           

                           

                          BTW, though it hasn't made any difference, should my script trigger be 'on window' or 'onfirst window'?

                          OnFirstWindowOpen

                           

                           

                           

                          You need to rethink what the workflow is.

                          And I think you are confusing window name with layout name.

                          • 10. Re: Startup
                            tays01s

                            Workflow: It's probably best I land on the 'File | Open' layout so that's now what I've specified from File option > Switch to layout. The script then needs to check the license before potentially opening the solution via the Home Window.

                             

                            OnFirstWindownOpen: is now the Startup script trigger.

                             

                            Window/layout name: I really wasn't sure what you were suggesting to do with it? The problem seems to be that I land on a 'now specified' layout, but how do I transform this into a named Window so that I can decide it 'fate'?

                            • 11. Re: Startup
                              electon

                              Set Window Title is the step.

                               

                              In order for this to work it should be based on the Home table so you can check the account and license.

                              Then you decide if you need to open a new window.

                               

                              Your script logic is:

                               

                              If there's no window named Home then create one.

                              So you end up with two windows.

                              • 12. Re: Startup
                                tays01s

                                Yes, that's what I've got. However, does this mean there's no way to name and close the original window? I'd like to do this in part because it's tidier, but also to avoid accidential interference with the license.

                                • 13. Re: Startup
                                  electon

                                  It's confusing at best what you're trying to achieve.

                                   

                                  There is a way:

                                  But you fist need to create a new window before you close the other one. Otherwise you will close the file.

                                  So your starting window should not be called "Home".

                                   

                                  Name it "Startup" or something else than "Home"

                                   

                                  Before you create the new window set the current window name to a variable:

                                  Then do:

                                  New Window [ with a name "Home" ]

                                  Close Window ["Startup"]

                                   

                                   

                                   

                                  I think what you're trying to do is this:

                                   

                                  Upon opening the file check for license:

                                  If there's no license, open a new window for some reason to do what? but close the first window.

                                  Why not just use the same window and switch layouts? OK you find it better like that, no problem.

                                  • 14. Re: Startup
                                    tays01s

                                    Apologies for not making it clearer, but your deduction of my intent was correct and the method suggested worked; it's a neat startup now.

                                     

                                    Thanks,

                                    Stephen