I know I'm going to feel really dumb when this gets sorted, but right now I can't figure out why the following bit of code won't save to the primary record.
This is only a bit of code to try to come to grips with XBasic (I'm the guy that used to use Dataflex)There is actually another 4000 odd lines of code to go in here but no point in doing that until I can get it save one bit of info.
The set contains 2 dbf's, formdata which is a horses formcard, and racedata which is all the individual runs that horse has had. Racedata has the horses complete history on a race by race basis with each race being one record while formcard is a summary of the horses total racing form showing total number of runs at say, a mile, 6 furlongs, heavy tracks, etc.
As new race results are downloaded each week into the racedata file, the horses form card needs to be updated by adding to the existing formcard the new details of races the horse has run in the last week.
I hope to be able to do this by running a script that will go thru and update the horses that have raced in the preceeding week and then mark the race records as being processed.
I know the code below is working to a point as I have placed trace writeln (removed now) thru it and they all seem to appear the correct number of times based on how many child records there are.
Any help of info would appreciated and thanks in advance
Greg
t1=table.open("d:a5v4racingformcard.dbf") 'Primary Table
t2=table.open("d:a5v4racingracedata.dbf") 'Child Table
t1.index_primary_put("horse")
'Get pointer to primary table of form.set
tbl = table.current()
'Get pointer to child table in the set
table.get("racedata")
t2.fetch_first()
WHILE .NOT. t2.fetch_EOF()
t1.change_begin()
t1.firstuprun+1
t1.change_end(.T.)
t2.fetch_next()
END WHILE
t1.close()
t2.close()
This is only a bit of code to try to come to grips with XBasic (I'm the guy that used to use Dataflex)There is actually another 4000 odd lines of code to go in here but no point in doing that until I can get it save one bit of info.
The set contains 2 dbf's, formdata which is a horses formcard, and racedata which is all the individual runs that horse has had. Racedata has the horses complete history on a race by race basis with each race being one record while formcard is a summary of the horses total racing form showing total number of runs at say, a mile, 6 furlongs, heavy tracks, etc.
As new race results are downloaded each week into the racedata file, the horses form card needs to be updated by adding to the existing formcard the new details of races the horse has run in the last week.
I hope to be able to do this by running a script that will go thru and update the horses that have raced in the preceeding week and then mark the race records as being processed.
I know the code below is working to a point as I have placed trace writeln (removed now) thru it and they all seem to appear the correct number of times based on how many child records there are.
Any help of info would appreciated and thanks in advance
Greg
t1=table.open("d:a5v4racingformcard.dbf") 'Primary Table
t2=table.open("d:a5v4racingracedata.dbf") 'Child Table
t1.index_primary_put("horse")
'Get pointer to primary table of form.set
tbl = table.current()
'Get pointer to child table in the set
table.get("racedata")
t2.fetch_first()
WHILE .NOT. t2.fetch_EOF()
t1.change_begin()
t1.firstuprun+1
t1.change_end(.T.)
t2.fetch_next()
END WHILE
t1.close()
t2.close()
Comment