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

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
BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

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

Post by BarrySumpter » Sat Sep 24, 2011 9:29 am

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.
Last edited by BarrySumpter on Sat Sep 24, 2011 10:26 am, edited 1 time in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

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

Post by Dixie » Sat Sep 24, 2011 9:45 am

Barry...

Have a look at 'lineOffset' in the dictionary.

Dixie

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

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

Post by BarrySumpter » Sat Sep 24, 2011 10:25 am

Yep! Thats it! Much Appreciated!
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

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

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

Post by jmburnod » Sat Sep 24, 2011 10:26 am

Hi Barry,
See "replace" in LC dictionary also.

Best

Jean-Marc
https://alternatic.ch

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

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

Post by BarrySumpter » Sat Sep 24, 2011 11:49 am

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.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

Post Reply