matchText error -> Handler can't find handler

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
IsDark
Posts: 6
Joined: Thu Apr 21, 2011 9:06 pm

matchText error -> Handler can't find handler

Post by IsDark » Thu Apr 21, 2011 9:21 pm

I recently bought LiveCode, while building a Twitter desktop application I'm having issues with matchText and replaceText function. I browsed through the forum, copy, pasting and adapting a bit the code.

Forum is preventing me of posting an twitter profile example, so replace "twitter" with the any twitter profile

Code: Select all

on mouseUp
   put URL "twitter" into field Logs
   put empty into field Tweets
   put "<span class=" & quote & "entry-content" & quote & ">" into myExpression
   repeat for each line thisLine in field Logs
      if myExpression is in thisLine then
         put word 1 to -1 of thisLine into thisLine
         replace myExpression with empty in thisLine
         replace "</span>" with empty in thisLine
         replace "</a>" with empty in thisLine
         replaceText (thisLine,"<a\sclass=(.*)>",empty)
         put thisLine & cr after field Tweets
      end if
   end repeat
end mouseUp
When the user presses the button, the script download the select Twitter profile, isolate tweets and probably will display it in a field

Problem is matchText and replaceText are firing a Handler can't find handler error.

Since matchText was firing the same error, I changed the code and add all the cleaning statements plus the replaceText function

This line

Code: Select all

         replaceText (thisLine,"<a\sclass=(.*)>",empty)
or this line

Code: Select all

         replaceText (thisLine,"<a class=(.*)>",empty)
when used are both triggering the handler's error.

The ideal thing was to use the matchText function, extracting the data I want with a regular expression. When used it triggered the same error.

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

Re: matchText error -> Handler can't find handler

Post by Klaus » Thu Apr 21, 2011 11:42 pm

Hi IsDark,

1. "repeat for each..."is READ only, that means that you cannot change the value of "thisLine" in your script!
2. "replacetext" and "matchtext" are both FUNCTIONS, but you used them like handlers, which are not found as you experienced! 8)

Do something like this (not tested!) adn read my comments:

Code: Select all

on mouseUp
   ## "twitter" is definitively not a valid URL!
   ##  Put NAMES into QUOTES!
   put URL "twitter" into field "Logs"
   put empty into field "Tweets"
   put "<span class=" & quote & "entry-content" & quote & ">" into myExpression
   repeat for each line thisLine in field Logs
      if myExpression is in thisLine then
         put thisLine into thatLine
         put word 1 to -1 of thatLine into thatLine
         replace myExpression with empty in thatLine
         replace "</span>" with empty in thatLine
         replace "</a>" with empty in thatLine
         put replaceText (thatLine,"<a\sclass=(.*)>",empty) into thatLine

         ## Avoid accessing fields in a repeat loop, this will slow down things dramatically!
         ## Instead collect the data into avariable and put that variable into a field AFTER the loop!
         put thatLine & cr after tTweet
      end if
   end repeat
   put tTweet into fld "Tweets"
end mouseUp
Best

Klaus

IsDark
Posts: 6
Joined: Thu Apr 21, 2011 9:06 pm

Re: matchText error -> Handler can't find handler

Post by IsDark » Fri Apr 22, 2011 10:40 pm

Ah thanks, my error. I copy and paste the example from the Dictionary. Now is working. thanks

On a side note, as this script is checking a huge amount of data, I need to use a visual sign for the user in order for him to know the application is running the selected task.

I try using a scrollbar progress object. I can set the endValue and startValue property, but I'm having problems with setting the thumbPosition, something like this:

Code: Select all

put field TweetList into TempList
put the number of lines in TempList into MaxTempList
set the endValue of ProgressionBar to MaxTempList
set the startValue of ProgressionBar to 0
put 0 into CurrentLine
repeat for each line thisLine in TempList
  put CurrentLine + 1 into CurrentLine
 set the thumbPosition of ProgressionBar to CurrentLine
--- process the data here
end repeat
I copy this line

Code: Select all

set the thumbPosition of ProgressionBar to CurrentLine
From livecode Dictionary, but it triggers an error.

How can I show the progression of the list processing?.
Last edited by IsDark on Fri Apr 22, 2011 10:59 pm, edited 1 time in total.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: matchText error -> Handler can't find handler

Post by mwieder » Fri Apr 22, 2011 10:46 pm

try

Code: Select all

put CurrentLine + 1 into CurrentLine
or

Code: Select all

add 1 to CurrentLine
instead of

Code: Select all

put CurrentLine + 1 to CurrentLine

IsDark
Posts: 6
Joined: Thu Apr 21, 2011 9:06 pm

Re: matchText error -> Handler can't find handler

Post by IsDark » Fri Apr 22, 2011 11:01 pm

Typing error, sorry. My problem is with:

Code: Select all

set the thumbPosition of ProgressionBar to CurrentLine

doc
Posts: 148
Joined: Fri Jun 09, 2006 4:30 pm

Re: matchText error -> Handler can't find handler

Post by doc » Sat Apr 23, 2011 1:30 am

Assuming that your scrollbar is named "ProgressionBar", then I think this should work for you:

Code: Select all

set the thumbPosition of scrollbar "ProgressionBar" to CurrentLine
-- Or maybe the short version:
set the thumbPosition of sb "ProgressionBar" to CurrentLine
Does that help?

Best regards,
-Doc-

Edit: Added a very simple example stack
Attachments
PB_Update.zip
(787 Bytes) Downloaded 285 times

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: matchText error -> Handler can't find handler

Post by Dixie » Sat Apr 23, 2011 2:20 am

Doc..

Or maybe the even 'shorter version'

Code: Select all

set the thumbPos of sb "ProgressionBar" to CurrentLine
Sorry Doc... I couldn't resist.... :D

be well,

Dixie

doc
Posts: 148
Joined: Fri Jun 09, 2006 4:30 pm

Re: matchText error -> Handler can't find handler

Post by doc » Sat Apr 23, 2011 2:22 am

Ya know, I didn't even think about it...
...it's all good. :lol:

-Doc-

IsDark
Posts: 6
Joined: Thu Apr 21, 2011 9:06 pm

Re: matchText error -> Handler can't find handler

Post by IsDark » Sat Apr 23, 2011 4:41 pm

Thanks, I got it now. My mistake was not including the type of control before the object name when changing propertyes

I was using

Code: Select all

set the thumbPosition of "ProgressionBar" to CurrentLine
instead of

Code: Select all

set the thumbPosition of scrollbar "ProgressionBar" to CurrentLine
Thanks

Post Reply