VBS中的ExecuteGlobal语句的使用

在VBScript中,可以用ExecuteGlobal语句来在一个脚本文件中加载另外一个脚本的函数,例如,假设需要加载的是脚本Test.vbs:
Function Test1
 Msgbox "Test1"
End Function

那么可以在脚本ExecuteGlobal.vbs中按下面的方式加载并调用Test1函数:
Set fso = CreateObject("Scripting.FilesyStemObject")
Str = fso.OpenTextFile("Test.vbs", 1).ReadAll
ExecuteGlobal Str
Set fso = Nothing

Test1


在QTP中有对应的一个函数叫ExecuteFile,可以用于替代QTP中添加Resource的方式:

If you decide not to associate a function library (any VBScript file) with a test, but do want to be able to call its functions, subroutines, and so forth from an action in your test or from another function library, you can do so by inserting an ExecuteFile statement in your action.

When you run your test, the ExecuteFile statement executes all global code in the function library making all definitions in the file available from the global scope of the action's script.

Note: You cannot debug a file that is called using an ExecuteFile statement, or any of the functions contained in the file. In addition, when debugging a test that contains an ExecuteFile statement, the execution marker may not be correctly displayed.

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值