Ok, I presume this is a Lathe?
Attached is a simple macro, place it in the macro folder of the profile you are using. When you call M123 it will look to see if referenced, if not it will stop the code then pop up a message box. If it is referenced it will just continue and will display a message in the ticker saying so.
Hood