Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading In A File And Editing It

Status
Not open for further replies.

bcbm

Technical User
Sep 21, 2004
41
US
I'm trying to get a file in, something short the whole output is currently only 21 lines. It may contain a line that will show an alarm for some equipment. I tried the fget command and it did not seem to work. Can anybody point me in the direction of what commands to use to get the file read into memory and then figure out if there is an alarm present.
 
Here is a file that will read a text file in, line by line, to the end:

proc main
string sLine

fopen 0 "file.txt" READ TEXT
while not feof 0
fgets 0 sLine
if strfind sLine "alarm"

endif
endwhile
endproc

Of course, you'll need to modify file.txt with the path and name of the file you want to open.

The if strfind command will check each line of text for the string alarm. You would want to place whatever commands need to be executed when an alarm is found between if strfind and endif lines.


aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top