I had you change the first cursor name to something different so the rest of your code would work with the TempDBF cursor name.
Your original code was:
create cursor tempdbf from array dbf_struc
select tempdbf
Which gives the same result as:
create cursor tempcrs from array dbf_struc
select tempcrs
use dbf() again in 0 alias tempdbf && working with TempDBF as before
use && closes the tempcrs cursor, but tempdbf is now open
select tempdbf
When you created your meta data, did you use the COPY STRUCTURE TO SOMEFILE EXTENDED command? If so other properties get included in the data -- like default values, field and table rules, etc. These all get inherited by the cursor and could be the culprit of the problem.
I was not sure if the original cursor you created as TempDBF was RO or not, but I do know the work around code above will assure the cursor is RW.
>Thanks Mark,
>
>But now I get the error
>
>REbuild found an error it couldn't fix in file: contact.dbf
>Error #13: Alias 'tempcrs' is not found
>
>Here is my modified code:
>
>* 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 tempcrs from array dbf_struc
> select tempcrs
>
> use dbf() again in 0 alias tempdbf && makes cursor RW instead of RO
> use
> select tempdbf
> go top
>
>
>* Copy the data from the old table into the new structure
> ? "Copying old data"
> if file(currdbf)
> 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
>
>Tyler
Mark McCasland
Midlothian, TX USA