am7
07-31-2009, 07:02 PM
Does the callback functions need to be declared globally? If this is the case I have to keep all functions that needs to be accessed from the callback global too? (ie: foo2())
For example, I don't want to declare foo2 as a global function - I still want it to stay inside my scope level. Does anyone have a solution to this?
Once you put the callback function inside the scope level it fails.
(
fn foo2 =
(
format "another function\n"
)
fn whendeleted = --define a callback function
(
callbacks.removeScripts #selectedNodesPreDelete
format "callback function entered, trying to call foo2()\n"
foo2()
)
fn foo =
(
-- make sure we remove the callback
callbacks.removeScripts #selectedNodesPreDelete
--register the function as general callback
callbacks.addscript #selectedNodesPreDelete "whendeleted()"
mypot1 = teapot() --create a teapot
select mypot1
max delete --trigger the callback function
)
foo() -- test it!
)
For example, I don't want to declare foo2 as a global function - I still want it to stay inside my scope level. Does anyone have a solution to this?
Once you put the callback function inside the scope level it fails.
(
fn foo2 =
(
format "another function\n"
)
fn whendeleted = --define a callback function
(
callbacks.removeScripts #selectedNodesPreDelete
format "callback function entered, trying to call foo2()\n"
foo2()
)
fn foo =
(
-- make sure we remove the callback
callbacks.removeScripts #selectedNodesPreDelete
--register the function as general callback
callbacks.addscript #selectedNodesPreDelete "whendeleted()"
mypot1 = teapot() --create a teapot
select mypot1
max delete --trigger the callback function
)
foo() -- test it!
)
