Software
Crestron
SIMPL+
There are two ways to force a task switch: with the ProcessLogic function or the
Delay function. To provide an immediate task switch out of the current SIMPL+
module use ProcessLogic. When the logic processor enters this module on the next
logic solution, execution begins with the line immediately following. An immediate
task switch also results from Delay, but the SIMPL+ module does not continue
executing until the time specified has elapsed. The Delay function is discussed in
greater detail in “Working with Time” on page 42.
Debugging
Rare is the case where a program works perfectly on the first try. Usually, a
programmer must make numerous modifications to the original code in order to get
the desired results. Programming bugs can be mistakes in syntax, typos, design
errors, or a misunderstanding of certain language elements. This section is not
intended to prevent mistakes, but rather to find and fix them.
Compiler Errors
Of all the possible problems that a program can have, ones that cause the compiler to
complain are perhaps the easiest to remedy. The reason is quite simple: the compiler
reveals what the problem is and where in the program it is located. The only job is to
recognize exactly what the compiler means and make the necessary changes.
The following list provides the most common causes of compiler errors.
•
Missing a semi-colon at the end of a statement
•
Having a semi-colon where it does not belong (e.g., before an opening
brace of a compound statement)
•
Trying to use a variable that has not been declared, or misspelling a
variable
•
Attempting to assign a value to an input variable (digital, analog, string,
or buffer)
•
Syntax errors
If multiple error messages are received when compiling the program, always work
with the first one before attempting to fix the rest. Many times, a missing semi-colon
at the beginning of a program can confuse the compiler enough that it thinks there
are many more errors. Fixing the first error may clear up the rest.
Run-time Errors
The term run-time error refers to an error, which is not caught by the compiler, but
causes the program to crash while it is running. For example, consider the following
statement.
x = y / z;
The compiler passes by this statement in the program with no problem, as it should.
This is a perfectly valid statement. However, if during run-time, the variable z
contains 0 when this statement executes, this becomes an illegal operation. Although
the control system is robust enough to catch most errors like this and the system
should not crash, unexpected results may occur.
50
•
SIMPL+
Programming Guide – DOC. 5789A