OK, I think you need to understand the message path.

Messages are initiated by user actions or by your own scripts. The most common 
user actions are things like mousedown", "mouseup", "mousemove", "enterfield", 
"closefield", etc., but there are many more of them as well. When the user 
clicks on a button, for instance, the LC engine is notified by the system of 
the user action and it sends several messages, including "mousedown" and 
"mouseup", and it sends them to the button that was clicked. If the script of 
the button has a handler in it that starts "on mouseup" then that handler will 
be triggered and executed. If there is no "mouseup" handler in the button 
script then the message will be passed to any group the button is an element 
of, then to the card, then to any background group that owns the button, then 
to the stack, and finally to the engine. (There are other things like front and 
back scripts and stacks that are "in use", but you can learn about them later. 
The important thing to know is that messages are passed from one objec
 t along the message path, in a well-defined sequence. If the script of any of 
the objects in the path contain a handler for handling the message (you can see 
why they are called "handlers"), then that handler will be triggered. The 
message then stops -- unless you end the handler with a "pass <message>" 
command, in which case the message goes on to the next object in the path.

So, if you put the two handlers below in the card script, in the order you show 
them, when the message reaches the card, the first "on doMath" handler will be 
triggered, and the only thing you have told it to do is pass the message, so 
the engine passes the message to the stack (assuming no background group), and 
the stack has no handler to intercept "doMath", so it will go to the engine, 
and the engine ignores any user-generated messages.

Remember that if you have two handlers in the same script with the same name, 
only the first one is executed and any others are ignored. You're almost there 
-- just take out the first "doMath" handler entirely and leave the other one. 
Then in each of your fields, have a handler "on closefield":

on closefield
   doMath
end closefield

When the user changes text in any such field then moves the focus out of the 
field, eg, by clicking elsewhere, the closefield message will trigger and 
"doMath" will be sent. It will be sent initially to the field itself (so you 
could have a "doMath" handler in the field script if you needed a custom action 
for that particular field) and if there is no "doMath" handler in the field the 
message is sent on the the card, where it triggers the handler you want.

The message path is utterly basic to how LC (and Hypercard before it) works, 
and understanding that well enough that it's second nature will go a long way 
towards clarifying your thinking.

-- Peter

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


On Sep 13, 2013, at 11:54 AM, Vaughn Clement wrote:

> Hi All
> 
> Well my first attempt ever to use a custom handler (OK :- (
> 
> Well I thought I understood what to do, but as things go I didn't get the
> expected result:
> 
> In the card control field,  I put this pass call;
> 
> on doMath
>   pass doMath
> end doMath
> 
> in the card script I put this script;
> 
> on doMath
>   put field "Loan Balance 1" + field "Loan Balance 2" into field "Loan
> Balance Total"
>   -- set the numberFormat to "#.00" -- dollar format testing to see if it
> worked "No"
> end doMath
> 
> The fields both had the pass call to send the math to the card handler.
> 
> 
> 
> Thank you
> 
> Vaughn Clement
> 
> Apps by Vaughn Clement (Support)
> *http://www.appsbyvaughnclement.com/tools/home-page/*
> Skype: vaughn.clement
> https://secure.join.me/appsbyvclement
> FaceTime: vclem...@gmail.com
> LogMeIn also avaialble
> Call on "ooVoo" at address:  vaughnclement or 9282549062
> Ph. 928-254-9062
> Cloud Hosting Registration Web Site:
> https://my.oditech.com/cart.php?a=add&pid=41
> 
> 
> On Thu, Sep 12, 2013 at 7:30 PM, stephen barncard <
> stephenrevoluti...@barncard.com> wrote:
> 
>> On Thu, Sep 12, 2013 at 7:17 PM, Vaughn Clement <vclem...@gmail.com>
>> wrote:
>> 
>>> The same thing happened when I used a
>>> comma for the divider of hundreds. So that kills the scripts. I did not
>>> find anything that tells you how to solve this? I tried the dictionary
>> for
>>> answers but nothing was doing it!
>>> 
>> 
>> strip the offending characters before calculating, then put them back.
>> 
>> 
>> --
>> 
>> 
>> 
>> Stephen Barncard
>> San Francisco Ca. USA
>> 
>> more about sqb  <http://www.google.com/profiles/sbarncar>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
> _______________________________________________
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to