VBScript高级:VBScript调试对象

调试对象是可以将输出发送到脚本调试器的全局对象。在这里,我们所指的调试器是Microsoft Script Debugger。

调试对象不能像其他对象被创建,但可以当我们正在调试中。

调试对象支持以下方法。如果未在调试模式下执行脚本,则这些方法或对象无效。详细讨论了调试对象支持的方法。

Write

Write方法在运行时将字符串发送到Microsoft脚本调试器的立即窗口。如果脚本未在调试模式下执行,则Write方法无效。

Write Debug.Write([str1 [, str2 [, ... [, strN]]]])

<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         Dim counter
         counter = 42
         Debug.Write "The value of counter is " & counter
       
      </script>
   </body>
</html>

WriteLine

Writeline方法与Write方法非常相似。WriteLine方法在运行时将字符串,后跟换行符,发送到Microsoft脚本调试器的直接窗口。如果脚本未在调试模式下执行,则WriteLine方法无效。

Debug.WriteLine([str1 [, str2 [, ... [, strN]]]])

<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         Dim counter
         counter = 42
         Debug.WriteLine "The value of counter is " & counter
       
      </script>
   </body>
</html>

启用调试模式

要在调试模式下启用脚本,用户需要执行以下操作-

  • 工具菜单上,单击Internet选项。
  • 在“ Internet选项”对话框中,单击“高级”选项卡。
  • 在“浏览”类别中,清除“禁用脚本调试”复选框。
  • 单击确定。
  • 退出并重新启动Internet Explorer。

作者:terry,如若转载,请注明出处:https://www.web176.com/vbscript/1127.html

(1)
打赏 支付宝 支付宝 微信 微信
terryterry
上一篇 2020年12月7日 下午12:33
下一篇 2020年12月7日 下午3:11

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注