5 Replies Latest reply on Jan 6, 2014 9:43 AM by philmodjunk

    Opening another file and performing a find request

    GaryVogt

      Title

      Opening another file and performing a find request

      Post

           This should be easy and I'm probably making it harder than it should be, but I can't get FM to open another file and perform a simple find. Here is the script.  It would be easier if I could copy from the script to here, but, alas, I can't.

           ------- while in the file the script is in, I touch a button to perform this script

           Copy [select; Annual::Customer Number]

           Open File [Customer data base]

           Enter Find Mode []

           Go to Field [Select/perform; Customer Data Base:: Customer Number]

           Paste [Select;  [Customer Data Base:: Customer Number]

           Pause/Resume Script [indefinitely]

           -------- I can't get it to open the find mode in Customer data base and paste the contents.

        • 1. Re: Opening another file and performing a find request
          philmodjunk

               Create a script in Customer Database like this:

               Go to Layout "Customer Data Base" (Customer Data Base ) ]

               Enter Find Mode []

               Set FIeld [Customer Data Base::Customer Number ; Get ( ScriptParameter ) ]

               Pause/Resume Script [indefinitely]

               Let's say you name that script "Find Records".

               Then modify your original script to be:

               Perform Script ["Find Records" from file: Customer Data base ; Parameter: Annual::Customer Number ]

               I am assuming that the file has the same name as your table. If not the text in blue will need to be changed to that of the file name. These scripts also leave any data previously copied to the clipboard intact--which will make your users happier with your database when data they may have copied doesn't disappear every time they run your find script.

          • 2. Re: Opening another file and performing a find request
            GaryVogt

                 So, what you are saying is that I need to run a script that is in the Customer Data Base?  And run that script from the initiating file?  Hmm.  Hadn't thought about that.  Seems counter-intuitive.  

                  

                 Thanks a million.

            • 3. Re: Opening another file and performing a find request
              philmodjunk

                   Scripts can only interact with windows from the same file as the script. But once upon a time, each FileMaker table had to be defined in a separate file. So FileMaker has long supported the ability to perform a script in File A from a Script in File B. The ability to pass data in a script parameter is a newer option that makes this work even more nicely than in the "old days" when we had to park data in a global field and use a relationship to retrieve it when the script in the second file began execution. (Yes, you could copy it to the clipboard like you've done here, but that wasn't the best way to do this back then either...)

              • 4. Re: Opening another file and performing a find request
                GaryVogt

                     As I was creating the script, deja vu happened.  35 years ago I wrote FORTRAN code.  I passed parameters in subroutines the same way.  That's awesome.  

                      

                     Thanks for your help

                • 5. Re: Opening another file and performing a find request
                  philmodjunk

                       Of course, in Fortran, you can define a whole set of parameters. FileMaker supports just one, but there are several ways you can use to combine values so that you can still send multiple parameter values to the Subscript.