ERROR: Nested Too Deeply

The number one cause for a Nested Too Deeply error in ToolBook is seen when you are writing or manipulating Shared Script code.

The following handler is valid if placed in the Script of a button:

to handle buttonClick
   text of field "foo" = name of target
   forward
end

However that same code will fail, producing the Nested Too Deeply error if you try to assign that code as the Shared Script of an object and then click on that object.

The reason it will fail is that the Forward statement tells ToolBook to forward the buttonClick message to the next object higher in the hierarchy, and since the nature of a Shared Script is to pretend that the shared script code is really extra code for the button object, ToolBook thinks the next object in the hierarchy is in fact the Shared Script. This causes the forward to essentially loop back into the same code about 1000 times or so until this error occurs.

Sound confusing? Well, if it does not make sense, don't worry about it. The bottom line is that you will need to modify your code just a bit to make it work in a Shared Script. To get the code to work, simply do this instead:

to handle buttonClick
   text of field "foo" = name of target
   forward to parent
end

Forwarding to the Parent object forces the message to go the the next object higher in the hierarchy, thus getting rid of this error.