Device Channel 10

Top  Previous  Next

Device 10 is an output channel that sends text to Windows dialog box. This means that you can send text from any XPL Intrinsic that can output bytes to a device channel. This is very useful for debugging.  To redirect data from the dialog box, you simply use 10 as the device number. For example, Text(10,"Hello World"); would send the string "Hello World" to the dialog box.


Displaying The Dialog Box. The dialog box can be displayed by selecting the Debug -> Device 10 Output option from the menu bar. The Device 10 display is also available in a Stand Alone program by right clicking on the window and selecting the Device 10 Output option.


Debugging. The primary use of the Device 10 is for debugging. A standard debugging technique for XPL is to print text at various points in the program to trace program execution or to display variable values. This works well in some text programs, but is problematic in a graphics program. For example, the debug text may be overwritten and obscured by the graphics display. Likewise, the text may also interfere with graphic operations so you can't see key portions of the image.


Device channel 10 avoids these problems by directing text to a separate dialog box. This way, the print statements never interfere with the graphic display. Because this feature is a device channel, any intrinsic that sends output to a device channel can be used to display debug information. For example, the IntOut, RlOut, Text and CRLF intrinsics can be used for generating debug print statements.


As an example of using Device Channel 10, here is a snippet of code that illustrates the process:


A:=1.2; B:=3.4;

C:=Sqrt(A*A + B*B);


Text(10,"A = "); RlOut(10,A); CRLF(10);

Text(10,"B = "); RlOut(10,B); CRLF(10);

Text(10,"C = "); RlOut(10,C); CRLF(10);


The code above performs a simple calculation and then outputs the values to device channel 10. The dialog to the right illustrates the result.


The dialog can be left open during the execution of the program so print statements can be observed while they occur. The contents of the dialog can be cleared by pressing the Clear button.