Copy a string to a specific line in a fld (UTF8 safe)[Solved

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
atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Copy a string to a specific line in a fld (UTF8 safe)[Solved

Post by atout66 » Thu Apr 14, 2016 9:54 am

Hi to all,

My question is: How can I copy a string to a specific line in an other field ?
For example my script below can copy a specific line from the fld "laDefinition" but what to do if I want this line to by copied to line 3 of fld "laCible" ?

Code: Select all

copy line 4 of fld "laDefinition"
     focus on nothing
     focus on fld "laCible"
     if the clipboard is "text" then paste
Thanks in advance for your help, Jean-Paul.
Last edited by atout66 on Thu Apr 14, 2016 2:40 pm, edited 2 times in total.
Discovering LiveCode Community 6.5.2.

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Copy a string to a specific line in a fld

Post by AxWald » Thu Apr 14, 2016 10:47 am

Hi,

try:

Code: Select all

put 23 into myLiNum
put line 4 of fld "laDefinition" into line myLiNum of fld "laCible"
;-) Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Copy a string to a specific line in a fld

Post by atout66 » Thu Apr 14, 2016 11:04 am

Thanks AxWald, but it would be too simple like that :wink:

If I want to copy instead of to put one line of a fld to an other it's because the copy method preserves the unicode chars from one field to the other :!:
Discovering LiveCode Community 6.5.2.

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Copy a string to a specific line in a fld

Post by MaxV » Thu Apr 14, 2016 11:42 am

Do you like this?

Code: Select all

put line 4 of fld "laDefinition" into temp1
put line 1 to 3 of field "laCible" into temp2
put line 4 to -1 of field "laCible" into temp3
put temp2 & temp1 & return & temp3 into field "laCible"
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Copy a string to a specific line in a fld

Post by atout66 » Thu Apr 14, 2016 11:58 am

Yes I like it but it doesn't change the probleme :?
Let say for example you have this string below in a line of a field:

Code: Select all

blablabla şişkebap blablabla blablabla 
Now, try to do your method and you'll notice that you loose the char 1 and 3 of the word 2 which use UTF8 chars...

If you use the copy function instead, you keep all the chars as they are.
So as mentionned in my first post, I can copy a specific line of a field to an other field, but what to do to paste in a special line into the new field ?
"That is the question" like said someone before :wink:
Discovering LiveCode Community 6.5.2.

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Copy a string to a specific line in a fld (UTF8 safe)

Post by AxWald » Thu Apr 14, 2016 2:12 pm

Oooops,

missed the unicode thingie!

Doesn't matter, try this then:

Code: Select all

set the unicodetext of line 1 of fld "b" to the unicodetext of line 1 of fld "a"
:D

Have fun!

PS: Didn't get any method working with using the clipboard ...
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Copy a string to a specific line in a fld (UTF8 safe)

Post by atout66 » Thu Apr 14, 2016 2:39 pm

You've got it :D
Thanks a lot, lot lot and more :wink:
That's exactlly what I've been looking for since a while now.
Discovering LiveCode Community 6.5.2.

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Copy a string to a specific line in a fld

Post by MaxV » Thu Apr 14, 2016 2:47 pm

atout66 wrote:Yes I like it but it doesn't change the probleme :?
Let say for example you have this string below in a line of a field:

Code: Select all

blablabla şişkebap blablabla blablabla 
Now, try to do your method and you'll notice that you loose the char 1 and 3 of the word 2 which use UTF8 chars...
I don't loose any chars on windows. :?:
Livecode 7 supports unicode natively, so I don't need to use any other commands.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply