Learning and Developing AppleScripts

Chris @ccstone gave you a great, thorough answer.
But simply put, KM is NOT a scripting editor or IDE for coding.

Chris' bottom line is worth repeating: