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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with search a text in a file text

Status
Not open for further replies.

eparada

Programmer
Oct 24, 2013
1
US
Hi everybody

I have this code


fopen 0 "c:\5140TXT\5140.txt" READ TEXT
while not feof 0
fgets 0 sLine
if strfind sLine "Running bank : B,Bank package version: saos-06-10-10-0009,Standby bank : A,Bank package version: saos-06-10-10-0009"
goto Good
else
goto Bad
endif
endwhile
pause 3

first I create a filename 5140.txt after open this file for read the content of this file but I have this problem when I use the strfind to search this lines ("Running bank : B,Bank package version: saos-06-10-10-0009,Standby bank : A,Bank package version: saos-06-10-10-0009") don't jump with the goto to the label correct for example if is true must be Jump to the label Good and if is False must be jump to the label Bad but always althougth this strings are correct jump to the label Bad and I don't know if this is the way correct for search many lines.
 
Does your 5140.txt file have only one line, or can there be multiple lines in that file? The way the script is written now, it will only check the first line of that file and then jump to either the good or bad label. A better way to do this would be to use a variable that can be set to a value such as 1 if a match was found using the strfind command, then that value is checked after the file has been read and then acted upon. Here's a reworked version of the script that does this:

proc main
string sLine
integer iVal = 0

fopen 0 "c:\5140TXT\5140.txt" READ TEXT
while not feof 0
fgets 0 sLine
if strfind sLine "Running bank : B,Bank package version: saos-06-10-10-0009,Standby bank : A,Bank package version: saos-06-10-10-0009"
iVal = 1
exitwhile
endif
endwhile
pause 3
if iVal == 1
;string found, do things
usermsg "good"
else
;string not found, do other things
usermsg "bad"
endif
endproc

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top