Works sometimes -- but not other times

Peter M. Brigham pmbrig at gmail.com
Sat Jun 23 07:46:40 EDT 2012


Another problem is that in the field script your keydown handler is mis-constructed. You have "on keyDown var, temp, pKey" This is the same problem you were having before in your mouseup handler. What you have to understand is that when trapping system messages like mouseup or keydown (or openfield, or enterinfield, or mouseleave, or..., etc) you are not free to use any parameter list you want. Each system message is accompanied by a specific parameter or parameters (or maybe no parameters at all), and the dictionary tells you what they are.

The keydown message carries with it only one parameter, the keyName. if you start a keydown handler with "on keydown a,b,c" then the keyname will be inserted into the first parameter variable "a" and the variables b and c will be empty. Because of the fact that you put the contents of your first parameter, "var," into the field, you get what you expect from this. The other parameters start out empty and then you load them with values. There is no point in listing them as parameters in the "on keydown" line, since the keydown message is accompanied by only one parameter. A cleaner version of your keydown handler would start out:

on keyDown pKey
  set the cFlagPhotoGet of field "Type_Name_to_Find" \
         of stack "QuickieFinder" to true

  put the cNewmanResults of stack "Kids" into temp
  put pKey after me
  filter temp with "*" & me & "*"
  put temp into fld "Filtered_Results"
  <snip>

Also, further down you have a "pass keydown" line and then a "send" command. You should be aware that if you "pass" the message you have trapped, your handler is immediately exited, and nothing later will be executed.

And -- never never never trap the idle message. It ties up too much processing time, since idle is sent multiple times per second. There is **always** a better way to do whatever you're trying to do.

-- Peter

Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig



On Jun 21, 2012, at 7:45 PM, Mark Rauterkus wrote:

> Hi Pros,
> 
> I have a sub stack that has 1 card with a FIND field that user types
> in a name. As one types in the names of the students, the results
> shrink to the results of those in the class using a custom field
> property so that one person, (Firstname Lastname) appears.
> 
> Then when the results are ONE person, I want to show a photo of that
> person. For now, 3 beeps is enough.
> 
> I must not be using the right handler. Now deploying, poorly, the "on
> Idle" handler.
> 
> So, when I first go to the stack, it does not work. But, after going
> to the script of the field "Filtered_Results", and I don't change
> anything except push the green arrow key, it runs. And then thereafter
> it runs without any problems. Upon arrival the first time, the fancy
> script does not work.
> 
> Here are the scripts.
> 
> Filed "Filtered_Results"
> 
> on idle tUsermame
>   -- to avoid a loop with an idle:
>   if the cFlagPhotoGet of field "Type_Name_to_Find" of stack
> "QuickieFinder" is "true"
> 
>   then
>      Get the number of words of me
>      if it is two then
>         beep 3
>         -- More goes here to set the photo
> 
>         set the cFlagPhotoGet of field "Type_Name_to_Find" of stack
> "QuickieFinder" to ""
>      end if
>   end if
> end idle
> 
> 
> - - - -
> 
> 
> Script for Field "Type_Name_to_Find"
> on keyDown var, temp, pKey
> 
>   -- MR: This avoids a loop on the other field with an on idle script.
>   set the cFlagPhotoGet of field "Type_Name_to_Find" of stack
> "QuickieFinder" to true
> 
>   -- MR: below works fine:
>   get the cNewmanResults of stack "Kids"
>   put it into temp
>   put var after me
>   filter temp with "*" & me & "*"
>   put temp into fld "Filtered_Results"
> 
>   -- MR: After a backspace to nothing, clear the other field.
>   if pKey is a number then
>      pass keyDown
>      send "exitField" to field "Type_Name_to_Find"
>   end if
> 
> end keyDown
> 
> on exitField -- remove visual signs that the field is being edited
>   put "" into field "Filtered_Results"
>   put "" into field "Type_Name_to_Find"
> end exitField
> 
> 
> - - -
> I'm not doing well at using the backspace key as well. I'd like to get
> rid off all the content in the results field if the backspace key
> takes the field to empty.
> 
> 
> 
> --
> Ta.
> 
> 
> Mark Rauterkus       Mark.Rauterkus at gmail.com
> PPS Summer Dreamers' Swim and Water Polo Camp Head Coach with
> Neighborhood Learning Alliance
> 
> http://NeighborhoodLearning.org
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list