Debugging is the process of finding and removing errors in your source code.
To debug a program means to locate and remove flaws in the source code which cause the application to not perform correctly.
UJML provides language support for debugging using the _trace() function and conditional compilation. See Compiling, _trace() function. There are also debugger programs for UJML which support stepping through the code and displaying variable values at run time without language support. To use these, the code must be compiled with the 'Debug' setting on. See Compiling.
The _trace() function may be called from anywhere in your scripting code to output a string value to the trace pane of the debugger program or some other output device. See _trace() function. To use the _trace() function the 'Trace' compiler setting must be on.
Conditional compilation allows you to have some parts of your program that are ignored or are compiled based on a conditional compilation name being defined. An example of this is using the name 'DEBUG' to mark parts of your program which are only compiled when 'DEBUG' is defined. Then, in those code blocks, your code may display values on the device screen or do other things to help you find out what is happening with your code.
The following example shows how to write the contents of a local variable to the trace pane of the debugger. It is part of the events.ujml sample.
_trace(message);
The following example shows how to override a function that creates help text to output a string listing the device's context instead. It is part of the lunarlander.ujml sample.
<?ujml-ifdef DEBUG?>
<!--
Builds a string listing the device context.
-->
<function name="getHelpText" type="string">
<variables>
<var name="text" type="string" />
</variables>
<script>
text = _strcat("PLATFORM: ", _getStringProperty(&_PROPERTY_STRING_PLATFORM;));
text = _strcat(text, " -- SCREEN WIDTH: ",
_getIntProperty(&_PROPERTY_INT_SCREEN_WIDTH;));
text = _strcat(text, " -- SCREEN HEIGHT: ",
_getIntProperty(&_PROPERTY_INT_SCREEN_HEIGHT;));
text = _strcat(text, " -- COLOR DEPTH: ",
_getIntProperty(&_PROPERTY_INT_COLOR_DEPTH;));
text = _strcat(text, " -- PREFERRED IMAGE EXTENSION: ",
_getStringProperty(&_PROPERTY_STRING_PREFERRED_IMAGE_EXTENSION;));
text = _strcat(text, " -- PREFERRED SOUND EXTENSION: ",
_getStringProperty(&_PROPERTY_STRING_PREFERRED_SOUND_EXTENSION;));
</script>
<return>
<eval>text</eval>
</return>
</function>
<?ujml-else?>|
Copyright (c) 2000-2007 UIEvolution, Inc. All rights reserved.
|
|
What do you think about this topic? Send feedback!
|