6 Replies Latest reply on Nov 30, 2010 5:29 PM by Sewlong

    how would I write this calculation / script

    marco96

      Title

      how would I write this calculation / script

      Post

      I know I should know this by now, but this is all still pretty deep for me. From a script, I suppose, how do I say-  if "invoices" is open bring it to the front. If not open "invoices"

      I mean how exactly do I write this script?

       

      I'm guessing that from a script I click on the "if" script. But after that I am just not sure if I can finish it by just typing it in or I think I will need to click on the "else" as well.

       

      Do I do this from a calculation window or straight from the script window?

       

      Thanks for any help

       

      Marco

        • 1. Re: how would I write this calculation / script
          LaRetta_1

           


          marco96 wrote:

          ... how do I say-  if "invoices" is open bring it to the front. If not open "invoices"


           

          Hi Marco, I'm unsure what makes an invoice 'open' but here is the basic concept - You want to find all Open Invoices (assuming they have a Status = Open).  Create a "Find Open Invoices" script similar to:

           

          Go To Layout [ layout based upon your invoices ]

          Enter Find Mode [ uncheck pause ]

          Set Field [ your Status Field ; "Open" ]

          Set Error Capture [ On ]

          Perform Find [ ]

          If [ Get ( LastError )  ]

          Show Custom Dialog [ OK ; "No records found." ]

          Go To Layout [ Original Layout ]

          Exit Script

          End If

          ... you now have a found set of open invoices.

           

           

           


          • 2. Re: how would I write this calculation / script
            comment_1

            My guess would be:

             

            Open File [ "Invoices" ]

            • 3. Re: how would I write this calculation / script
              marco96

              Hi LaRetta,

              My file name is invoices, and  I was wondering how to write the script to bring the window forward if it is open (behind one of the other window) and if it is not open already then open the file called "invoices".

               

              Marco

              • 4. Re: how would I write this calculation / script
                Sewlong

                I am having the same issue, if I already have a window with a specific name open I would simply like to choose that window, if that window does not exist yet, I would like to create it. 

                I am using FMPro 11 advanced on Windows 7

                I have tried a few variations of the following script without much luck 

                If  - WindowNames ( Get ( FileName ) ) = "Employee"

                            Select Window [Name: "Employee"]

                ElseIf - WindowNames ( Get ( FileName ) )  ≠  "Employee"    

                            New Window [Name: "Employee"]

                Any information is appreciated! 

                • 5. Re: how would I write this calculation / script
                  philmodjunk

                  WindowNames is a return separated list of all open FileMaker windows for the specified file. Thus, WindowNames ( Get ( FileName ) )= "Employee" will only be true if "Employee" is the only window open for that file.

                  Try testing with the FilterValues function:

                  IsEmpty ( FilterValues ( WindowNames ( Get ( FileName ) ) ; "Employee" ) )

                  will be true if Employee is not open and false if it is.

                  • 6. Re: how would I write this calculation / script
                    Sewlong

                    PHIL THANK YOU!

                    I had a feeling I may have something to do with the fact that it may not match exactly.

                    I do not fully understand the FilterValues yet, but it is starting to sink in, nevertheless it works, and solves a problem I have wanted to overcome fro quite some time!

                    Thank you again!

                    SewLong