; This script relies on the FileIO function
Call '%KIXLIBPATH%\FileIO.kxf'
$FPath = 'c:\temp\' ; location of file(s)
$File = 'test.txt' ; name of file
$aData = FileIO($FPath + $File, 'R') ; read the original file
$aData = Join($aData, @CRLF) ; Combine into a single string
$aData = Split($aData, Chr(12)) ; break on FormFeed chars
; This block will break the original file into separate files per page
; This solves the original request, but is not needed to continue
; to the next section which checks for data after a specific string
; on each page
For $Page = 0 to UBound($aData) ; enumerate pages
$SubFile = Right('0000' + $Page, 4) + '_' + $File ; create page filename "0000_filename.txt"
$aSubData = Split($aData[$Page],@CRLF) ; create array of lines for current page
$ = FileIO($FPath + $SubFile, 'W', $aSubData) ; write the sub-file
Next
; at this point, we have an array of pages as a simple string
; Using a similar logic block, we can search each page for a string and then check the next two lines
For $Page = 0 to UBound($aData) ; enumerate pages
$aSubData = Split($aData[$Page],@CRLF) ; create array of lines for current page
$SearchStart = AScan($aSubData, 'findme', 1, , 1) ; locate the line with the search phrase
If $SearchStart ; was it found? will be zero if not
; the search phrase was found in the current page on the line represented by $SearchStart
; Check the next two lines for data, but only if at least 2 more lines are present on the page
If UBound($aSubData) >= $SearchStart + 2
If $aSubData[$SearchStart + 1] ; FindMe + 1 has data
; do something, such as
'Page ' ($Page + 1) ' - search line 1 contains ' $aSubData[$SearchStart + 1] ?
EndIf
If $aSubData[$SearchStart + 2] ; FindMe + 2 has data
'Page ' ($Page + 1) ' - search line 1 contains ' $aSubData[$SearchStart + 2] ?
; do something
EndIf
EndIf
EndIf
Next