| Subject |
PRG keeps looping back to start |
| From |
Gaetano De Luisi <gaetanodd@hotmail.com> |
| Date |
Fri, 10 Jul 2020 21:22:51 -0400 |
| Newsgroups |
dbase.getting-started |
I have a do while loop to cycle through records to look for missing records for a time interval while .not.eof()
From what I can tell, the initial DO WHILE loop EOF() condition evaluates to TRUE because the msgbox("End of do while was reached","Warning",64) does get triggered
Nevertheless, after that msgbox is closed, the whole PRG file executes again instead of exiting. If there was a failure in the logic and EOF was never reached, I could understand that the routine would go in loops forever, but I cannot understand what triggers the loop-back to the start of the routine even though the DO WHILE does end and I do see the "GAP Found" timestamp value progressing to the last record.
FYI, the reason I delete some records at the start is to create the gaps, because when there are no gaps, the code executes as expected, the logfile contains the timestamp of when it was run and "No gaps found!", and the program doesn't go back to the start of the routine once the last record is reached.
What am I doing wrong?
//integrity checks
//log gaps in interval data
use energydata.dbf order etimestamp excl
goto top
delete all for Mins=55
pack
goto top
nCurrDay = dd
nCurrMins=Mins
skip 1
nNextDay = dd
nNextMins=Mins
//create a logfile and store the rundate
logString=DTTOC(datetime())
logFile = "dataGroomLog.txt"
f=new file()
if f.exists(logFile)
f.open(logFile,"A")
else
f.create(logFile)
endif
f.writeln(LogString)
logString="no gaps found!" //if no gaps are found, this is what will be logged
do while .not. eof()
nCurrDay=nNextDay
nCurrMins=Mins-5
Do while nCurrDay=nNextDay
if nNextMins=nCurrMins+5 //all good, just the next 5 mins interval, update vars, skip and keep looping
nCurrmins=nNextmins
nCurrday=nNextday
skip 1
nNextmins=Mins
nNextday=dd
elseif nNextMins=nCurrMins-55 //all good, it's just a new hour, update vars, skip and keep looping
nCurrmins=nNextmins
nCurrday=nNextday
skip 1
nNextmins=Mins
nNextday=dd
else // if it's neither a next 5 mins nor a new hour, it's a gap
msgbox("Gap found for timestamp: "+ eTimeStamp+"--nCurrMins="+nCurrMins+"--nNextMins="+nNextMins,"Warning",64)
//since a gap was found, update logString to the timestamp of the record and log it in a log file, update vars, skip and keep looping
logString=DTTOC(eTimeStamp)
f.writeln(logString)
//update vars and move pointer to the next record
nCurrmins=nNextmins
nCurrday=nNextday
skip 1
nNextmins=Mins
nNextday=dd
endif
enddo
enddo
f.writeln(logString)
msgbox("End of the main DO WHILE was reached","Warning",64)
close all
release all
return
|
|