Hi Viktor, hi Klas, hi all,
okay, my fault. I can't recontruct now, why I had the impression that the
ERRORBLOCK() has to be in ERRORSYS.PRG. It just works also in ERRORLIN.PRG.
I attach my ERRORLIN.PRG. It gives more information about the error than
/src/rtl/errsys.prg and uses some memvars in my program to retrieve the current
database and add some function for correction. Sorry, it is not hbformated.
I solved the "APPEND FROM" error like this:
cfile is the file that should be updated, which could have an error in database
structure.
The function fbasis(cfile) gives the name of an empty database with the right
database structure corresponding to cfile.
-----------------
function fappendfrom(cfile)
memvar cErrFile
cErrFile := cfile
begin sequence
append from (cfile)
recover
fdbfehler(cfile)
cErrFile := ""
end sequence
return .t.
function fdbfehler(cfile)
local nselect,astruct1,astruct2,vdbf2
local nn1,nn2,nn3,nn5,nn6
local cfieldname,vfeldinhalt
*
close all
*
nselect := select()
select 1
use (cfile) alias orig exclusive
pack
nn1 := fcount()
nn5 := lastrec()
astruct1 := DbStruct()
*
select 99
vdbf2 := fbasis(cfile)
ferase("tmp.dbf")
copyfile(vdbf2+".dbf","tmp.dbf")
if !file("tmp.dbf")
? "can not create temporary database tmp.dbf"
return .f.
endif
use ("tmp.dbf") alias new exclusive
for nn2 := 1 to nn5
append
next
astruct2 := DbStruct()
for nn2 := 1 to nn1
for nn3 := 1 to len(astruct2)
if fieldname(nn3) == astruct1[nn2,1] ;
.and. fieldtype(nn3) == astruct1[nn2,2] ;
.and. fieldlen(nn3) == astruct1[nn2,3] ;
.and. fielddec(nn3) == astruct1[nn2,4]
cfieldname := fieldname(nn3)
for nn6 := 1 to nn5
select 1
go nn6
select 99
go nn6
vfeldinhalt := orig->&cfieldname
fReplace("new",cfieldname,vfeldinhalt)
next
endif
next
next
close all
select(nselect)
return .t.
function fReplace(cdbf,cfeld,cinhalt)
replace &cdbf->&cfeld with cinhalt
return nil
----------------
Best regards
Claudia (still learning)