📄 ttpmacro.txt
字号:
2 A line which contains <string2> has received.
. .
. .
. .
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.1.33 waitrecv
Format:
waitrecv <sub-string> <len> <pos>
Pauses until a string, which satisfies a condition, is received from
the host, or until the timeout occurs.
The condition is:
The length of the string is <len>, and the string contains
the <sub-string> beginning at the <pos>th character.
For example, if <sub-string> is "def" and <len> is 9 and <pos> is 4,
the string "abcdefghi" satisfies the condition.
If such a string is received, it is saved in the system variable "inputstr".
If the system variable "timeout" is greater than zero, the timeout occurs
when <timeout> seconds have passed. If the "timeout" is less than or equal
to zero, the timeout never occurs.
The "waitrecv" command returns one of the following values in the system
variable "result":
Value Meaning
----------------------------------------------------------------------------
-1 A string, which contains the <sub-string> beginning at the
<pos>th character, has been received, and saved in the
"inputstr", but its length is less than <len> because of
the timeout.
0 Timeout. No string, which satisfies the condition, has
been received.
1 A string, which satisfies the condition, has been received,
and saved in the "inputstr".
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.1.34 xmodemrecv
Format:
xmodemrecv <filename> <binary flag> <option>
Causes Tera Term to receive the file <filename> from the host with the XMODEM
protocol. Pauses until the end of the file transfer.
If the file is a binary file, <binary flag> must be non-zero. If the file is
a text file, <binary flag> must be zero.
<option> specifies the XMODEM option, and can be one of the following:
<option> XMODEM option
--------------------------
1 Checksum
2 CRC
3 1K
others Checksum
Example:
xmodemrecv 'readme.txt' 0 2 XMODEM receive, text file, CRC
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.1.35 xmodemsend
Format:
xmodemsend <filename> <option>
Causes Tera Term to send the file <filename> to the host with the XMODEM
protocol. Pauses until the end of the file transfer.
<option> specifies the XMODEM option, and can be one of the following:
<option> XMODEM option
--------------------------
1 Checksum
2 CRC
3 1K
others Checksum
Example:
xmodemsend 'readme.txt' 1 XMODEM send, checksum
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.1.36 zmodemrecv
Format:
zmodemrecv
Causes Tera Term to receive files from the host with the ZMODEM protocol.
Pauses until the end of the file transfer.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.1.37 zmodemsend
Format:
zmodemsend <filename> <binary flag>
Causes Tera Term to send the file <filename> to the host with the ZMODEM
protocol. Pauses until the end of the file transfer.
If the file is a binary file, <binary flag> must be non-zero. If the file is
a text file, <binary flag> must be zero.
Example:
zmodem 'readme.txt' 0
...............................................................................
4.2 Control commands
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.2.1 call
Format:
call <label>
Calls a subroutine beginning with the <label> line.
Example:
messagebox "I'm in main." "test"
call sub Jump to ":sub".
messagebox "Now I'm in main" "test"
end
:sub Start of the subroutine.
messagebox "Now I'm in sub" "test"
return Go back to the main routine.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.2.2 end
Format:
end
Quits the execution of the macro. TTPMACRO is also closed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.2.3 execcmnd
Format:
execcmnd <statement>
Executes a TTL statement expressed by the string <statement>.
Example:
execcmnd "send 'abc'" Execute the statement "send 'abc'".
execcmnd "a=1"
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.2.4 exit
Format:
exit
Exits the include file and returns to the main file.
Example:
See "4.2.8 include".
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.2.5 for, next
Format:
for <intvar> <first> <last>
...
...
next
Repeats the statements between "for" and "next" until the integer variable
<intvar> has the value <last> at the 'next' statement.
The initial value of the <intvar> is <first>. If <last> is greater than
<first>, <intvar> is incremented by 1 at the 'next' line. If <last> is less
than <first>, <intvar> is decremented by 1 at the 'next' line.
Example:
for i 1 10 Repeat ten times.
sendln 'abc'
next
for i 5 1 Repeat five times.
sendln 'abc'
next
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.2.6 goto
Format:
goto <label>
Moves control to the next line of the <label>.
Example:
goto label Jump to the next line of the ':label'.
...
...
...
:label
send 'abc'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.2.7 if, then, elseif, else, endif
1) Format:
if <int> <statement>
Executes a <statement>, if <int> is non-zero.
Example:
if A>1 goto label If A>1, jump to ':label'.
if result A=0 If result<>0, assign 0 to A.
2) Format:
if <int 1> then
...
(Statements for the case: <int 1> is true (non-zero).)
...
[elseif <int 2> then]
...
(Statements for the case: <int 1> is false (zero) and
<int 2> is true.)
...
...
[elseif <int N> then]
...
(Statements for the case: <int 1>, <int 2>,... and
<int N-1> are all false, and <int N> is true.)
...
[else]
...
(Statements for the case: all the conditions above
are false (zero).)
...
endif
'if' and 'elseif' statements must end with 'then'.
'elseif' and 'else' can be omitted.
'endif' can not be omitted.
Examples:
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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.2.8 include
Format:
include <include file name>
Moves control to the include file.
Example:
----- main file 'main.ttl' ------
i=10
:loop
include 'sub.ttl' Move to the include file.
if i>=0 goto loop
end
----- End of 'main.ttl' ---------
----- include file 'sub.ttl' ----
if i<0 then
messagebox 'error!' 'sub'
exit Go back to the main file.
endif
i = i - 1
----- End of 'sub.ttl' ---------- Go back to the main file.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.2.9 pause
Format:
pause <time>
Pauses for <time> seconds.
Example:
pause 10 Pause for 10 seconds.
pause Time
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.2.10 return
Format:
return
Exits the subroutine and returns to the main routine.
Example:
See "4.2.1 call".
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.2.11 while, endwhile
Format:
while <int>
...
...
...
endwhile
Repeats the statements between 'while' and 'endwhile' while <int> is non-zero.
Examples:
i = 10
while i>0
i = i - 1 Repeat ten times.
endwhile
...............................................................................
4.3 String operation commands
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.3.1 str2int
Format:
str2int <intvar> <string>
Converts the <string> which represents a decimal number to its numeric value.
The value is returned in the integer variable <intvar>. If the string is
converted successfully, the system variable "result" is set to 1. Otherwise,
"result" is set to zero.
Example:
str2int val '123' val=123, result=1
str2int val '123abc' result=0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.3.2 strcompare
Format:
strcompare <string1> <string2>
Compares two strings. Depending on the relation between them, one of the
following result code is returned in the system variable "result":
Relation result
---------------------------------------
<string1> < <string2> -1
<string1> = <string2> 0
<string1> > <string2> 1
Example:
strcompare 'abc' 'def' result = -1
strcompare command 'next'
if result=0 goto label
strcompare command 'end'
if result=0 end
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.3.3 strconcat
Format:
strconcat <strvar> <string>
Appends a copy of <string> to the end of the string variable <strvar>.
Example:
filename = 'c:\teraterm\'
strconcat filename 'test.txt'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.3.4 strcopy
Format:
strcopy <string> <pos> <len> <strvar>
Copies a substring of <string> to the string variable <strvar>.
The substring begings at the <pos>th character in <string>, and its length
is <len>.
Example:
strcopy 'tera term' 6 4 substr substr='term'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.3.5 strlen
Format:
strlen <string>
Returns the length of <string> in the system variable "result".
Example:
strlen 'abc' result = 3
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.3.6 strscan
Format:
strscan <string> <substring>
Searches for <substring> in <string>.
If <substring> is found, its position is returned in the system variable
"result". If <string> contains more than one occurrence of <substring>,
the position of the first one is returned. If <substring> is not found,
"result" is set to zero.
Example:
strscan 'tera term' 'term' result = 6
...............................................................................
4.4 File operation commands
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.4.1 fileclose
Format:
fileclose <file handle>
Closes the file specified by <file handle>.
<file handle> is no longer valid after this command.
Example:
fileclose fhandle
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.4.2 fileconcat
Format:
fileconcat <file1> <file2>
Appends a copy of file <file2> to the end of file <file1>.
<file1> and <file2> must not be same.
Example:
fileconcat 'test.dat' test2.dat'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.4.3 filecopy
Format:
filecopy <file1> <file2>
Copies file <file1> to file <file2>.
If <file2> already exists, it is overwritten. <file1> and <file2> must not
be same.
Example:
filecopy 'test.dat' test2.dat'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.4.4 filecreate
Format:
filecreate <file handle> <filename>
Creates and opens a new file specified by <filename>.
The file pointer is set to the beginning of the file. If file <filename>
already exists, its size is truncated to zero. If the file is successfully
created and opened, the file handle is returned in the integer variable
<file handle>. Otherwise, <file handle> is set to -1.
Example:
filecreate fhandle 'data.dat'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.4.5 filedelete
Format:
filedelete <filename>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -