Find a text in a list

Jan Schenkel janschenkel at yahoo.com
Tue Dec 16 17:12:17 CST 2003


--- Yves COPPE <yvescoppe at skynet.be> wrote:
> Hi,
> 
> 
> I have a list of names.
> 
> Id like to type the first letters of the name and
> the first letters of 
> the first name to retrieve all the names beginning
> with those letters.
> 
> 
> for ex.
> 
> a list with
> 
> Gaskin Richard
> Major Klaus
> Major Klaudia
> Rice Alex
> Rossi Scott
> Schenkel Jan
> 
> 
> If I type in a "ask" dialog :
> 
> "klau maj"
> or
> "maj klau"
> 
> 
> the result should be :
> 2
> 3
> 
> respectively the numbers of the lines where those
> chunk are present
> 
> I've tried wtih lineOffset but without success..
> 
> Can anyone help me ?
> Thank you.
> 
> Greetings.
> 
> Yves COPPE
> 

Hi Yves,

The following ought to work :
--
on mouseUp
  put fld 1 into tSearchText
  put "maj klau" into tSearchWords
  put 0 into tLineCounter
  repeat for each line tLine in tSearchText
    add 1 to tLineCounter
    put true into tWordPresent
    repeat for each word tWord in tSearchWords
      put tWordPresent and (tWord is in tLine) \
          into tWordPresent
    end repeat
    if tWordPresent
    then put tLineCounter & return after tLines
  end repeat
  delete char -1 of tLines
  answer tLines
end mouseUp
--

Hope this helped,

Jan Schenkel.

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree


More information about the use-livecode mailing list