What is a Procedure?
A procedure is a section of code that is separate from the rest of the main body. It can be called from other points in the code in order to execute it. e.g. ' Main Body of the code ... HandleOutput() ... ' Procedure Definition Procedure HandleOutput() ... End Proc In this example, the code that is written inside the body of HandleOutput will be executed at the point from where it is called. The procedure definition must be placed after the end of the main body of code. Procedure Names
Procedures can be given any name you want as long as these rules are obeyed: - Procedure names cannot contain spaces - Each procedure must be uniquely named - No key words from TNT Basic can be included in the name (e.g. Print) Advantages of Using Procedures
The advantages of using procedures are: - Improves code readability because the code does not need to be laid out as one long sequence - Allows code to be reused because it can be written once and called from more than one place in the code - Allows tasks to be broken down into simpler components because procedures can be written for certain tasks (procedures can also call other procedures)
Table of contents