CodeCharge Studio All ASP PHP Perl ColdFusion Java C#.NET VB.NET

Displaying Output


Although CodeCharge Studio doesn't include a debugger, you can perform various debugging tasks using a small amount of manual coding within the events. One of the common debugging tasks is to examine the value of a variable within the application. You can often do this by adding a line of code to your program that will display the value of any variable.

ASP

When using ASP, you can use the following code to print out variables within most events:
response.write variable_name

In a similar fashion you can also display the value of a control, such as a Text Box, within its Before Show event:

response.write TextBox1.value

Additionally, you can use the Before Execute Select event of a Grid to examine parts of the SQL statement of the form by using the following code:

response.write "SQL:" & GridName.datasource.SQL & "<br>"
response.write "ORDER BY:" & GridName.datasource.Order & "<br>"
response.write "WHERE:" & GridName.datasource.Where & "<br>"

(similar code can also be used to dynamically alter the SQL)

Keep in mind that sometimes the VBScript command response.write may appear not to work, especially when the page is being redirected to another page or refreshed. In this case you can disable the page buffering option by adding the following code to the beginning of the Common.asp file (after the 'End Include Files comment):

response.buffer = False

The following MSDN articles also provide information about debugging when using ASP:

PHP

When using PHP, you can use the following code to print out variables within most events:
global $variable_name;

echo $variable_name;


In a similar fashion you can also display the value of a control, such as a Text Box, within its Before Show event:

global $TextBox1;

echo $TextBox1->GetValue();

Additionally, you can use the Before Execute Select event of a Grid to examine parts of the SQL statement of the form by using the following code:

global $GridName;

echo "SQL:" . $GridName->DataSource->SQL . "<br>";
echo "ORDER BY:" . $GridName->DataSource->Order . "<br>";
echo "WHERE:" . $GridName->DataSource->Where . "<br>";

(similar code can also be used to dynamically alter the SQL)

Keep in mind that sometimes the PHP command echo may appear not to work, especially when the page is being redirected to another page or refreshed. In this case you can disable the page buffering option by adding the following code to the beginning of the Common.php file (after the //End Include Files comment):

ini_set("output_buffering", "Off");

Perl

As a prerequisite to printing any debug information in Perl, make sure that you set common header information as follows:

if (!$isHTTPHeader) {
  $isHTTPHeader = 1;
  print $page_header;
  print "Content-type: text/html\n\n";
}

After setting the header information, you can use the following code to print out variables within most events:

print $variable_name;


In a similar fashion you can also display the value of a control, such as a Text Box, within its Before Show event:

print $TextBox1->GetValue();

Additionally, you can use the Before Execute Select event of a Grid to examine parts of the SQL statement of the form by using the following code:

print "SQL:" . $GridName->{DataSource}->{SQL} . "<br>";

print "ORDER BY:" . $GridName->{DataSource}->{Order} . "<br>";

print "WHERE:" . $GridName->{DataSource}->{Where} . "<br>";

(similar code can also be used to dynamically alter the SQL)

ColdFusion

When using ColdFusion, you can use the following code to print out variables within most events:
<cfoutput>#variable name#</cfoutput>


In a similar fashion you can also display the value of a control, such as a Text Box, within its Before Show event:

<cfoutput>#fldTextBox1#</cfoutput>

Additionally, you can use the Before Execute Select event of a Grid to examine parts of the SQL statement of the form by using the following code:

<cfoutput><br>SQL: #strSQL#</cfoutput>
<cfoutput><br>ORDER BY: #strOrder#</cfoutput>
<cfoutput><br>WHERE: #strWhere#</cfoutput>
(similar code can also be used to dynamically alter the SQL)

Keep in mind that sometimes the ColdFusion command <cfoutput> may appear not to work, especially when the page is being redirected to another page or refreshed. You can disable redirection by using the following command:

<CFSET strRedirect="">

Java

The code generated by CodeCharge Studio Servlets and JSP patterns includes logging capabilities that can be configured to trace your application's execution. The logging properties are located in the Properties window when the project name is selected in the Project Explorer window. These properties are as follows:

Path to logfile The absolute path to a file where the log messages should be written. This property also supports predefined values such as out and err to write to the standard output and standard error streams respectively. The value none will switch off the logging functionality.
Level of Logging There are four levels that determine the verbosity of logging: debug, info, warn, error. Debug is the most verbose level and error is the least. The Debug level will produce messages about page processing and output SQL statements being executed.

To add your messages to the logging stream from events or custom code, you can use the following code:

CCLogger.getInstance().debug("In BeforeShow event, changing label color");

.NET

The .NET framework provides a various methods for debugging and profiling applications. Similar to ASP you can use Response.Write statements in events to examine variables and controls values

System.Web.HttpContext.Current.Response.Write(variable_name);

System.Web.HttpContext.Current.Response.Write(variable_name)

Keep in mind that the variable whose value should be displayed must be of the System.String data type. If the variable is of a different data type, you should call the ToString() method to produce a value of the type System.String.

In a similar fashion you can also display the value of a control, such as a Text Box, within its Before Show event:

System.Web.HttpContext.Current.Response.Write(TextBox1.Text);

System.Web.HttpContext.Current.Response.Write(TextBox1.Text)

Additionally, you can use the Before Execute Select event of a Grid to examine the Grid's SQL statement with the following code:

System.Web.HttpContext.Current.Response.Write(Select.ToString());

System.Web.HttpContext.Current.Response.Write(Select_.ToString())

You can also use tracing to produce debugging information. This method includes functionality that allows you to write debug statements directly in your code, without having to remove the statements from your application when it is deployed to production servers. For detailed information about this, please refer to the section on ASP.NET Trace in the MSDN documentation.

The following MSDN articles also provide information about debugging in the .Net environment:


On-line, printable versions and updates