Errors, Warnings and The Compiler

There are many types of errors you will encounter while programming and running your creations, but they fall into four main categories:

"SYNTAX ERROR"

You have tried to compile your program but a command statement was not recognized or understood.

"PARAMETER MISMATCH"

You have tried to compile your program but a known command has been given the wrong parameter data. You must provide the correct types of parameters for the command, and in the right order.

"RUNTIME WARNING"

The program has compiled and run successfully, but the command failed due to the reasons given with the warning. A warning will not be given in a standalone executable version of the program!

"RUNTIME ERROR"

The program has compiled and run successfully, but the command failed due to the reasons given with the error. An error will terminate a standalone executable version of the program and provide a reason for the error!

The Compiler

To help understand the compiler better, here are a few notes that will help as you start to compile your programs. Some of the notes may be a little advanced, and are not essential reading for the beginner.

1. To reduce iterations, the compiler will process TYPE declarations and FUNCTION declarations in the same sweep, so if you place the TYPE ENDTYPE command after the function, the function will not be able to compile as it will not know what the TYPE is. Make sure you declare all your types before declaring any functions that use them.

2. Comments can be created as an appendage to an existing line, or as a command in itself. To append a comment to a line, simply use the ` symbol before adding the descriptive text you wish to apply. Comments can also be created as standalone commands using the REM statement, which you can abbreviate to the ` symbol if you wish. You should only place "appendage" comments inside type declarations or select statements. You can place a command comment anywhere a normal command can go. Common mistakes is to try and place REM commands inside TYPE or SELECT statements, which the compiler will find illegal.

3. The compiler will treat an ambiguous name as an array before a user function. A name will be treated as a user function call only if there is a FUNCTION declaration elsewhere in the program.

4. When the compiler processes a program that includes more than one .AGC source code file, it must first produce a single listing before it can be processed. This single listing can be found in the Media\SourceCode.agc file for reference. If the resulting executables throws a runtime error during its execution, the line number it reports refers to this master file, and not the main source code file from the project.

5. Error messages can sometimes be confusing if read out of context. Here is an explanation of an error that might cause confusion;

CODE: A$ = "X: " + TIMER()
ERROR: Types "$$1" and "TEMP0" are incompatible at line X.
EXPLANATION: This means the string and value cannot be added. The $$ symbol refers to a string, the TEMP0 refers to a temporary variable internally required by the compiler. The solution is to convert one so that you are adding the same type, i.e.: A$ = "X: " + STR(TIMER())