With STYX there is a function called:
ERROR TRAPPING OFF
ERROR TRAPPING OFF
` Turns DarkBasic Pro's error trapping off. This catches runtime errors that may occur in the code section that follows this command up to the next occurence of ERROR TRAPPING ON. Note that this only covers most runtime errors of native DarkBasic Pro commands. It will eventually not handle runtime errors that occur in the Enhancement Packs or in Third Party Commands.
` Important: Do not use ERROR TRAPPING OFF to cover large blocks of code. Use it only to trap runtime errors in error prone commands, ie. those which deal with file operations (LOAD IMAGE, OPEN TO READ, etc.). You can call GET LAST ERROR() to determine if an error has occured while error trapping was switched off.
` Important: Not all runtime errors are caught. Use it only for things you cannot check otherwise (for example: loading media).
` ARGUMENTS:
` *none*
` SYNTAX
ERROR TRAPPING OFF
and
ERROR TRAPPING ON
ERROR TRAPPING ON
` Turns DarkBasic Pro's error trapping on. See ERROR TRAPPING OFF for more details.
` ARGUMENTS:
` *none*
` SYNTAX
ERROR TRAPPING ON
and
GET LAST ERROR
GET LAST ERROR
` Call GET LAST ERROR to determine if an error has occured while Error Trapping was turned off. The returned value is either 0 i no error occured or an error number.
` ARGUMENTS:
` *none*
` RETURNS:
` Returns either 0 (no error) or an error number.
` SYNTAX
Return Integer=GET LAST ERROR()
and
RAISE ERROR
RAISE ERROR
` Raises an error of a given number. This can be useful for debugging purposes.
` ARGUMENTS:
` * Error Number = the error number that will be raised.
` SYNTAX
RAISE ERROR Error Number
[Typos in the code above is not that of mine, I simply copy+pasted]
To give an explanation of how you would use this functionality...
First lets say you have a block of code that you either wish to test against, but allow the program to continue past and run the rest of the program... or a section of code you are certain may be prone to error based on external events for example...
This is the code sample that comes with STYX, I have yet to get the raise error to work, but it is a life saver to stop the application dying...
remstart
This demo demonstrates how to use the ERROR TRAPPING commands in
Styx. These are especially useful if your program needs to deal
with media that is only known during runtime and maybe corrupted.
In this demo we attempt to load an image. Provided are two examples
one valid windows bitmap and one "corrupted" file. Unless you switch
the error trapping off DarkBasic Pro will raise a run time error
when attempting to load that image.
remend
cls
rem an open file dialog
Result = EXECUTE OPEN DIALOG("Load an image...", Get Dir$(), "Bitmap (*.bmp)|*.bmp", "")
if result = 1 then fname$ = OPEN DIALOG FILENAME()
rem switch error trappin off
ERROR TRAPPING OFF
Load Image fname$, 1
ERROR TRAPPING ON
If GET LAST ERROR() = 0
Paste Image 1, 0, 0
Else
Print "Can't load image. Maybe it's a corrupted file..."
EndIf
Wait Key
Although it says it is intended for CORE FUNCTIONS...
An example from me would be, say you was using DarkPhysics... and you had your program in a modular fashion and did not look at your start block, where you would place the call to "PHY START" and later you created a call to make an object into a PHY object by calling PHY MAKE RIGID BODY DYNAMIC BOX, I would place the error trapping before this and then turn it back on after, the program will not die and you will see that the effect was not applied... you could then apply your own error calls in your own way for such accounts and still resume the application...
I plan to make EEVs on this, so stay tuned
I do not know if Matrix1Utils has such a feature, but you are welcome to check into that yourself...
Hope this helped...