Page 1 of 1

Simple Text Search Problem

Posted: Sat Aug 26, 2017 6:11 am
by bidgeeman
Hi.
Trying to create a small database of email addresses and I want to perform
a search of the existing list to check if an email address already exists in the list.
The code I wrote works fine for names but as soon as you enter an "@" or a "." it
fails to find anything.

Code: Select all

on mouseUp
   if field "Email" is empty then
      answer "Please Enter Email"
   else 
      find the text of field "Email" in field "List" 
      put the foundText into fText
      if line 1 of fText = field "Email" then
         answer "Email Exists"
      else 
     
         get fld "List"
         put cr & field "Email" after it
         sort it
         put it into dataBase
         put dataBase into fld "List"
      end if
   end if
end mouseUp
Not sure why it's not working?
Bidge

Re: Simple Text Search Problem [SOLVED]

Posted: Sat Aug 26, 2017 11:08 am
by bidgeeman
I have managed to sort the problem with "find string" :)

Code: Select all

on mouseUp
   put field "Email" into ttsearch
   find string ttsearch in field "List"
   if the result <> empty then
      put ttsearch into tList
      put cr after tList
      put field "List" after tList
      sort it
      put tList into field "List"
      answer "Email Added"
   else
      answer "Email Already Exists"
   end if
end mouseUp
Thanks all
Bidge

Re: Simple Text Search Problem

Posted: Sat Aug 26, 2017 12:16 pm
by Klaus
Glad we could help! :D

Re: Simple Text Search Problem

Posted: Sat Aug 26, 2017 12:18 pm
by bidgeeman
LOL. I can feel your support :)

Bidge

Re: Simple Text Search Problem

Posted: Sat Aug 26, 2017 12:21 pm
by Klaus
I would use "lineoffset" however in situations like this:

Code: Select all

...
put field "Email" into ttsearch
put field "List" into tList

## To be sure -> ethel.wonka@willi.com <> wonka@willi.com!
set the wholematches to TRUE
if lineoffset(ttsearch,tList) <> 0 then
     answer "Email Already Exists"
    exit to top
end if

put CR & ttsearch after tList
sort tList
put tList into field "List"
...
Best

Klaus

Re: Simple Text Search Problem

Posted: Sat Aug 26, 2017 12:29 pm
by bidgeeman
Thank you Klaus.
I always make sure I have tried to get it right before I post a problem.
Really loving Livecode and the forum.

Bidge

Re: Simple Text Search Problem

Posted: Sat Aug 26, 2017 12:50 pm
by bogs
bidgeeman wrote:I have managed to sort the problem with "find string" :)
Klaus wrote:Glad we could help! :D
bidgeeman wrote:LOL. I can feel your support :)
Ah Klaus, our son is growing up ! I'm so proud he solved it on his own ! (tears of pride welling up) :cry:

Re: Simple Text Search Problem

Posted: Sat Aug 26, 2017 12:56 pm
by bidgeeman
I must thank my forum parents for such a good education :)
Bidge