Page 1 of 1

matchtext command

Posted: Tue Aug 18, 2015 5:34 pm
by ittarter
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)

Re: matchtext command

Posted: Tue Aug 18, 2015 5:50 pm
by Klaus
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

Re: matchtext command

Posted: Tue Aug 18, 2015 6:25 pm
by ittarter
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.

Re: matchtext command

Posted: Tue Aug 18, 2015 6:33 pm
by dunbarx
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