SAPIEN Solutions

SAPIEN homepage
PrimalScript script editor+ide
PrimalScope script debugger
Free Tools script utilities
SAPIEN Press tech books
ScriptingAnswers.com learn+share
ScriptingOutpost.com online store
Blog.Sapien.com official blog
Contact Us

 

Writing debug information to an IE window

This is a trick I’ve used a lot in VBScript - writing debug messages to a browser window. It isn’t necessary if you use an editor like PrimalScript, which redirects Write-Debug output to another pane for you. But if you’re working in Notepad or something, this can be a good trick for separating debug output from your script’s main output.

  1. # # ScriptingAnswers.com Essentials # copyright 2006 SAPIEN Technologies, Inc. # # IE-based Debug Window # # add this to the beginning of your script: $ie = New-Object -comobject "InternetExplorer.Application" Function Debug($text) { # uncomment the next line to disable debugging # return if ($ie.visible -ne $true) { $ie.visible = $true $ie.navigate("about:blank") $ie.ToolBar = $False $ie.Width = 200 $ie.Height = 300 $ie.Left = 10 $ie.Top = 10 } $body = $ie.document.body.innerhtml $body += $text $ie.document.body.innerhtml = $body } # to use: # Debug("whatever") # will cause 'whatever' to appear in a pop-up window

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags: , , , , , ,

Leave a Reply


Entries (RSS) and Comments (RSS).