In an attempt to track down a larger problem, I made these three scripts in a suite I called handlerConfusion:
====================
driveTest.script:
put new parentObject into po
send “someMessage” to po
====================
ParentObject.script:
function makeNewObject
put “------------------------------------”
put “I’m a parent constructor”
put “I make a child”
put new childObject into co2 // succeeds
put “and it’s no problem!”
put “------------------------------------”
return me
end makeNewObject
on someMessage
put “------------------------------------”
put “I’m a parent message”
put “I make a child”
put new childObject into co // fails
put “------------------------------------”
end someMessage
on put
pass message
end put
on
put “I’m the parent, I don’t want the child’s message!”
end
====================
ChildObject.script:
function makeNewObject
put “I’m the child and I’m gonna call my function”
childFunction
return me
end makeNewObject
to childFunction
put “I am in the childFunction”
end childFunction
on put
pass message
end put
on
put “I’m the child, and I didn’t get the message!”
end
====================
I expect the same behavior when I create a childobject in the parentobject constructor as I see when I create a childobject in the parentobject message handler, but I don’t. I get this error:
Tue, 12/6/05 5:09:32 PM START Running /Documents/source/qa/eggplant_tests/test/handlerConfusion.suite/Scripts/driveTest.script
I’m a parent constructor
I make a child
I’m the child and I’m gonna call my function
I am in the childFunction
and it’s no problem!
I’m a parent message
I make a child
I’m the child and I’m gonna call my function
Tue, 12/6/05 5:09:33 PM FAILURE Screen_Error.tiff SRUN_UnknownCommand ERROR: No Handler Found for Command message: ‘childfunction’
Please tell me why I cannot get the childobject handler to be called when the childobject was created in the course of handling a parentobject message.
Also, please show me how to do this essential operation or point me to some documentation I may have overlooked.
Thank you.
-edj