Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Error handling in Basic4PPC


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-01-2008, 09:52 PM
Knows the basics
 
Join Date: Apr 2008
Location: Duesseldorf, Germany
Posts: 71
Default Error handling in Basic4PPC

Hello,

i want prevent users from getting error message boxes, that contain cryptic error messages or even such with no error description.Therefore i tried a bit with the B4P error handler.This is working, if it's been triggered i still do not know what the exact error was and therefore cannot take the appropriate measure to continue.All i then can assume is: in this sub an error has occured.

Question: is there a chance to get the error description the error popup is presenting to the user..? if not, how do you handle errors in your code and how do you catch them..?

In certain other dialects i used to use a structure like this:

if function(arguments)
...
do something that depends on function
...
Else
...
do some corrective code here
MsgBox("file cannot be opened !")
end if

Why do B4P functions or routines not give back a return code of true or false..? Or do they..? My own created do and can be handled like outlined, by use of the Return directive.

Any other ways or suggestion how to handle that effectively..?



kind regards

TWELVE
Reply With Quote
  #2 (permalink)  
Old 05-01-2008, 10:10 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,092
Default

Error handling in B4PPC is done using the Errorlabel method...
Taken from the B4PPC Helper:

Quote:
Sets a label that the program will jump to in case an error will occur in the current sub,
Syntax: ErrorLabel (Label)
Example:
Sub OpenFile
ErrorLabel (errHandler)
FileOpen (c,"data.dat",cRead)
Return
ErrHandler:
Msgbox("Can't open file.")
End Sub
Since the Error code or description seem to be "intalation" dependant, (it seems that we need to actually install the errorcode reference file....) there is not currently available way to trap specific errors, but we can do some fancy coding and cascade a series of errorlabels, to try to catch an error at a specific code line or block...
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD
Reply With Quote
  #3 (permalink)  
Old 05-02-2008, 07:56 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,314
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Quote:
Originally Posted by TWELVE View Post
Why do B4P functions or routines not give back a return code of true or false..?
This is a deliberarate design feature of the CLR. Errors are handled by throwing exceptions and catching them by error-handling code, similar to C++. Every B4PPC Sub actually has an exception handler, it is this which puts up the message box when an error occurs. Using Errorlabel replaces this default handler with your own code. Unfortunately, at the moment, there is no way to detect which exception has occurred.

Recently I made a suggestion to Erel about this and he has agreed to put a facility in the next release of B4PPC which will provide low-level access to the exception details. In anticipation I have the library and help file/tutorial ready.
Reply With Quote
  #4 (permalink)  
Old 05-02-2008, 09:57 AM
Knows the basics
 
Join Date: Mar 2008
Location: germany
Posts: 77
Default

Hello TWELVE,

Quote:
Originally Posted by TWELVE View Post
Why do B4P functions or routines not give back a return code of true or false..? Or do they..? My own created do and can be handled like outlined, by use of the Return directive.
TWELVE
There are no functions in Basic4ppc but instead every sub can return a value
with the keyword "Return"

Sub Mean (a,b)
Return (a+b)/2
End Sub

Greatings mamuen
Reply With Quote
  #5 (permalink)  
Old 05-04-2008, 10:44 AM
Knows the basics
 
Join Date: May 2007
Posts: 63
Default

Quote:
Originally Posted by agraham View Post
Recently I made a suggestion to Erel about this and he has agreed to put a facility in the next release of B4PPC which will provide low-level access to the exception details. In anticipation I have the library and help file/tutorial ready.
You are really amazing agraham!

Murat
__________________
PC: Laptop CoreDUo, Windows XP SP2 French
PPC: TyTN, WM5 French -> iPAQ 214 WM6 French (to diverge or not to diverge,...)
Reply With Quote
  #6 (permalink)  
Old 05-04-2008, 05:57 PM
Knows the basics
 
Join Date: Apr 2008
Location: Duesseldorf, Germany
Posts: 71
Default

Yas, this guy is really invaluable for this community...

cheers

TWELVE
Reply With Quote
  #7 (permalink)  
Old 05-04-2008, 06:04 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,314
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Aw shucks guys - Shuffles feet embarrassedly. I do really only do this for the fun of it and to let other people have the benefit of my (too many ) years of exxperience
Reply With Quote
  #8 (permalink)  
Old 05-05-2008, 04:52 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,780
Default

Quote:
Originally Posted by TWELVE View Post
Yas, this guy is really invaluable for this community...

cheers

TWELVE
Reply With Quote
  #9 (permalink)  
Old 05-14-2008, 06:56 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,314
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

The promised Exception handling library is now posted
Exceptions handling library
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Serial port handling mjcoon Questions & Help Needed 5 06-26-2008 10:48 AM
"more replies below current level" handling John F. Eldredge Forum Discussion 3 06-02-2008 06:28 PM
Exceptions handling library agraham Additional Libraries 5 05-28-2008 11:52 AM
Menu handling with hardware keys miklquick Questions & Help Needed 8 07-13-2007 06:58 PM
Exception Handling Astragali Questions & Help Needed 2 05-23-2007 12:44 AM


All times are GMT. The time now is 09:09 PM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0