This is in response to a different thread, but worth discussing on its own.

I just wanted to explain my view on why callbacks are not as horrible as they 
seem at first, if one structures the script logically.

The below code explains:

On LCcontrolScript pcommand,pdata

If pcommand = empty then
Put "step1();" into tJS
Do tJS in widget "my browser"

Else if pcommand = "return from step 1" then
-- process pdata 
Put "step2();" into tJS
Do tJS in widget "my browser"

Else if pcommand = "return from step 2" then
--process pdata 
Put "step3();" into tJS
Do tJS in widget "my browser

Else if pcommand = "return from step 3" then
--process pdata 
--Finish doing whatever it needs and enjoy a great JavaScript display
End if

End LCcontrolScript

On the JS side, the different functions use 
"liveCode.LCcontrolScript(tcommand,tdata);" to return the output.

As long as we structure our callback thread logically, doing a bunch of 
callbacks between LC and JS is not so bad.

The same structure can be used by functions initiated in JS. 

Having done some messy callbacks, I have learned my lesson on this. 


Sent from my iPhone
_______________________________________________
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