Select and copy before some text

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Select and copy before some text

Post by richmond62 » Sun Jan 31, 2021 4:08 pm

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10048
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Select and copy before some text

Post by FourthWorld » Sun Jan 31, 2021 5:02 pm

Your could set the itemdel to "acTL", and put item 1 into the other field.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Select and copy before some text

Post by richmond62 » Sun Jan 31, 2021 5:10 pm

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. :)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10319
Joined: Wed May 06, 2009 2:28 pm

Re: Select and copy before some text

Post by dunbarx » Sun Jan 31, 2021 5:17 pm

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

Post Reply