Trying a custom handler for several math fields

dunbarx at aol.com dunbarx at aol.com
Fri Sep 13 12:27:05 EDT 2013


Vaughn.


LC is event driven. In order to run your "doMath" handler, a "doMath" message must be generated. Now how to do this?



1- You could send the message directly from some object, or the message box. (send "doMath" to this card)

2- A system message generated by some other action might work.




Try this:


Make a button. Put this in its script:


on mouseUp
  doMath
end mouseUp


When you click on the button, the engine generates a "mouseUp" message with that button as the "target". The handler in that button is trapped and executes, and its only task is to generate a "doMath" message. This message is examined along the message hierarchy, as Jacque outlined, starting with the button itself, and is eventually trapped by the "doMath" handler in the card script. This will work.


Having two "doMath" handlers in different places is frequently useful, but here is redundant, and possibly dangerous. Again, as Jacque pointed out, the hierarchy is a profoundly powerful tool to organize and systemetize message handling.


Try this out. But you simply must play around a bit with a few of your own projects, and it matters not how sensible or simple they are, they will teach you an enormous amount. But again, you do not yet have the fundamentals. Can you put your "doMath" thing in the button itself? Make an address book or a calculator. Anything at all. You have to practice on the computer, not read the documents.


Craig








-----Original Message-----
From: Vaughn Clement <vclement at gmail.com>
To: How to use LiveCode <use-livecode at lists.runrev.com>
Sent: Fri, Sep 13, 2013 11:55 am
Subject: Re: Trying a custom handler for several math fields


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: vclement at 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 <
stephenREVOLUTION2 at barncard.com> wrote:

> On Thu, Sep 12, 2013 at 7:17 PM, Vaughn Clement <vclement at 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 at 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 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