Page 1 of 1

Search for a word in a line, replace or delete that line?

Posted: Sat Sep 24, 2011 9:29 am
by BarrySumpter
Hi all,

I've got a local variable with a bunch of text lines in it.

I'd like to search for a word and either remove or replace that line.

I could have sworn it was to do with lineDelimiter then
replace line
or delete line

But can't seem to get it to work.

Any help would be greatly appreciated.

Re: Search for a word in a line, replace or delete that line

Posted: Sat Sep 24, 2011 9:45 am
by Dixie
Barry...

Have a look at 'lineOffset' in the dictionary.

Dixie

Re: Search for a word in a line, replace or delete that line

Posted: Sat Sep 24, 2011 10:25 am
by BarrySumpter
Yep! Thats it! Much Appreciated!

Re: Search for a word in a line, replace or delete that line

Posted: Sat Sep 24, 2011 10:26 am
by jmburnod
Hi Barry,
See "replace" in LC dictionary also.

Best

Jean-Marc

Re: Search for a word in a line, replace or delete that line?

Posted: Sat Sep 24, 2011 11:49 am
by BarrySumpter
No wonder I couldn't remember it.

Code: Select all

put lineOffset(tFindWhichWord, MyData) into tWhichLineFound
if tWhichLineFound > 0 then
    put myNewLine into line tWhichLineFound of MyData    -- Replaces the line
end if
So freakin simple.

I have to write that lineOffset is so weird and hard to remember for me.
But that's LiveCode.