While running codes sometimes we come across compiler error

Label not defined, sub functions not defined.

Are there any rules we need to keep in mind while defining procedures and functions..?