Reputation: 1
I have tried this code to verify the content of file and I was able to read the content, but I should read the word which is immediate to searching word.
For example in the text file I have some 10 lines of content; in the third line I found the searched word, I should read the immediate next line of searched word. Consider this is a text fie content:
Hello
how
are
you
I am
fine
I need to search the word how
is present in the text file , if the how
word is found, I should read/verify the immediate next line of the word.
The output should be are
open file "D:\Automation\EGGPlant\Archiecture\Script-Demo.suite\Resources\Demo.txt"
read from file "D:\Automation\EGGPlant\Archiecture\Script-Demo.suite\Resources\Demo.txt"
put file "D:\Automation\EGGPlant\Archiecture\Script-Demo.suite\Resources\Demo.txt" into WiFiInfo
Repeat the number of lines of WiFiInfo times:
put line repeatindex() of WiFiInfo into output
if output contains "how" then
Log "found"
else
Log "Not found"
end if
end repeat
Expected result should be are
Upvotes: 0
Views: 480
Reputation: 1
Here is the answer to your question
Set dataFile to (file ResourcePath("Test.txt"))
set output to "how" // variable to set with the value "how
split dataFile by newline // all the values from the text file will be split and put into a list so that we can access it based on it position
repeat each item of dataFile
if item repeatindex() of dataFile contains output then // statement check each item with the variable which is containing "how"
log item repeatindex()+1 of dataFile // repeatindex()+1 will point the next index of current index
exit repeat // Repeat will exit once the condition is true
end if
end repeat
Upvotes: 0