using get matchText true/false return...

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
tjo7777
Posts: 34
Joined: Fri May 02, 2014 9:16 pm

using get matchText true/false return...

Post by tjo7777 » Tue Feb 24, 2015 9:56 pm

I know this is probably a stupid question, but I'm kinda struggling...

Code looks like this:

Code: Select all

on MouseUp
   local tLineNumber
   put 1 into tLineNumber
   put 1 into NewListNumber
   
   repeat for each line tLine in field "PlayerList"
   put line tLineNumber of field "PlayerList" into playerlistline
   get matchText(playerlistline,"name player=\"(.*.)\" ",sc1) 
   if matchText is true then
   put sc1 into line NewListNumber of field "TestField"
   add 1 to tLineNumber
   add 1 to NewListNumber
   end if
   end repeat
end MouseUp
The matchText works as expected. The problem seems to be in the "if matchText is true then" line. I get the error message " compilation error at line 12 (Function: missing '('), char 7"

I am trying to have sc1 put into a line of TestField ONLY IF matchText is true. Right now if I remove the if/then statement it creates a blank line in TestField when there is no match.

Really I just need to know how to tell if the matchText return value is TRUE or FALSE. Feeling pretty dumb right now, just spent an hour on this and I'm sure it can't be that hard. :oops:

Thanks for any help or suggestions,

TJ.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: using get matchText true/false return...

Post by Simon » Tue Feb 24, 2015 9:59 pm

Hi TJ.,
"Get" puts the stuff into the "it' variable.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

tjo7777
Posts: 34
Joined: Fri May 02, 2014 9:16 pm

Re: using get matchText true/false return...

Post by tjo7777 » Tue Feb 24, 2015 10:28 pm

Hi Simon,

Thanks for your reply. I think I got it now.

Thanks so much for taking the time to reply. God only knows how long I would have searched on my own before finding the it variable. Having an off brain day, lol.

TJ. :D

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: using get matchText true/false return...

Post by Simon » Tue Feb 24, 2015 10:36 pm

Hi TJ,
Glad I could help. :)
People seem to really like the "get" method but I prefer the "put" way.

Code: Select all

put matchText("Goodbye","bye") into tVar
answer tVar
Now the way you have it set up (using 'it" right after getting) you'll not run into any trouble using the "it" var but understand that "it" can get updated often.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply