Simple Text Search Problem

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: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Simple Text Search Problem

Post by bidgeeman » Sat Aug 26, 2017 6:11 am

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

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: Simple Text Search Problem [SOLVED]

Post by bidgeeman » Sat Aug 26, 2017 11:08 am

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

Klaus
Posts: 11276
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Simple Text Search Problem

Post by Klaus » Sat Aug 26, 2017 12:16 pm

Glad we could help! :D

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: Simple Text Search Problem

Post by bidgeeman » Sat Aug 26, 2017 12:18 pm

LOL. I can feel your support :)

Bidge

Klaus
Posts: 11276
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Simple Text Search Problem

Post by Klaus » Sat Aug 26, 2017 12:21 pm

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

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: Simple Text Search Problem

Post by bidgeeman » Sat Aug 26, 2017 12:29 pm

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

bogs
Posts: 3939
Joined: Sat Feb 25, 2017 10:45 pm

Re: Simple Text Search Problem

Post by bogs » Sat Aug 26, 2017 12:50 pm

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:
Image

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am
Location: Australia

Re: Simple Text Search Problem

Post by bidgeeman » Sat Aug 26, 2017 12:56 pm

I must thank my forum parents for such a good education :)
Bidge

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”