troubleshooting Question

How to workaround backup routine runtime errors?

Avatar of Eduardo Fuerte
Eduardo FuerteFlag for Brazil asked on
FoxPro
7 Comments3 Solutions398 ViewsLast Modified:
Hi Experts!

Few years ago I've gently obtained here a very util backup routine that works well with  exception of the fact that frequently some errors occurs when it runs (but it still does the job)

Accordingly with the pictures:
img001
and then
img02
The code:
LOCAL cTempZip, cTempPath, cdia, m.drv
LOCAL oTherm, cThermometer

*-- Close forms
=fecha_forms()


*-- maio 2010 Close work areas
FOR i = 1 TO 100
	SELECT(i)
	use
ENDFOR

cTempZip=""
cTempPath=""

m.drv = m.driver+":"+m.diretor
cSource = ADDBS(m.drv) && This is data path

SET CENTURY on

cdia = DTOC(DATE())
cdia = SUBSTR(CDIA,1,2) + SUBSTR(CDIA,4,2) + SUBSTR(CDIA,7)
*--cDestination = m.drv+cdia+".bak"

cDestination = m.drv+cdia+".zip"

cTempZip = m.drv+'temp'+  '.zip'

cThermometer = 'gsThermometerBar'
oTherm = createobject(cThermometer)
oTherm.lblProgress.caption = "Backup dos dados da Livraria"
oTherm.Show()

DECLARE INTEGER Sleep IN kernel32 INTEGER

IF FILE(cTempZip)
	DELETE FILE (cTempZip)
ENDIF

= STRTOFILE(CHR(80) + CHR(75) + CHR(5) + CHR(6) + REPLICATE(CHR(0),18),cTempZip)

DIMENSION aDBFs(1,5)
nCount = ADIR(aDBFs,cSource+"*.*")
oShell = CREATEOBJECT("Shell.Application")
FOR i = 1 TO nCount

	oTherm.Progress1.Value = INT(i/nCount*100)

	cFileName = aDBFs(i,1)
*--	IF UPPER(RIGHT(cFileName,3)) $ "DBF|FPT" AND NOT ("FOX" $ cFileName)

*-- Fev 2011: Salves .CDX also
	IF UPPER(RIGHT(cFileName,3)) $ "DBF|FPT|CDX" AND NOT ("FOX" $ cFileName)
		oTherm.lblProgress.caption = "Backup => "+ cFileName
		cFile = cSource + cFileName
		nCount1 = oShell.NameSpace(cTempZip).Items.Count
		oShell.NameSpace(cTempZip).CopyHere(cFile)
		DO WHILE oShell.NameSpace(cTempZip).Items.Count = nCount1
			= Sleep(100)
		ENDDO
	ENDIF
ENDFOR

oTherm.Release

RELEASE oShell
COPY FILE (cTempZip) TO (cDestination)
DELETE FILE (cTempZip)
CLEAR DLLS

*-- Find where is the pen drive
IF DISKSPACE("E:\") = -1
	IF DISKSPACE("F:\") = -1
		IF DISKSPACE("G:\") = -1
			IF DISKSPACE("H:\") = -1
				MESSAGEBOX("Não há dispositivo de gravação (pen-drive) disponível para salvar os dados !",48,"Erro")
			ELSE
				lcdrive="H:\"
				COPY FILE &cDestination TO &lcdrive
			ENDIF
		ELSE
			lcdrive="G:\"
			COPY FILE &cDestination TO &lcdrive
		ENDIF
	ELSE
		lcdrive="F:\"
		COPY FILE &cDestination TO &lcdrive
	ENDIF
ELSE
	lcdrive="E:\"
	COPY FILE &cDestination TO &lcdrive
ENDIF

*-- Reabre as áreas fechadas para backup

*-- Some clean-up routines

*----------
=montadic()
*----------

*--- Monta os dicion rios de integridades
*----------

=mont_del()

=mont_atr()
*----------

* Ativa o Help
*******
Do Help
*******

*-- reativa toolbar
fotb   = CREATEOBJECT("cls_toolbar")
fotb.show()

return

Open in new window



Could you point a workaround to that?

Thanks in advance!
ASKER CERTIFIED SOLUTION
Pavel Celba
All in One

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 3 Answers and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros