Is there something simple that I don't understand about fetching, marking, or changinging redords? The following code gives predictable traced record number order for a small sample of six records when the asterisked ('****) line is commented out.
When the ('****) line is enabled, the trace order is tangled...more than ten passes through the WHILE loop with erratic record number order. Several times there is no apparent record pointer move for the AdTable.fetch_prev() and the AdTable.fetch_next() statements in the second half of the IF...END IF construct at the bottom of the WHILE loop.
CODE:
' This code eliminates duplicate Adinfo but updates old phone, Status
' and firstDate info from the original (oldest) records before deleting.
tblchoice = ui_get_radio("Select Table to Index in Ad order",1,"chrontemp","chronads","chrontest")
IF tblchoice = "" 'If user presses Cancel...
END ' end the script.
END IF
AdTable = table.open(tblchoice)
Table.index_create_begin(tblchoice,"Substr(AdInfo,1,100)+AdDate")
Adx = AdTable.index_create_end()
AdTable.Fetch_First()
trace.write(" First "+str(AdTable.recno()))
while .not. AdTable.fetch_eof()
vAdInfo = Substr(AdTable.AdInfo,1,100)
' vSource = AdTable.Source 'older Source not wanted
vAdDate = AdTable.AdDate
vFirstDate = AdTable.FirstDate
vStatus = AdTable.Status
vPhone1 = AdTable.Phone1
vPhone2 = AdTable.Phone2
AdTable.fetch_next()
trace.writeln(" Compare To "+str(AdTable.recno()))
if AdTable.fetch_eof()
exit while
end if
if Substr(AdTable.AdInfo,1,100) == vAdInfo 'duplicate Ad
trace.write(" Dupe")
AdTable.change_begin(.t.) 'save desired older field data
' AdTable.Source = vSource 'keep newer Source as is
' AdTable.Phone1 = vPhone1 'keep older phones in case they were...
' AdTable.Phone2 = vPhone2 ' changed from AdInfo in older data
' AdTable.FirstDate = vFirstDate
' if AdTable.FirstDate
When the ('****) line is enabled, the trace order is tangled...more than ten passes through the WHILE loop with erratic record number order. Several times there is no apparent record pointer move for the AdTable.fetch_prev() and the AdTable.fetch_next() statements in the second half of the IF...END IF construct at the bottom of the WHILE loop.
CODE:
' This code eliminates duplicate Adinfo but updates old phone, Status
' and firstDate info from the original (oldest) records before deleting.
tblchoice = ui_get_radio("Select Table to Index in Ad order",1,"chrontemp","chronads","chrontest")
IF tblchoice = "" 'If user presses Cancel...
END ' end the script.
END IF
AdTable = table.open(tblchoice)
Table.index_create_begin(tblchoice,"Substr(AdInfo,1,100)+AdDate")
Adx = AdTable.index_create_end()
AdTable.Fetch_First()
trace.write(" First "+str(AdTable.recno()))
while .not. AdTable.fetch_eof()
vAdInfo = Substr(AdTable.AdInfo,1,100)
' vSource = AdTable.Source 'older Source not wanted
vAdDate = AdTable.AdDate
vFirstDate = AdTable.FirstDate
vStatus = AdTable.Status
vPhone1 = AdTable.Phone1
vPhone2 = AdTable.Phone2
AdTable.fetch_next()
trace.writeln(" Compare To "+str(AdTable.recno()))
if AdTable.fetch_eof()
exit while
end if
if Substr(AdTable.AdInfo,1,100) == vAdInfo 'duplicate Ad
trace.write(" Dupe")
AdTable.change_begin(.t.) 'save desired older field data
' AdTable.Source = vSource 'keep newer Source as is
' AdTable.Phone1 = vPhone1 'keep older phones in case they were...
' AdTable.Phone2 = vPhone2 ' changed from AdInfo in older data
' AdTable.FirstDate = vFirstDate
' if AdTable.FirstDate
Comment