matchtext command

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
ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

matchtext command

Post by ittarter » Tue Aug 18, 2015 5:34 pm

Hello!

I'm using the matchtext command in my card's script (below). Can someone explain to me what I'm doing wrong here? I get the same error (below below) whether the username already exists in fld "user list" or not.

I've tested this command a dozen different ways as a single line in the message box and I get no problems. As a side note, as a total beginner, what is an effective way to debug this kind of problem myself?

Code: Select all

on adduser # Click btn Add User, adds new user to fld User List with basic info
   global gName
   ask "What is your username?" # select unique username
   put it into gName
   matchtext(fld "user list",gName)
   if it is false then
      choosepassword
   else if it is true then
      answer "Username unavailable. Please choose another username." with "OK"
      exit adduser
   end if
end adduser
error
handler: can't find handler
object: login
matchtext(fld "user list",gName)

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: matchtext command

Post by Klaus » Tue Aug 18, 2015 5:50 pm

HI ittarter,

no idea about RegEx stuff, but "matchtext" is a function, and you use it like a handler!

Try this:
...
get matchtext(fld "user list",gName)
if it is false then
...


Best

Klaus

ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Re: matchtext command

Post by ittarter » Tue Aug 18, 2015 6:25 pm

Klaus wrote: "matchtext" is a function, and you use it like a handler!

Klaus
OK, I think I sort of understand the difference. A function yields a result, but is directed by a handler toward a specific use? Anyway, the problem is fixed :) Thank you.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: matchtext command

Post by dunbarx » Tue Aug 18, 2015 6:33 pm

Hi.

More correctly, a function *returns* a result:

Code: Select all

put date() into field 1 --a system function call
or

Code: Select all

put doubleValue(3) into fld 1 --a custom function call

function doubleValue var
  return var * 2
end doubleValue
Craig Newman

Post Reply