Page 1 of 1

Remove whitespaces after second comma

Posted: Wed Jan 26, 2011 5:28 pm
by richh
Ok... so I have been curious to see how powerful LiveCode is when Text manipulation. I am still getting my barrings straight with documentation and syntax.

lets say I have a string like this

Code: Select all

put "this, is,      a, test" into sString

now, I want to go ahead and remove the white spaces after the second comma

I was looking at the documentations for LTRIM or TRIM but did not see anything. Suggestions on how to do this in LiveCode?

TIA

Re: Remove whitespaces after second comma

Posted: Wed Jan 26, 2011 5:43 pm
by Klaus
Hi Rich,

ONE way is this:
...
replace SPACE with empty in item 3 of tString
...
Yep, you might need get used to this "natural" approach :D


Best

Klaus

Re: Remove whitespaces after second comma

Posted: Wed Jan 26, 2011 5:49 pm
by richh
Klaus,

your becoming my hero :)

thank you again.

Re: Remove whitespaces after second comma

Posted: Wed Jan 26, 2011 5:57 pm
by Klaus
I feel flattered! :oops:

But not too much, I work with LiveCode (and its ancestors MetaCard/Revolution)
since 1999 and it would be a shame if I could not answer this 8)


Best

Klaus

Re: Remove whitespaces after second comma

Posted: Wed Jan 26, 2011 6:01 pm
by doc
Nice one, Klaus! :)

@Rich
A few words of encouragement...
Learning LiveCode from *any* BASIC-like language perspective can be daunting at first ...but hang in there.
(nothing works quite like you think it should)

Nothing comes close to LiveCode when it comes to easy and powerful text processing. Absolutely nothing!
Once you get the hang of it, you won't want to use anything else and syntax like LTRIM or TRIM will become almost foreign to you.

-Doc-

Re: Remove whitespaces after second comma

Posted: Wed Jan 26, 2011 6:08 pm
by Klaus
Hi Rich,

I also strongly recommend to check these stacks here:
http://www.runrev.com/developers/lesson ... nferences/


Best

Klaus

Re: Remove whitespaces after second comma

Posted: Wed Jan 26, 2011 6:29 pm
by wsamples
Yes, the amount of help that Klaus provides the community makes him one of its greatest assets.

I see he has removed my incomplete (and therefore broken and misleading) repeat loop :D, although I was coming back to fix it.

Anyway... Klaus's first example removes all spaces in the third item, which may not be what you want, so if you use

Code: Select all

replace "  " with "" ...
you will get the modification you are looking for (provided there isn't another double space in there that you would like to preserve!).

Re: Remove whitespaces after second comma

Posted: Wed Jan 26, 2011 7:11 pm
by Klaus
wsamples wrote:...I see he has removed my incomplete (and therefore broken and misleading) repeat loop :D, although I was coming back to fix it.
Really? Where and when? :shock:

Re: Remove whitespaces after second comma

Posted: Wed Jan 26, 2011 7:32 pm
by richh
Thank you all for your responses....

When I was learning to program in RB, it took me a while to understand OOP and how to "think different" compared to liner programming. As doc said, LiveCode will take some getting used to and will continue to read as much documents as I can.

I am very close to making a decision on purchasing LiveCode. I have emailed the development team and waiting response concerning licensing and what I am entitled to. I have been on the hunt for a second language to put in my back pocket and I hope LiveCode is it.

Moving forward, I am hoping to press my luck one more time with removing white spaces....

if I had a line that was "this$ is $ a $ test"

like before, if I wanted to remove the white spaces in item 3, how can I tell LiveCode to use $ as a delimiter?

Re: Remove whitespaces after second comma

Posted: Wed Jan 26, 2011 7:36 pm
by wsamples
It wasn't you??? :lol: I just assumed it was you, wearing the Mod hat... In any event, my feelings weren't hurt; what I had posted was seriously flawed and definitely not going to help anyone! Whoever deleted it couldn't have known I would catch it and come back to try to correct it.

(I had been distracted and I suppose it's possible my carelessness could have been so extreme that I didn't realize I had never successfully posted it :roll: )

Re: Remove whitespaces after second comma

Posted: Wed Jan 26, 2011 7:47 pm
by Klaus
Hi Rich,
richh wrote:...how can I tell LiveCode to use $ as a delimiter?
...
set the itemdel to "$"
## itemdel = short for itemdelimiter
...
You can define ANY single character as an itemdelimiter, which is a wonderful thing

@wsamples
No, that surely wasn't me!
I know how to differ Viagra Ads from "real" postings" :D


Best

Klaus