Well, you don't need an external error handling function. You can embed error handling directly into your main program, like this:
local llError
on error llError = .T.
copy file aaa to bbb
if llError
endif
For example, to retry:
local llError
on error llError = .T.
do while .T.
llError = .F.
copy file aaa to bbb
if llError and MessageBox("Error copying file. Do you want to retry?") = ID_YES
loop
endif
enddo
if not llError
endif
Grüsse,
Hilmar.
>Hi All,
>
>I am encountering a problem while copying the file. I want to track error. Let me explain it to you in breif.
>
>I want to copy file from "C:\Package\Temp\*.dbf" to "H:\Package\Data" folder. While copying there might be a possibility of network connection loosing or the folder is not present or something like this. I want to track when the copying is now possible and want to display a messagebox and ask the user to retry or cancel. If the user says retry then the copying should happen again.
>
>To test this I have written a small prg as given below
>
>
>lnI = 1
>ON ERROR DO Onerror WITH ERROR( ), MESSAGE( ), MESSAGE(1), PROGRAM( ), LINENO( )
>Do while .T.
> Do Case
> Case Mod(lnI,2) = 1
> Copy File "C:\Package\Temp\Munir.DBF" To "H:\Package\Data\Munir.DBF"
> Case Mod(lnI,2) = 0
> Copy File "C:\Package\Temp\Munir.DBF" To "H:\Package\Dt\Munir.DBF"
>
> Endcase
> lnI = lnI + 1
>Enddo
>
>
>*--------------------
>OnError.PRG
>*--------------------
>
>PARAMETER merror, mess, mess1, mprog, mlineno
>lnAnswer = Messagebox(merror,21,"Error)
>If lnAnswer = 4
> Retry
>Endif
>
>
>Now when the retry command is fired the control is passed to lnI = lnI + 1 command line but I want to continue copying the file in case Mod(lnI,2) = 0
>
>Can anyone help.
>
>Regards
>
>Munir Solkar
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)