I am wondering if my script is doing too much work, and would like to know if there is a cleaner way of doing this.
I am saving the scrollback buffer to a file, and later I try to extract a block of information from this file. (I have no way of knowing the block size, which can range from 2 to 50 lines, from response to response). All I know is the string in the beginning of the block and at the end. Here is a sample:
Thank you.
I am saving the scrollback buffer to a file, and later I try to extract a block of information from this file. (I have no way of knowing the block size, which can range from 2 to 50 lines, from response to response). All I know is the string in the beginning of the block and at the end. Here is a sample:
Code:
proc main
string strLine
fopen 0 "c:\temp.txt" READ ; File with original data
fopen 1 "c:\newtemp.txt" CREATE ; File with extracted data
while not feof 0
fgets 0 strLine ; get a single line of data
if strfind strLine "XX" ; find beginning of block
fputs 1 strLine ; save beginning of block
while not feof 0 ; loop withing the block
fgets 0 strLine ; continue getting data
if strfind strLine "&" ; look for end of block
fputs 1 strLine ; save end of block
exitwhile ; done extracting block
else
fputs 1 strLine ; keep writing block
endif
endwhile
exitwhile ; done with file
endif
endwhile
fclose 0
fclose 1
endproc
Thank you.