Before and after Livecode

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Before and after Livecode

David Bovill-3
Has anyone been using the "before" and "after" handlers in Livecode? If so
what for?

I'm very impressed with them. Together with chain-able behaviors I this we
have some great opportunities for code collaboration without the usual name
space collisions you get with global libraries.

If anyone has any pointers to documentation / architectures that can help
structure these features - that would be great. I've been using MVC type
architectures for a while - dispatching messages from one layer to another
- but it seems that I can do much of the same by routing behaviors, and
using the "before" and "after" features.

I'm not quite sure what to call these message path patterns - are clear
there equivalents in other coding paradigms?
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Before and after Livecode

Richmond Mathewson-2
On 18/07/15 09:47, David Bovill wrote:
> Has anyone been using the "before" and "after" handlers in Livecode? If so
> what for?
>
> I'm very impressed with them. Together with chain-able behaviors I this we
> have some great opportunities for code collaboration without the usual name
> space collisions you get with global libraries.

Well, Yes, but probably not in the way you mean:

put "a" after fld "XYZ"

put "a" before fld "XYZ"

fairly babyish stuff.

Richmond.

>
> If anyone has any pointers to documentation / architectures that can help
> structure these features - that would be great. I've been using MVC type
> architectures for a while - dispatching messages from one layer to another
> - but it seems that I can do much of the same by routing behaviors, and
> using the "before" and "after" features.
>
> I'm not quite sure what to call these message path patterns - are clear
> there equivalents in other coding paradigms?
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Before and after Livecode

Dave Kilroy
Richmond I think David is probably referring to the 'before' and 'after' control structures - as in:

"before mouseUp
  answer "before mouse up received"
end resizeStack"

David, no sorry I've never used them (and yes they are interesting...)
"The first 90% of the task takes 90% of the time, and the last 10% takes the other 90% of the time."
Peter M. Brigham
Reply | Threaded
Open this post in threaded view
|

Re: Before and after Livecode

Richmond Mathewson-2
On 18/07/15 12:24, Dave Kilroy wrote:
> Richmond I think David is probably referring to the 'before' and 'after'
> control structures - as in:
>
> "before mouseUp
>    answer "before mouse up received"
> end resizeStack"
>
> David, no sorry I've never used them (and yes they are interesting...)
>
I'm sure you are right.

Richmond.

>
>
> -----
> "The difference between genius and stupidity is; genius has its limits." - Albert Einstein
> --
> View this message in context: http://runtime-revolution.278305.n4.nabble.com/Before-and-after-Livecode-tp4694048p4694053.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Before and after Livecode

David Bovill-3
An example of how I used them to solve a problem that's bugged me for years
- logging / debugging things like servers. You can write a server in a tiny
bit of code, but to see what is going on / wrong you want to log things at
every step - or at least the important bits - and your code ends up with
lot's of loggin bits everywhere - even if you use a library for the actual
logging code.

Now with before / after handlers - no logging code in the server - it's so
clean and simple it is gorgeous. When I want logging I add the behavior
which includes all the efore / after handlers that havve acess to all the
data and just do the logging. When I don;t want them I remove the behavior.
Nice.

On 18 July 2015 at 11:09, Richmond <[hidden email]> wrote:

> On 18/07/15 12:24, Dave Kilroy wrote:
>
>> Richmond I think David is probably referring to the 'before' and 'after'
>> control structures - as in:
>>
>> "before mouseUp
>>    answer "before mouse up received"
>> end resizeStack"
>>
>> David, no sorry I've never used them (and yes they are interesting...)
>>
>>  I'm sure you are right.
>
> Richmond.
>
>>
>>
>> -----
>> "The difference between genius and stupidity is; genius has its limits."
>> - Albert Einstein
>> --
>> View this message in context:
>> http://runtime-revolution.278305.n4.nabble.com/Before-and-after-Livecode-tp4694048p4694053.html
>> Sent from the Revolution - User mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Before and after Livecode

Robert Brenstein
On 18.07.2015 at 20:28 Uhr +0100 David Bovill apparently wrote:
>
>Now with before / after handlers - no logging code in the server - it's so
>clean and simple it is gorgeous. When I want logging I add the behavior
>which includes all the efore / after handlers that havve acess to all the
>data and just do the logging. When I don;t want them I remove the behavior.
>Nice.

Indeed. I wonder whether before/after could be used to populate
popup/pulldown lists in buttons dynamically (upon mouse click) or
store field selection before it looses focus.

RObert

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Before and after Livecode

mwieder
In reply to this post by David Bovill-3
On 07/18/2015 12:28 PM, David Bovill wrote:

> Now with before / after handlers - no logging code in the server - it's so
> clean and simple it is gorgeous. When I want logging I add the behavior
> which includes all the efore / after handlers that havve acess to all the
> data and just do the logging. When I don;t want them I remove the behavior.
> Nice.

Brilliant.

--
  Mark Wieder
  [hidden email]

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
--
 Mark Wieder
 ahsoftware@gmail.com
Reply | Threaded
Open this post in threaded view
|

Re: Before and after Livecode

Dave Kilroy
In reply to this post by David Bovill-3
Ah that's clever! Thank you, I'll try that next time I need logging :)

David Bovill-3 wrote
An example of how I used them to solve a problem that's bugged me for years
- logging / debugging things like servers. You can write a server in a tiny
bit of code, but to see what is going on / wrong you want to log things at
every step - or at least the important bits - and your code ends up with
lot's of loggin bits everywhere - even if you use a library for the actual
logging code.

Now with before / after handlers - no logging code in the server - it's so
clean and simple it is gorgeous. When I want logging I add the behavior
which includes all the efore / after handlers that havve acess to all the
data and just do the logging. When I don;t want them I remove the behavior.
Nice.
"The first 90% of the task takes 90% of the time, and the last 10% takes the other 90% of the time."
Peter M. Brigham
Reply | Threaded
Open this post in threaded view
|

Re: Before and after Livecode

David Bovill-3
In reply to this post by mwieder
Oh wow - it get's better.

Say you have a handler - that processes some information from a request and
then sends out a response. In my case the server bundles useful stuff into
a requestArray, and after it has been routed a handler processes it and
sends back a reply to the browser. The handler looks like this:

*command* process_UnGot socketID, requestArray
>    *put* requestArray ["someInput"] && "is flexible!" into someMessage
>    daemon_SendJSON socketID, someMessage
>    *return* "An ungot url path"
> *end* process_UnGot


So let's say we want to modify this processing in some way - but not touch
the code. We can override the handler, by using the same "process_UnGot" -
but what if we want to just modify the data and let the existing code do
it's thing. how can we put stuff into the requestArray without altering the
existing code?

Well damned me if you can't use the following before handler in another
script:

before process_UnGot socketID, @requestArray
>    *put* "rubbish" into requestArray ["test"]
> *end* process_UnGot


Note the "@" - it's not in the original handler - but it still works!
Inject anything you want into any existing handler without messing with
your existing code. Middleware just got sexy.


On 19 July 2015 at 02:19, Mark Wieder <[hidden email]> wrote:

> On 07/18/2015 12:28 PM, David Bovill wrote:
>
>  Now with before / after handlers - no logging code in the server - it's so
>> clean and simple it is gorgeous. When I want logging I add the behavior
>> which includes all the efore / after handlers that havve acess to all the
>> data and just do the logging. When I don;t want them I remove the
>> behavior.
>> Nice.
>>
>
> Brilliant.
>
> --
>  Mark Wieder
>  [hidden email]
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Before and after Livecode

Dr. Hawkins
In reply to this post by David Bovill-3
On Sat, Jul 18, 2015 at 4:45 PM, Robert Brenstein <[hidden email]> wrote:

> Indeed. I wonder whether before/after could be used to populate
> popup/pulldown lists in buttons dynamically (upon mouse click) or store
> field selection before it looses focus.
>
>
For saving valuesNot following the advantage here – it seems that things
worked fine using closeField. Similarly, on mouseDown can load the images
or items from button. Where would be the vantage be?


--
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode