I am having troubles figuring out a rebuild program that I am using. I keep getting Error #111. Cannot update cursor.
Here is what I am doing. I am finding which tables are in the datadict and trying to copy the data from the old table into a new structure.
Here is my code.
* Determine which files to Rebuild
if empty(FileList)
select distinct dbf_name, d_template;
from datadict ;
order by dbf_name ;
into cursor dbf_list
else
select distinct dbf_name, d_template;
from datadict ;
where alltrim(dbf_name) $ m.FileList ;
order by dbf_name ;
into cursor dbf_list
endif
* Begin Processing
select dbf_list
scan
* Get table, template, and CDX names
alias = strtran(alltrim(dbf_list.dbf_name),".DBF","")
template = dbf_list.d_template
currdbf = alias+".DBF"
currcdx = alias+".CDX"
* Report progress
activate window files
? currdbf
activate window progress
clear
* Create a back up of this table and index
set safety off
? "Creating backup files:"
copy file (currdbf) to (strtran(currdbf,".DBF",".DB~"))
? " "+strtran(currdbf,".DBF",".DB~")
if file(currcdx)
copy file (currcdx) to (strtran(currcdx,".CDX",".CD~"))
? " "+strtran(currcdx,".CDX",".CD~")
endif
set safety on
* Create the new structure in memory
? "Creating new structure"
select distinct * ;
from datadict ;
where datadict.d_template == template;
having datadict.field_name != "Proxy" ;
into array dbf_struc ;
order by field_ord
create cursor tempdbf from array dbf_struc
select tempdbf
go top
* Copy the data from the old table into the new structure
? "Copying old data"
if file(currdbf) *THIS IS WHERE I GET THE ERROR
append from (currdbf) && This is where we will likely have an error
endif
* If we had an error that couldn't be fixed, Say so and exit.
if GotError <> 0
Wait Window "Rebuild found a problem it couldn't fix in file: "+upper(Currdbf) Timeout 5
wait window "Error #: "+alltrim(str(goterror))+" Message: "+alltrim(message()) Timeout 5
RETURN -1
endif
Any help would be appreciated,
Thanks,
Tyler
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only