Hi !
I'm completely new to Livecode, and I've been experimenting with it since 1 week, I have to do something with my program, but I don't know how to ! I've searched and I've found nothing. So, I have a field and I would like to have something that do the following : If there's a backslash in a string in that field, let's double it up. So an address like FOLDER\FILE\FILE becomes FOLDER\\FILE\\FILE. Do anyone have an idea on how to do that ?
Doubling a character inside a field !
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 2
- Joined: Sun Dec 28, 2014 5:49 pm
- Contact:
Re: Doubling a character inside a field !
Hi Frederic,
1. welcome to the forum!
2. So you want to replace / with // in your field, right?
Since we are talking about Livecode, you can simply:
...
repace "\" with "\\" in fld "xyz"
...
3. You might be interested in these great learning resources:
http://www.hyperactivesw.com/revscriptc ... ences.html
Best
Klaus
1. welcome to the forum!

2. So you want to replace / with // in your field, right?
Since we are talking about Livecode, you can simply:
...
repace "\" with "\\" in fld "xyz"
...

3. You might be interested in these great learning resources:
http://www.hyperactivesw.com/revscriptc ... ences.html
Best
Klaus
Re: Doubling a character inside a field !
And just in case you already have \\ in the field somewhere, you don't want to end up with \\\\:
put field "xyz" into tData
replace "\\" with "not_to_be_duplicated" in tData
replace "\" with "\\" in tData
replace "not_to_be_duplicated" with "\\" in tData
put tData into field "xyz"

put field "xyz" into tData
replace "\\" with "not_to_be_duplicated" in tData
replace "\" with "\\" in tData
replace "not_to_be_duplicated" with "\\" in tData
put tData into field "xyz"

Re: Doubling a character inside a field !
Hi.
Isn't LC great?
But it made me think that there should be a way to create a general function, which changes any string of "/" of any length into "//". So even if you had:
"xx/xx//xx///////xx" you would get "xx//xx//xx//xx". You don't have to worry about the number of "/" strings or their length.
Craig
Isn't LC great?
But it made me think that there should be a way to create a general function, which changes any string of "/" of any length into "//". So even if you had:
"xx/xx//xx///////xx" you would get "xx//xx//xx//xx". You don't have to worry about the number of "/" strings or their length.
Code: Select all
on mouseUp
put replaceText(fld 1,"/*/","//") into fld 1
end mouseUp
-
- Posts: 2
- Joined: Sun Dec 28, 2014 5:49 pm
- Contact:
Re: Doubling a character inside a field !
Thank you for all your answers !
I'm really enjoying livecode because it's much simplier for me than trying to do C++ and other things. It gave me a headache in like 1 hour. I've got to make a Client for a Server which communicate via Telnet (so sockets), and I found that Livecode was the solution ! So thank you guys !
I'm really enjoying livecode because it's much simplier for me than trying to do C++ and other things. It gave me a headache in like 1 hour. I've got to make a Client for a Server which communicate via Telnet (so sockets), and I found that Livecode was the solution ! So thank you guys !