// ---------------------- restore data from original DBF ( backup )----------
FUNCTION NET_RESTORE3(oBrw)
LOCAL lReturn := .F., aData := {}
PACKZAP_1(2) // zap original dbf
// original data
USE CUST_ORG NEW ALIAS "CUSTNEW" SHARED VIA "DBFCDX"
oCustNew := TDataBase():New( Select( "CUSTNEW" ) )
// Read required data into array
cList := "*,RECNO()"
aData := oCustNew:FW_DbfToArray( @cList )
aNew := Array( oCustNew:FCount() + 1 )
AEval( aNew, { |u,i| aNew[ i ] := uValBlank( oCustNew:FieldGet( i ) ) }, 1, oCustNew:FCount() )
nRecNoCol:= Len( aNew )
aNew[ nRecNoCol ] := 0
// Read done close backup
oCustNew:Close()
// write new data to customer.dbf from backup
WITH OBJECT oBrw:oDbf
oCust:FW_ArrayToDbf( aData )
END
oCust:GoTop()
oBrw:SetoDbf(oCust)
oBrw:Refresh()
MSGINFO("Original data restored !")
RETURN (lReturn)
// -----------------
FUNCTION PACKZAP_1(nStyle)
IF oCust:lShared() = .T.
oCust:Close()
oCust := TCustomers():New(.F.) // exclusive
oCust:use()
// MSGINFO( oCust:lShared(),"Shared")
ENDIF
IF oCust:Used()
IF nStyle = 1
oCust:Pack()
MSGINFO("Done Pack")
ELSE
oCust:Zap()
MSGINFO("Done Zap")
ENDIF
ENDIF
oCust:Close()
oCust := TCustomers():New(.T.) // back to shared
oCust:use()
RETURN( NIL)
ukoenig wrote:tested : read from backup and write to original
1. read backup-data to array
2. zap original dbf
3. write backup-data to original
- Code: Select all Expand view RUN
// ---------------------- restore data from original DBF ( backup )----------
FUNCTION NET_RESTORE3(oBrw)
LOCAL lReturn := .F., aData := {}
PACKZAP_1(2) // zap original dbf
// original data
USE CUST_ORG NEW ALIAS "CUSTNEW" SHARED VIA "DBFCDX"
oCustNew := TDataBase():New( Select( "CUSTNEW" ) )
// Read required data into array
cList := "*,RECNO()"
aData := oCustNew:FW_DbfToArray( @cList )
aNew := Array( oCustNew:FCount() + 1 )
AEval( aNew, { |u,i| aNew[ i ] := uValBlank( oCustNew:FieldGet( i ) ) }, 1, oCustNew:FCount() )
nRecNoCol:= Len( aNew )
aNew[ nRecNoCol ] := 0
// Read done close backup
oCustNew:Close()
// write new data to customer.dbf from backup
WITH OBJECT oBrw:oDbf
oCust:FW_ArrayToDbf( aData )
END
oCust:GoTop()
oBrw:SetoDbf(oCust)
oBrw:Refresh()
MSGINFO("Original data restored !")
RETURN (lReturn)
// -----------------
FUNCTION PACKZAP_1(nStyle)
IF oCust:lShared() = .T.
oCust:Close()
oCust := TCustomers():New(.F.) // exclusive
oCust:use()
// MSGINFO( oCust:lShared(),"Shared")
ENDIF
IF oCust:Used()
IF nStyle = 1
oCust:Pack()
MSGINFO("Done Pack")
ELSE
oCust:Zap()
MSGINFO("Done Zap")
ENDIF
ENDIF
oCust:Close()
oCust := TCustomers():New(.T.) // back to shared
oCust:use()
RETURN( NIL)
regards
Uwe
3 I cannot make pack and zap
4. I can only delete all records.
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 26 guests