i have a simple setup to give feedback to users for a variety of actions - by showing a transient status line of text. The text is a background group that has handlers to show a message and hide the message.
Rather than writing 'dispatch' code everywhere i wanted to create a stack-wide handler that would delegate the dispatching to the group to simplify calling the handler.
So, lets say the group has the code:
Code: Select all
on showMessage pMessage
set the text of field "text" of me to pMessage
set the visible of me to true
end showMessage
on hideMessage
set the text of me to "Message" // so this can be seen in the IDE when showing invisibles
set the visible of me to false
end showMessage
dispatch "showMessage" to group "messageGroup" of this card with "my amazing message", I implement a stack handler:
Code: Select all
on showMessage pMessage
try
dispatch "showMessage" to group "messageGroup" of this card with pMessage
catch e
put "messageGroup is not placed on this card"
end try
end showMessage
on hideMessage
try
dispatch "hideMessage" to group "messageGroup" of this card
end try
end hideMessage

The issue is that not all cards have the background group "messageGroup" - sometimes this is intentional, sometimes accidental.
If the group is not on the card it calling showMessage pMessage does not trigger any error and nothing is put into the messageBox...
So my question is why doesn't the catch statement fire? (just to alert me i may have forgotten to place the group).
Or is this some peculiarity with groups/background groups? Or am I misusing the try/catch block?
Stam