Page 1 of 1

Select and copy before some text

Posted: Sun Jan 31, 2021 4:08 pm
by richmond62
What am I missing?

I have a field called "PICC" that conatins text including the chunk "acTL".

I wish to copy ALL the text before the chunk "acTL" and dump it into another field.

Code: Select all

on mouseUp
   find string "acTL" in fld "PICC"
   set the traversalOn of fld "PICC" to true
select before foundChunk of fld "PICC" --this is a load of rubbish and does not work
   copy the selected text
   paste into fld "SOMEWHEREelse"
   end mouseUp

Re: Select and copy before some text

Posted: Sun Jan 31, 2021 5:02 pm
by FourthWorld
Your could set the itemdel to "acTL", and put item 1 into the other field.

Re: Select and copy before some text

Posted: Sun Jan 31, 2021 5:10 pm
by richmond62
FourthWorld wrote:
Sun Jan 31, 2021 5:02 pm
Your could set the itemdel to "acTL", and put item 1 into the other field.
Brilliant. Thanks. :)

Re: Select and copy before some text

Posted: Sun Jan 31, 2021 5:17 pm
by dunbarx
Richard's way is the best way, in my opinion.

But to follow the thread of your original thinking. if you have two fields and a button, and some text with your "acTL" buried in field 1, and this in the button script:

Code: Select all

on mouseUp
get offset("actl",fld 1)
put char 1 to (it - 1) of fld 1 into fld 2
 end mouseUp
Craig