Can't find handler

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
pwr
Posts: 13
Joined: Thu Apr 16, 2009 8:37 pm

Can't find handler

Post by pwr » Thu Apr 16, 2009 8:47 pm

Hi, I'm new to Revolution and have the following problem with my first app.

I have a single stack and a single card in my app. There are several controls on my card.

I've created a custom handler named ConvertUnits that I placed in my stack script. However, when I try to execute the handler using keyUp on a field I get the "can't find handler" error msg.

Funny though, if I right-click on the ConvertUnits command and select the "Go to definition" it finds the handler with no problem. There are no compile errors.

I read elsewhere on this forum that it may be better to create the custom handler before you write the command to execute it, and I may not have done this. But certainly, the Rev product must be able to see the handler after it's written!!!!

Why can't I find my handler....????

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Can't find handler

Post by sturgis » Thu Apr 16, 2009 8:55 pm

Mind posting the handler code and your field code?
Lots of times when you get that error it is actually something missing in the lines above the call, but if you post the code it'll be easier to find whats up.
pwr wrote:Hi, I'm new to Revolution and have the following problem with my first app.

I have a single stack and a single card in my app. There are several controls on my card.

I've created a custom handler named ConvertUnits that I placed in my stack script. However, when I try to execute the handler using keyUp on a field I get the "can't find handler" error msg.

Funny though, if I right-click on the ConvertUnits command and select the "Go to definition" it finds the handler with no problem. There are no compile errors.

I read elsewhere on this forum that it may be better to create the custom handler before you write the command to execute it, and I may not have done this. But certainly, the Rev product must be able to see the handler after it's written!!!!

Why can't I find my handler....????

pwr
Posts: 13
Joined: Thu Apr 16, 2009 8:37 pm

Post by pwr » Thu Apr 16, 2009 9:01 pm

Here's the custom handler in my stack script...

function ConvertUnits
switch
case the value of SelectedProperty is "Area"
ConvertAreas --Not yet done
break
case the value of SelectedProperty is "Length"
break
case the value of SelectedProperty is "Temperature"
ConvertTemperatures
break
end switch
end ConvertUnits


Here's my call to the custom handler...

on keyUp
if the text of field fldInputValue is not a number then beep
else --pass keyDown
ConvertUnits
end if
end keyUp

Thanks for any help...

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Post by sturgis » Thu Apr 16, 2009 9:50 pm

Edited to correct: Since you've defined it as a function try adding () at the end to make the call ConvertUnits().
In addition, you can change it from a function to a command and forget the parens entirely.

Think you can also shorten the typing requirements for your switch /case block if you wish.

YOu can do something like this to avoid retyping SelectedProperty so much. (yes i'm lazy)

Code: Select all

switch the value of SelectedProperty
     case "Area"
          code here
          exit switch -- or break
     case "Length"
           code here
          exit switch
     case "Temperature"
          code here
          exit switch 
     default
         answer "No match"
end switch
[/b]
pwr wrote:Here's the custom handler in my stack script...

function ConvertUnits
switch
case the value of SelectedProperty is "Area"
ConvertAreas --Not yet done
break
case the value of SelectedProperty is "Length"
break
case the value of SelectedProperty is "Temperature"
ConvertTemperatures
break
end switch
end ConvertUnits


Here's my call to the custom handler...

on keyUp
if the text of field fldInputValue is not a number then beep
else --pass keyDown
ConvertUnits
end if
end keyUp

Thanks for any help...

pwr
Posts: 13
Joined: Thu Apr 16, 2009 8:37 pm

Post by pwr » Thu Apr 16, 2009 11:01 pm

Thank you very much.

I changed my function to a command and now it's working.

Again, thanks very, very much...pwr

Post Reply