3 Replies Latest reply on Mar 1, 2011 6:58 AM by james.gould

    Copy/paste? Opinions?



      Copy/paste? Opinions?




      I was speaking with a friend the other day-he's a DB developer (not Filemaker) and he mentioned that he NEVER used the OS clipboard. When I look at my solutions I see I can avoid copy and paste almost entirely by using optional script parameters (which work across files) and by setting variables (in a script running entirely in one file) and finally using the SetField step in Find mode. This seems a much more efficient method than having "copy" script steps and then pasting while in find mode, and I'm quite comfortable with these methods. What I'm wondering: is avoiding the OS clipboard advisable in general? NOT using copy/paste in scripts can certainly reduce the number of scripts and the number of steps within a script. Ideas?



        • 1. Re: Copy/paste? Opinions?

          Once upon a time, Copy and paste were the only way to move data from field to field in Filemaker Pro. They have, in my opinion, been retained ever since to provide backwards compatibility to older solutions. Given the many improvements to FMP's capabilities, I NEVER user copy and paste if I can possibly find an alternative. When you use these steps you encounter the following issues:


          1. The source (copy from) and target (paste to) fields must be present on the layout at the instance the script step executes or the script step will "Fail Silently". That means the data will not be copied/pasted, but no error message of any kind appears to tell the user that the step did not do what you expected it to do.
          2. Copy/Paste replaces the contents of the OS clipboard with the copied data, this frustrates users when they copy data to the clipboard and then the data they copied mysteriously changes into something else.


          • 2. Re: Copy/paste? Opinions?

            I have failed to run across a somehat in depth explanation of how to use these alternate ways i am new to Fm and running the Fm 11 pro. For some reason i cant wrap my mind around the references to say move the id muber in one field to another table without the cut paste, any help please thanks in advance

            • 3. Re: Copy/paste? Opinions?

              If you have the field Contacts::ContactID and need to place a copy of it in Invoice::CustomerID (or any fields for that matter):


              Set Variable[$id ; Value:Contacts::ContactID]

              Go To Layout[Invoice]

              Set Field [Invoice::CustomerID; $id]


              In the example above, the variable $id (as with the fields the name is not important) replaces the clip board - the Set Variable script step "copies" the values of Contacts::ContactID into $id. You can then "paste" the value of $id into any other field(s) later in the script... But filemaker does this without interfering with the OS clipboard. Another advantage of using variables is that you can have as many as you need, if for example you need to collect various IDs from other tables in your DB.

              e.g. A new project needs a customer and a supplier.


              Set Variable[$cust ; Value:Customer::CustomerID]

              Go To Layout[Suppliers]

              Perform Find*

              Set Variable[$sup ; Value:Supplier::SupplierID]

              Go To Layout[Projects]

              New Record/Request

              Set Field [Projects::CustomerID; $cust]

              Set Field [Projects::SupplierID ; $sup]


              *this step would either take user input to find a suitable supplier or find a supplier based on preset find requests.

              Hope this helps.