Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
On error do .... creates problems
Message
From
06/06/2010 14:22:23
 
 
To
06/06/2010 13:49:11
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01467471
Message ID:
01467571
Views:
33
Is mydata a table (.dbf) inside a database (.dbc)? Or is it a free table (.dbf)?

What if you try:
IF FILE(FULLPATH('mydata.dbf'))
    =MESSAGEBOX( [Found mydata: ] +FULLPATH('mydata.dbf'))
	try
	   USE mydata
	catch TO loOneError
	   lcError = ;
	   [Error opening mydata ] ;
		+ CHR(13) + [Error# ]+ ALLTRIM(STR(loOneError.ERRORNO)) ;
		+ CHR(13) + [Procedure: ] + loOneError.PROCEDURE ;
		+ CHR(13) + [Line No: ] + ALLTRIM(STR(loOneError.LINENO)) ;
		+ CHR(13) + [Error Message: ] + IIF(TYPE('loOneError.Message')='C',loOneError.MESSAGE,'') ;
		+ CHR(13) + [Details: ] + IIF(TYPE('loOneError.Details') = 'C',loOneError.DETAILS,'') ;
		+ CHR(13) + [Code: ] + IIF(TYPE('loOneError.LineContents') = 'C',loOneError.LINECONTENTS,'')
		=MESSAGEBOX(lcError,0+16+4096,"Error")
	ENDTRY
ELSE
	=MESSAGEBOX('mydata.dbf does not exist')
ENDIF
>Thanks TC i just tried your code. BTW Nothing actually appears as an error because there is no error, simply that vfp asks me what databse table i want to open. That being said however, with your code in place, the task that normally fails did not invoke the VFP window this time around and the files were found. I don't know if that tells you anything.
>
>k
>
>>>I have a problem that has just surfaced and have found the source of the problem but not a workable solution nor a why.
>>>
>>>1) When i set error to default (on error) - everything works fine. In my first program i open a database to inspect for information thus
>>>(close all databases)
>>>use mydata
>>>do something
>>>
>>>Here's the problem
>>>2) When i set error to a program (example on error do erroralert.)
>>>(close all databases)
>>>use mydata
>>>do something
>>>
>>>the program cannot find the database and a window opens asking to select the database to open. It opens the correct directory, the database is there clearly visible, but i have to manually select it. Same thing when i try to copy databases - cannot find the database. There is NO error message that comes up - my error handing program does not even kick in. It's like it can't make the connection between the written program instruction and the database it is instructed to open.
>>>
>>>Yet set errror to default, and everything works fine.
>>>
>>>Why have i survived all these years without this problem - there is the only new aspect i have created and that is a .CDX for auto-complete. Could it be this is interfering with the search for database yet why does it not have the problem when the error is at default.
>>>
>>> My current solution is to simply accept default error - not a practical one since default pops out of the program when an error occurs.
>>>
>>>Any ideas??
>>>
>>>many thanks if you can help me out of this.
>>>
>>>K
>>
>>What message do you receive if you try this:
>>
>>
>>*--Use this simple error handler to read the message
>>ON ERROR DO OnErrorHandler WITH ERROR(), MESSAGE(), MESSAGE(2)
>>
>>*--Add this function to your main program
>>FUNCTION OnErrorHandler(lnErr, lcMsg, lcMsgMore)
>>
>>IF TYPE("lcMsg")<>"C"
>>    lcMsg = ""
>>ENDIF
>>IF TYPE("lcMsgMore")<>"C"
>>    lcMsgMore = ""
>>ENDIF
>>IF TYPE("lnErr")<>"N"
>>    lnErr = 0
>>ENDIF
>>
>>MessageBox('Error ' + TRANSFORM(m.lnErr) + ;
>>       ', "' + m.lcMsg + '" handled by ON ERROR routine.' + ;
>>       ' More info: ' + m.lcMsgMore)
>>
>>
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform