do [ { while | until } <expression> (option)]
...
...
loop [ { while | until } <expression> (option)]
do loop类似于C语言中的do while
; Repeat ten times.
i = 10
do while i>0
i = i - 1
loop
; Send clipboard content.
offset = 0
do
clipb2var buff offset
if buff > 0 send buff
offset = offset + 1
loop while result = 2
while
while <expression>
...
...
endwhile
; Repeat ten times.
i = 10
while i>0
i = i - 1
endwhile
if
if, else, elseif, endif有两种使用方式:
if <expression> <statement>
如if A>1 goto label,另一种方式如下:
if <expression 1> then
...
(Statements for the case: <expression 1> is true (non-zero).)
...
[elseif <expression 2> then]
...
(Statements for the case: <expression 1> is false (zero) and <expression 2> is true.)
...
[elseif <expression N> then]
...
(Statements for the case: <expression 1>, <expression 2>,... and <expression N-1> are all false, and <expression N> is true.)
...
[else]
...
(Statements for the case: all the conditions above are false (zero).)
...
endif
if a=1 then
b = 1
c = 2
d = 3
endif
if i<0 then
i=0
else
i=i+1
endif
if i=1 then
c = '1'
elseif i=2 then
c = '2'
elseif i=3 then
c = '3'
else
c = '?'
endif
for
for <intvar> <first> <last>
...
...
next
for循环的参数按1递增或递减
; Repeat ten times.
for i 1 10
sendln 'abc'
next
; Repeat five times.
for i 5 1
sendln 'abc'
next
函数定义
冒号:开头接函数名,return结尾,中间是函数体
:FunctionName
body
return
调用函数可以使用call指令:call FunctionName
注释
分号;开头的表示注释
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Description : This is a comment
; Author : Guangtao.Wu
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
宏脚本实例
定时重启路由器
; loop reboot, pause 240s
connect /C=3 /BAUD=115200 /F=TERATERM.INI
while 1
sendln "show console"
sendln "reboot"
pause 240
endwhile
end