6 Replies Latest reply on Mar 4, 2010 9:13 AM by carolynhaywood

    Trouble coping and pasting in script

    carolynhaywood

      Title

      Trouble coping and pasting in script

      Post

      I have a script that is supposed to copy a field and paste into another - it does this 2 for different fields.  I have FMP 10 advanced with the debugger.  I notice when running the scripts that the copy and paste function is not working.  Anyone know why?

       

      Thanks,

      Carolyn Haywood

      FMP 10 Advanced Mac 6.3.2

        • 1. Re: Trouble coping and pasting in script
          RickWhitelaw

          It could be that the source field for "copy" is empty and is therefore pasting nothing. This is just one of the many reasons to avoid using copy and paste in scripts. With the ability to pass optional script parameters and create variables, coupled with Set Field, it really is a good idea to avoid using the clipboard. Another example would be having FM running a script, perhaps a scheduled script, and you're working on a text document in another application. Copying and pasting is very common when working on text documents. So you copy a phrase to the clipboard and a second later FM uses the contents of the clipboard to paste . . . not good! Someone here said "leave the copying and pasting to the user" and keep it out of scripts whenever possible. I believe it's always possble.

           

          RW

          • 2. Re: Trouble coping and pasting in script
            LaRetta_1

            In addition to Rick's good input, the primary reason a paste script-step could fail is that it requires that the field be on the layout.  Set Field[] has no such requirement.

            • 3. Re: Trouble coping and pasting in script
              carolynhaywood

              Thanks for your good advice.  Set Field only works with related tables, correct?  I'm trying to get info from a table to an unrelated table.  I figured out why it wasn't copying and pasting - There were some script errors (set fields with no relationship) so it skipped the copy and paste commands for some reason.   I'm going to post my bigger problem so I can, hopefully, omit the copy and paste steps.

               

              Thanks again,

              Carolyn Haywood

              Beginner User

              • 4. Re: Trouble coping and pasting in script
                mrvodka

                The values should be stored temp in a variable. The  script would be like such:

                 

                Set Variable [ $FirstName; FirstName ]

                Set Variable [ $LastName; LastName ]

                Go to Layout [ LayoutofOtherTable ]

                Set Field [ FirstName; $FirstName ]

                Set Field [ LastName; $LastName ]

                 

                 

                You can go to a layout of the unrelated table.

                 

                • 5. Re: Trouble coping and pasting in script
                  carolynhaywood

                  Thanks!  Maybe this will solve my problem!  Fingers crossed.

                   

                  Carolyn Haywood

                  Beginner

                   

                  I know just enough to be dangerous.

                  • 6. Re: Trouble coping and pasting in script
                    carolynhaywood

                    Thank you for your help.  With a lot of careful thinking and using the set field instead of pasting, I was able to solve my problem.  I think I had a complex problem - I wanted to create a new job and a new invoice at the same time, see them both on a portal, then switch to a detail tab that contained more info about that particular job in the list.  I was able to do it on one layout where I only needed to create one thing but adding the new twist of creating something else was hard for me.

                     

                    But the SET FIELD worked perfectly!

                     

                    Thanks,

                    Carolyn Haywood

                    Beginner