Backward searches a string from a file.
filestrseek2 <file handle> <string>
Searches for <string> in the file specified by <file handle>.
The search is done backward and started from the current position of the file pointer. For the forward search, use the "filestrseek" command.
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.
If <string> is not found, the file pointer is not moved and "result" is set to zero.
If the file pointer is already zero before the execution of this command, "result" is set to zero.
; Open the file "teraterm.log". The file pointer is set to the end of file. fileopen fhandle 'teraterm.log' 1 :next ; Backward search for the string "abc" filestrseek2 fhandle 'abc' if result=0 goto not_found ; mark the file pointer filemarkptr fhandle ; Read characters from the character just before "abc" to the end of the line. filereadln fhandle str ; recall the file pointer fileseekback fhanlde ; search for the next word goto next :not_found fileclose fhandle