How to swap text from 2 text fields

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
ivaho
Posts: 37
Joined: Tue Feb 14, 2012 2:19 pm

How to swap text from 2 text fields

Post by ivaho » Fri Nov 23, 2012 12:01 pm

Hi,

I have to text fields containg names.
What i want to do is selecting two names in the different text fields and than swap those names.

Kind regards Ivo

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: How to swap text from 2 text fields

Post by jmburnod » Fri Nov 23, 2012 1:01 pm

Hi Ivaho,
Something like that ?

Code: Select all

on swapLines
   put the hilitedlines of fld 1 into tHi1
   put the hilitedlines of fld 2 into tHi2
   if tHi1 = empty or tHi2 = empty then exit swapLines
   put line tHi1 of fld 1 into tCont1
   put line tHi2 of fld 2 into tCont2
   put tCont1 into line tHi2 of fld 2
   put tCont2 into line tHi1 of fld 1
end swapLines
Kind regards
Jean-marc
https://alternatic.ch

ivaho
Posts: 37
Joined: Tue Feb 14, 2012 2:19 pm

Re: How to swap text from 2 text fields

Post by ivaho » Fri Nov 23, 2012 6:51 pm

thanks for your help

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to swap text from 2 text fields

Post by Klaus » Fri Nov 23, 2012 7:12 pm

Hi Ivo,

hint: Jean-Marcs solution will only work with LIST fields!


Best

Klaus

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: How to swap text from 2 text fields

Post by jmburnod » Fri Nov 23, 2012 8:34 pm

Hi Klaus,
Selecting two chunks in two different fields is possible ? :shock:
Best
Jean-Marc
https://alternatic.ch

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to swap text from 2 text fields

Post by Klaus » Sat Nov 24, 2012 1:03 pm

Hi Jean-Marc,

yes, I tested this and was also surprised :D

The trick is to uncheck "traversal on" for the fields, but then you cannot write into the fields, so it is in fact useless 8)
However you can put text into these fields by script and THEN you can have a selection in each field by doucleclicking words.

So this is of doubtful use...


Best

Klaus

Post Reply