|
|

|
|
Effectively using the script console |
Using the Script Console
You can send the output of your custom scripts to the Script Console.
It provides rich formatting capabilities
that can be used to enhance the quality of your output. This article
demonstrates how you can control the font face, color, hilite, and size
of the text that appears in the console. Additionally, this article
contains some hints on how to output results in languages other than
English.
Stand-alone and Integrated scripts
Unsniff supports two types of scripts based on how they interact with
Unsniff Network Analyzer.
1. Stand alone scripts
These scripts typically are run from the command line or via a Windows
shortcut. They
operate on capture files outside the Unsniff application.
2. Integrated scripts
You can attach custom scripts to popup menu items in Unsniff.
They are triggered
when the corresponding menu item is selected. These scripts give you
access to the
currently open capture file and the current selection context. This is
a powerful way to
add functionality to the Unsniff application.
The Script Console is for
use with integrated scripts only. For standalone scripts you can use
the MS-DOS console, HTML, or a graphical toolkit such as
Fx-Ruby (the Fox toolkit)
The CurrentDocument.Console object
See the Unsniff
Scripting Guide for complete documentation of the
CurrentDocument.Console object.
The functionality of the Script Console is provided via the
CurrentDocument.Console object. You always have access to this object
within your script. This listing demonstrates all the features of the
Scripting Console in a single program. You can mix and match any of
these styles to produce reports. For example :
- Flag errors in red-bold font
- Highlight important data,
- Print titles in large size font
- Use a mono-space font like Courier New or Lucida
Console to align your reports
Dim
Con
Set Con = CurrentDocument.Console
Con.WriteLine"----------------"
Con.WriteLine "Testing Console"
Con.WriteLine"----------------"
' Default color
Con.WriteLine "This Text is in in default color"
' Different colors
Con.TextColor= "#0000FF"
Con.WriteLine "This Text is in in #0000FF color"
' Set window title
Con.SetTitle "A new window title"
' Test Default format
Con.SetDefaultFormat
Con.WriteLine "Now we are back to default format"
' Test Hilite
Con.Write "This is a long line, "
Con.Hilite = True
Con.Write "this text is now hilited"
Con.Hilite = False
Con.WriteLine "Now we are back to non-hilited more"
' Test Bold
Con.Bold=True
Con.Write "This sentence is meant to be in bold"
Con.Bold=False
' Test Italics
Con.Italics=True
Con.Write "This sentence is meant to be in italics"
Con.Italics=False
' Test Height
Con.Height = 250
Con.WriteLine "This text is
250 twips high"
' Test Font
Con.SetFont "Times", 300
Con.WriteLine "This text is
in TimesFont and 300 twips high"
Sample Output
A screenshot of the script console is shown below.

Working with Unicode
The Script Console is capable of displaying unicode output. The only
issue is that you must select a font that is capable of displaying your
language. For example if you are displaying output in Japanese, you may
want to choose a font such as MS Mincho or MS Hei. The code shown below
sets the font to MS Mincho 300 twips - at the very top of the script.
Dim Con
Set
Con = CurrentDocument.Console
Con.SetFont "MS
Mincho", 300
Sample Unicode Script Output
A sample Japanese script output is shown below. This sample script
scans through a capture file and looks for HTTP OK messages. It then
highlights each HTTP message.

Clipboard
You can save the contents of your script by pressing Ctrl-A (to select
all the output) and pressing the "Copy" button. You can then paste it
into notepad (for plain text) or Wordpad (for RTF text)
|
|