PDA

View Full Version : Can add On Error or Try function



xLeaves
11-07-2019, 07:41
Such a function is necessary

Is that I am able to handle errors encountered in the code

Otherwise, when the error occurs, it means the program must quit.

DirectuX
11-07-2019, 10:27
Hi,

some information :https://www.thinbasic.com/public/products/thinBasic/help/html/index.html?error_handling.htm

ErosOlmi
11-07-2019, 19:43
Error handling is an area where thinBasic must evolve.

Biggest problem is not related to runtime errors but errors while parsing source code syntax.
Actually all syntax errors are catched only at runtime so you never know when it can happen.
Also there are many functions where () are optional and others where () is mandatory.

For example the following code is wrong because PrintL and WaitKey keywords are defined inside Console module but Console module is not loaded using USES "Console"
But you will get that error only when you will reach execution of the second line

dim n as Long
Printl n
WaitKey


I'm conscious about that and will work on this trying to improve syntax errors trapping as much as possible during pre-loading phase.

Petr Schreiber
11-07-2019, 21:59
I think it would be nice to have alternative mode of execution, which would "just" check the whole code from syntactical point of view.

What makes it a bit challenging is the design of parsing - it is immediate, and module driven. Each module function directly manipulates parser.

I think in order to improve the situation, syntax definitions need to be added for all the function and then formal check will be possible. It could be very interesting project :)

One of the options could be if the functions in modules would be able to give some metadata to the "checker". That would allow to avoid separate check definitions and module code definitions.

Still, I think, that at the rules would be of two kinds - built in to checkers and the rest loaded from modernised modules.


Petr