Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help on Error Handling (VFP6)
Message
 
To
09/11/2004 07:54:00
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Conferences & events
Environment versions
Visual FoxPro:
VFP 6
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00959475
Message ID:
00959536
Views:
6
Hilmar i think your code for retry will be etarnal
should be like this
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
  exit
enddo
>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
>  * There was an error. Now what?
>endif
>* Continue processing from here
>
>
>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
>* Continue processing from here
>if not llError
>  * File was copied without error. Now, continue.
>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"
>>                   &&Error since dt folder is not prsent
>>    Endcase
>>    lnI = lnI + 1
>>Enddo
>>
>>
>>*--------------------
>>OnError.PRG
>>*--------------------
>>
>>PARAMETER merror, mess, mess1, mprog, mlineno
>>lnAnswer = Messagebox(merror,21,"Error)
>>If lnAnswer = 4 && RETRY
>>    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
.......
DO WHILE .T.
      ME.Work()
ENDDO
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform