
Debugging
106
Axcess Programming Language
Tracking down your errors
Finding run-time errors and logic errors can sometimes be difficult. Observing the values of
variables during program execution, following program flow through conditional statements, and
finding the locations of run-time errors are not easy tasks. However, there are some tools to help in
your debugging.
Tracing program flow
Many times, you may want to know if or when your program reaches a certain point. By using the
SEND_STRING keyword, you can send a message to your computer when it reaches a particular
section of code. When a string is sent to device Ø, the information is sent from the Central
Controller's communications port.
Here is an example:
IF (X = Y)
{
SEND_STRING Ø,"'X EQUALS Y!', $ØD, $ØA"
}
ELSE
{
SEND_STRING Ø,"'X DOES NOT EQUAL Y!', $ØD, $ØA"
}
In this example, you can observe at run time which branch the program takes by viewing the
message sent out of the Central Controller's communications port. This technique is also helpful in
locating run-time errors. By sending messages before and after suspected code, you can determine
if the code contains any bugs. For example:
DEFINE_VARIABLE
ARY[1Ø]
X
DEFINE_PROGRAM
X = 11
SEND_STRING Ø, 'BEFORE...'
ARY[X] = 123 (* This will cause an error *)
SEND_STRING Ø, "'...AFTER', $ØD, $ØA"
The resulting output from the Central Controller would look like this if the AMX BUG is on:
BEFORE...BAD ELEMENT ASSIGN BYTE ARRAY
...AFTER
By using the SEND_STRING statements, you can determine that the array assignment is causing
the run-time error message. While the error in this example is obvious, in more complex programs
the error may not be so obvious. In some cases, this debugging technique can prove to be
invaluable.
Содержание Axcess
Страница 1: ...instruction manual Software Axcess Programming Language ...
Страница 8: ...vi Axcess Programming Language Table of Contents ...
Страница 12: ...Introduction 4 Axcess Programming Language ...
Страница 22: ...Axcess Basics 14 Axcess Programming Language ...
Страница 38: ...Channel Characteristics 30 Axcess Programming Language ...
Страница 54: ...Levels 46 Axcess Programming Language ...
Страница 62: ...Operators 54 Axcess Programming Language ...
Страница 66: ...Variable Types and Conversions 58 Axcess Programming Language ...
Страница 70: ...Two Dimensional Arrays 62 Axcess Programming Language ...
Страница 80: ...While Keywords 72 Axcess Programming Language ...
Страница 86: ...Using Buffers 78 Axcess Programming Language ...
Страница 94: ...Waits and Timer Keywords 86 Axcess Programming Language ...
Страница 102: ...Using Subroutines 94 Axcess Programming Language ...
Страница 108: ...Include Files and System_Calls 100 Axcess Programming Language ...
Страница 120: ...Compiler Error Messages 112 Axcess Programming Language ...
Страница 124: ...The External_Control Protocol 116 Axcess Programming Language ...
Страница 143: ...Index 135 Axcess Programming Language ...