This new Library (with only 2 commands) is an enhancement to the OnError-library from Purebasic.
Introduction:
If you are familar with Java or C++, you remember the Errorhandling via Try-Catch-Finally Commands.
For Example
Code: Select all
Try{
CopyMemory();}
Catch{
printf("error");}
Finaly{};
If CopyMemory fails, the Printf-procedure is called.
And that is the same way it works in Purebasic now.
Code: Select all
If TryError()
CopyMemory(1,0,10)
else
Messagerequester("Info","CopyMemory fails",0)
endif:EndTryError()
The TryError() and EndTryError() can be interlocked.
There is no real Helpffile available for those 2 new commands, but they are easy to use .
Download: http://home.pages.at/purefan/libraries/ ... ycatch.zip
Another example:
Code: Select all
If TryError() ;The Try-section begins
Null.l=0
Ergebnis.l = 123 / Null
Else ;Catch-Section,
Debug "Division by zero!"
EndIf:EndTryError()
Using the library is easy, less bloated(1Kb in exe) and its freeware (Pure 3.7.x is recommented)
The TryCatch-Library is written and (c) by PureFan and some Parts by me ,Siegfried Rings . Have fun tackling Errors !