Crestron
SIMPL+
Software
To determine if a run-time error is occurring in your program, watch the status of the
control system's computer port with a program such as the Viewport (available
through SIMPL Windows or Crestron VisionTools
Pro-e). An "Interrupt" message
or some other error message can clue the user in to a problem. Locate the problem by
strategically placing
statements in the code. The
statement is covered in
the next section.
Debugging with Print()
The most powerful debugging tool for use with SIMPL+ is the
function. This
function allows the user to print out messages and variable contents during program
execution. The data that is generated by the
function is sent to the computer
port of the control system, making it viewable using a terminal emulation program
such as the Viewport tool that comes with SIMPL Windows and VisionTools Pro.
The
function is nearly identical to the
MakeString
function discussed in
“Working with Data (Variables)”. The only difference between the two functions is
that
MakeString
generates a formatted string into a string variable, while
generates a formatted string and spits it out of the control system's computer port.
The syntax of
is provided in the following example.
Print("<specification string>",<variable list>);
The <specification string> is a string, which determines what the output looks like. It
can contain static text intermixed with format specifiers. A format specifier is a
percentage sign (%) followed by a type character. For example, %d is a format
specifier for a decimal value, and %s is the format specifier for a string. Consider
this specific example.
INTEGER extension;
STRING name[30];
PUSH print_me
{
extension = 275;
name = "Joe Cool";
Print("%s is at extension %d", name, extension);
}
When this program is run and the digital input,
print_me,
goes high, the following
text is output from the computer port:
Joe Cool is at extension 275
The
statement works by replacing the format specifiers in the specification
string with the value of the variables in the variable list. Notice that the order of the
format specifiers must match the order of the variables in the list. In this example,
the first format specifier encountered is %s, which corresponds to the string name.
The next specifier is %d, which corresponds to the integer extension. If the variables
in the list were reversed and the specification string kept the same, the output would
be unpredictable because the system would try to print extension as a string and
name as an integer.
Refer to the latest revision of the SIMPL+ Language Reference Guide (Doc. 5797)
for a complete listing of all available format specifiers for use with the
and
MakeString
.
Programming Guide – DOC. 5789A
SIMPL+
•
51