常用VBScript

工作中调试操作,由人工来做,即浪费精力,又不能体现工作价值;而让电脑代替我们做是一个比较好的选择。

在工作利用VBScript代替人工操作确实带来了不少便利,现记录共享如下:

(当然VBScript本身还是很强大的,这里只利用很简单的操作)

简单示例(循环向串口发送提示和操作命令):

---------------------------------------------

#$language = "VBScript"
#$interface = "1.0"

Sub main

Dim index
index = 1

  Do while (index<31)

     crt.Screen.Send "#"
     crt.Screen.Send  Now & VbCr
     crt.Screen.Send "cmd" & VbCr
     crt.Sleep 50
     crt.Screen.Send "" & VbCr

     index = index + 1
  Loop

End Sub

--------------------------------------------------------------

#行为注释说明,VBScript,1.0版本

Sub为函数入口,main为主入口。

Dim用于声明变量

Do while(条件)

Loop为循环

End Sub为函数结束

crt.Screen.Send为向目标输出内容

示例中的Now为Windows下获取时间的接口

VbCr为换行

crt.Sleep为休眠多少ms

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Docklight Scripting is an extended edition of Docklight RS232 Terminal / RS232 Monitor. It features an easy-to-use scripting language, plus a built-in editor to create and run automated test jobs. A Docklight script allows you to execute all basic Docklight operations (sending predefined data sequences, detecting specific sequences within the incoming data stream, ...) and embed them in your own test code. Docklight Scripting is also network-enabled. Instead of using a serial COM port, Docklight Scripting can establish TCP connections (TCP client mode), accept a TCP connection on a local port (TCP server mode), or act as a UDP peer. Docklight Scripting gives you both flexibility and simplicity. Within minutes you can build your own automated testing tools and create: · time-controlled test jobs (e.g. sending a diagnostics command every 5 minutes and reporting an error, if the device response is not ok) · repeated test cycles (e.g. endurance testing for a motion control / drive system) · automatic device configuration scripts (e.g. resetting a RS232 device to factory defaults before delivery) · fault analysis tools for service and maintenance tasks (e.g. running a set of diagnostics commands and performing automatic fault analysis) · protocol testers with automatic checksum calculations (e.g. CRC - Cyclic Redundancy Codes) · Docklight startup scripts (e.g. automatically starting a COM port logging task at PC startup) Docklight Scripting uses the VBScript engine, allowing you to write your tests in a simple, well-known scripting language. Docklight's basic functions and features are made available through a small and convenient set of Docklight script commands.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值