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

script won't read FEOF!!

Status
Not open for further replies.

mailbox125

Technical User
Apr 1, 2003
44
0
0
US
You have been so very helpful in the past I'm sure this is something simple I'm just overlooking.. This script will not recognize the feof 0? and goto the else programming. What have I missed?



string listmbxfile = " "
PROC main
string f_line
string DREFF

clear
capture off
set capture file "STAR-DEL-REFF.txt"
set capture overwrite on
capture on

sdlginput "Information" "Full Path To Saved Text File: " listmbxfile

transmit "U^M"
waitfor "."
transmit "D REF^M"

;Load the txt file
if fopen 0 listmbxfile READ TEXT;

if not FEOF 0
fgets 0 f_line
strextract DREFF f_line "," 0
waitfor "DEL:"
transmit DREFF
transmit "^M"
WAITFOR ":"
transmit "Y^M"
waitfor "DEL:" forever

else
transmit "^M^M"
waitfor "."
transmit "E^M"
waitquiet 1
waitfor ":"
transmit "Y^M^M"

endif


else
errormsg "Couldn't open file '%s'" listmbxfile
endif


capture off
disconnect
endproc
 
Instead of using if I would recommend using a while loop and place the comments in the else clause after the while loop.

One other thing to keep in mind is that the last line read from the file may be null (i.e. just have a carriage return and or linefeed that is stripped by the fopen command). In this case, I use the strlen command to get the length of the string read from the file and use exitwhile to get out of the while loop.


aspect@aspectscripting.com
 
I have also had good luck using a null string test.
if nullstr DREFF
Something to keep in mind...if your input file was originally an Excel file and there were a lot of empty rows before the file was saved (in your case as a comma delimited .csv) then the EOF character can be thousands of rows below the end of your data. The feof test will not be resolved until the script sees the eof character so the nullstr test can be used with or in place of
while not feof.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top