Studio:Debugging Helps: Difference between revisions

From STRIDE Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 23: Line 23:
</pre>
</pre>


Note that the single argument to the function will accept any expression that perl can interpret as a string.
Note that the single argument to the function will accept any expression that perl can interpret as a string. Shown below is output from the sample script.


[[Image:PrintMessageOutput.jpg]]
[[Image:PrintMessageOutput.jpg]]


* MessageBox()
=== MessageBox() ===
The ascript object provides a way to interrupt script execution and display a modal message box containing a message you specify.
 
Here's an example of its use in a perl script:
 
<pre>
my $funcs = $main::ascript->Functions;
 
# loop through each captured function
foreach (0..($funcs->Count - 1)) {
  my $f = $funcs->Item($_);
  # send output to Studio Messages window
  $main::ascript->MessageBox("function item ".$_." ".$f->Name,
                              "Debug Output");
}
</pre>
 
The displayed message box can be customized in several ways; see online help and autosense for details. Shown below is output from the sample script.
 
[[Image:MessageBoxOutput.jpg]]


* exception messages
* exception messages

Revision as of 23:05, 4 February 2008

Script Debugging Techniques

Listed here are some debugging techniques.

perl

PrintMessage()

The studio object provides a way to perform printf-style debugging of scripts running within STRIDE Studio.

PrintMessage allows you to log messages from running scripts and view the values of variables during script execution.

Here's an example of its use in a perl script:

my $funcs = $main::ascript->Functions;

# loop through each captured function
foreach (0..($funcs->Count - 1)) {
   my $f = $funcs->Item($_);
   # send output to Studio Messages window
   $main::studio->Output->PrintMessage("function item ".$_." ".$f->Name);
}

Note that the single argument to the function will accept any expression that perl can interpret as a string. Shown below is output from the sample script.

PrintMessageOutput.jpg

MessageBox()

The ascript object provides a way to interrupt script execution and display a modal message box containing a message you specify.

Here's an example of its use in a perl script:

my $funcs = $main::ascript->Functions;

# loop through each captured function
foreach (0..($funcs->Count - 1)) {
   my $f = $funcs->Item($_);
   # send output to Studio Messages window
   $main::ascript->MessageBox("function item ".$_." ".$f->Name,
                              "Debug Output");
}

The displayed message box can be customized in several ways; see online help and autosense for details. Shown below is output from the sample script.

MessageBoxOutput.jpg

  • exception messages


JScript

  • PrintMessage()
  • MessageBox()
  • exception messages
  • symbolic debugger