7 Replies Latest reply on Jan 25, 2010 10:38 AM by aria

    Copy from a field with are comma delimiters numbers

    aria

      Title

      Copy from a field with are comma delimiters numbers

      Post

      Hi all,

      We have a field that will be populated by users “Copy and pasting” bunch of numbers that are comma delimiters.
      What we trying to do is to copy each number into a targeted “field2”  field and issu new record and copy the next numbers into the field 2 again. Here are the steps:

      1.Enter find mode
      2. users manually paste bunch of comma delimiters numbers such as: 213, 2133, 2144, 2177, 2199, 2100 into” field1”
      3. Then paste 213 into filed2.
      4. New Record/Request
      5. Then paste 2133 into filed2.
      6. New Record/Request
      7. Then paste 2144 into filed2.
      Repeat the same step over over until no more number left in the” field1”
      8. Once there is no more number left in field1 then
      9. Perform find.
      Is this possible with FileMaker  scripts
      Please advice,

      Thanks in advance,

       

       

      A






        • 1. Re: Copy from a field with are comma delimiters numbers
          philmodjunk
            

          Define a global field, gField1,  to receive the pasted list. (Global storage is a field option you can bring up by double clicking the field definition in Manage | Database | Fields.)

           

          Users would paste into the global field and then run this script:

           

          Set Variable [$WordCount; Value: 1]

          Enter Find Mode[]

          Loop

            Set Field [YourTable::Field2; Middle Words (gField1 ; $WordCount ; 1 ) ]

            Exit Loop If [$wordCount > WordCount(gField1) ]

            New Record/request

            set Variable [$WordCount; Value: $WordCount + 1]

          End Loop

          #Keep no records found dialog from appearing

          Set Error Capture [on]

          Perform Find[]

          • 2. Re: Copy from a field with are comma delimiters numbers
            aria
              

            Hi Phil,

             


            It works perfect:smileyhappy:
            Thank you so much for the quick and perfect solution.

            Have a wonderful weekend.

             

             

            A

            • 3. Re: Copy from a field with are comma delimiters numbers
              aria
                

              Hi Phil,


              Sorry to say that it is not inserting any numbers into the targeted field “field2” at all.
              At the end of the script it will returns “finds” all the records from the table, not the one that we inserted in to the field1.
              So basically it is not coping and pasting any of the numbers from filed1 to field 2 at all.

               


              Any idea  why?

               

               

              Thanks,


              • 4. Re: Copy from a field with are comma delimiters numbers
                philmodjunk
                  

                Did you define gField1 to be a text field with Global Storage? If it isn't global, the script won't work as written. If you want the field where you paste the number list to be a normal local field, modify the script this way:

                 

                Set Variable[$NumberList; yourTable::Field1]

                Enter Find Mode[]

                Loop

                  Set Field [YourTable::Field2; Middle Words ($NumberList ; $WordCount ; 1 ) ]

                • 5. Re: Copy from a field with are comma delimiters numbers
                  aria
                    

                  Phil

                  Yes ,

                  gField1 is a text field with Global Storage. I also updated the script, but now when I run it, the number 3133 gets copy and paste twice from gfield1 into Fieled2, then the "Perform Find" script get executed, and the script ignores the rest of numbers.

                  Below is the script:

                  Set Variable [$NumberList; Value:index::gfield1]

                  Enter Find Mode [ ]

                  Loop Set Field[index::field2; MiddleWords ($NumberList ; $WordCount ; 1 )]

                  Exit Loop If [$wordCount≥WordCount(index::gfield1)]

                  New Record/Request Set Variable [$wordCount; Value:"WordCount + 1"]

                  End Loop

                  Set Error Capture[On]

                  Perform Find [ ]

                   

                   

                  Any idea?

                  Thansk,

                  A

                  • 6. Re: Copy from a field with are comma delimiters numbers
                    philmodjunk
                      

                    The "word" text functions look for punctuation to separate words out of a larger text field. Your original post shows a list of numbers each separated by a comma and a space. The script should work correctly (and you shouldn't need the second version of this script for a field with global storage, though that version should still run correctly.) as long as that is the case.

                     

                    I think I see the typo:

                    Set Variable [$wordCount; Value: WordCount + 1"]

                     

                    Change it to Set Variable [$wordCount; Value: $WordCount + 1]

                    (remove the quotes and add the dollar sign)

                     

                    and it should work.

                    • 7. Re: Copy from a field with are comma delimiters numbers
                      aria
                         Hi Phil,
                      Please ignore my last reply I figure out what was the problem.
                      It is working fine now.
                      Thanks for all the help.
                       
                      A