1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
2 |
"http://www.w3.org/TR/html4/strict.dtd"> |
"http://www.w3.org/TR/html4/strict.dtd"> |
3 |
<html> |
<html> |
4 |
<head> |
<head> |
5 |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
6 |
<title>filestrseek2</title> |
<title>filestrseek2</title> |
7 |
<meta http-equiv="Content-Style-Type" content="text/css"> |
<meta http-equiv="Content-Style-Type" content="text/css"> |
8 |
<link rel="stylesheet" href="../../style.css" type="text/css"> |
<link rel="stylesheet" href="../../style.css" type="text/css"> |
9 |
</head> |
</head> |
10 |
|
|
11 |
<body> |
<body> |
12 |
|
|
13 |
|
|
14 |
<h1>filestrseek2</h1> |
<h1>filestrseek2</h1> |
15 |
|
|
16 |
<p> |
<p> |
17 |
Backward searchs a string from a file. |
Backward searchs a string from a file. |
18 |
</p> |
</p> |
19 |
|
|
20 |
<pre class="macro-syntax"> |
<pre class="macro-syntax"> |
21 |
filestrseek2 <file handle> <string> |
filestrseek2 <file handle> <string> |
22 |
</pre> |
</pre> |
23 |
|
|
24 |
<h2>Remarks</h2> |
<h2>Remarks</h2> |
25 |
|
|
26 |
<p> |
<p> |
27 |
Searches for <string> in the file specified by <file handle>.<br> |
Searches for <string> in the file specified by <file handle>.<br> |
28 |
The search is done backward and started from the current position of the file pointer. For the forward search, use the "<a href="filestrseek.html">filestrseek</a>" command.<br> |
The search is done backward and started from the current position of the file pointer. For the forward search, use the "<a href="filestrseek.html">filestrseek</a>" command.<br> |
29 |
If <string> is found, the file pointer is moved to the position of the character just before the string and the system variable "result" is set to 1. However, if the string locates at one byte of the file, the file pointer is zero offset.<br> |
If <string> is found, the file pointer is moved to the position of the character just before the string and the system variable "result" is set to 1. However, if the string locates at one byte of the file, the file pointer is zero offset.<br> |
30 |
If <string> is not found, the file pointer is not moved and "result" is set to zero.<br> |
If <string> is not found, the file pointer is not moved and "result" is set to zero.<br> |
31 |
If the file pointer is already zero before the execution of this command, "result" is set to zero. |
If the file pointer is already zero before the execution of this command, "result" is set to zero. |
32 |
</p> |
</p> |
33 |
|
|
34 |
<h2>Example</h2> |
<h2>Example</h2> |
35 |
|
|
36 |
<pre class="macro-example"> |
<pre class="macro-example"> |
37 |
; Open the file "teraterm.log". The file pointer is set to the end of file. |
; Open the file "teraterm.log". The file pointer is set to the end of file. |
38 |
fileopen fhandle 'teraterm.log' 1 |
fileopen fhandle 'teraterm.log' 1 |
39 |
|
|
40 |
:next |
:next |
41 |
; Backward search for the string "abc" |
; Backward search for the string "abc" |
42 |
filestrseek2 fhandle 'abc' |
filestrseek2 fhandle 'abc' |
43 |
if result=0 goto not_found |
if result=0 goto not_found |
44 |
; mark the file pointer |
; mark the file pointer |
45 |
filemarkptr fhandle |
filemarkptr fhandle |
46 |
; Read characters from the character just before "abc" to the end of the line. |
; Read characters from the character just before "abc" to the end of the line. |
47 |
filereadln fhandle str |
filereadln fhandle str |
48 |
; recall the file pointer |
; recall the file pointer |
49 |
fileseekback fhanlde |
fileseekback fhanlde |
50 |
; search for the next word |
; search for the next word |
51 |
goto next |
goto next |
52 |
|
|
53 |
:not_found |
:not_found |
54 |
fileclose fhandle |
fileclose fhandle |
55 |
</pre> |
</pre> |
56 |
|
|
57 |
</body> |
</body> |
58 |
</html> |
</html> |