Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ignore error prg

Status
Not open for further replies.

jonatan

Programmer
Mar 24, 2003
14
BR
I need help.In some case i need to ignore some error in my program.Usually we must choose cancel,suspend,or ignore right.I don't want it shown if found an error.What i should i do ? It seems like ON ERROR RESUME NEXT in Visual Basic ...

Thanks ....

CS
 
Jonatan

In the following example, an error is used positively to perform an action and then the error handler is reset.

The error dialog will not show.

LPARAMETERS cFolder

IF !DIRECTORY(cFolder)
[tab]ON ERRO cFolder = THIS.cHomeFolder
[tab]MKDIR (cFolder)
[tab]ON ERROR DO ErrorTrap WITH;
[tab][tab]SYS(16),;
[tab][tab]LINENO(),;
[tab][tab]ERROR(),;
[tab][tab]MESSAGE(1),;
[tab][tab]MESSAGE()

ENDI

RETURN cFolder HTH

Chris [pc2]
 
To gracefully handle errors, make your own error trap like above, then depending on the error number, you can choose to RETRY (for instance, obtain a record lock), RESUME (skip the line of code causing th error), CANCEL and so on.
To totally ignore errors, which is an option that should be chosen wisely, you can issue the command:

ON ERROR *

Dave S.
 
You could store the error in a database for viewing at a later time

on error do errtrap with ERROR(), MESSAGE(), MESSAGE(1), PROGRAM(), LINENO()

procedure errtrap
PARAMETER P_Err, P_Msg, P_Msg1, P_Prg, P_Lno
*
* dump data and memory status to text files
*
list status to file data.err
list memory to file memo.err
*
lnWorkArea = select()
do case
case used("ERRFILE")=.t.
select ERRFILE
case file("ERRFILE.DBF")=.t.
select 0
use ERRFILE
otherwise
select 0
create table ERRFILE.DBF (DATE d, TIME c(8), DATA m, MEMO m, option n(1,0))
use ERRFILE
endcase
append blank
replace date with date()
replace time with time()
append memo data from data.err
append memo memo from memo.err
select (lnWorkArea)
return David W. Grewe
Dave@internationalbid.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top