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
Set Field [YourTable::Field2; Middle Words (gField1 ; $WordCount ; 1 ) ]
Exit Loop If [$wordCount > WordCount(gField1) ]
set Variable [$WordCount; Value: $WordCount + 1]
#Keep no records found dialog from appearing
Set Error Capture [on]
It works perfect:smileyhappy:
Thank you so much for the quick and perfect solution.
Have a wonderful weekend.
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?
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
Set Field [YourTable::Field2; Middle Words ($NumberList ; $WordCount ; 1 ) ]
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"]
Set Error Capture[On]
Perform Find [ ]
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.
Please ignore my last reply I figure out what was the problem.
It is working fine now.
Thanks for all the help.