Hi Frank,
This is not a matter of the language binding but a matter of missing
support in the language.
Call it any way you want :)
As a matter of fact, the scripting language delivered with OOo -
StarBasic - lacks support for one of the most basic features
(exceptions) of one of the central foundations of OOo (UNO).
ACK
Looking at our testtool scripts, which are also written in some kind of
Basic very similar to StarBasic, there are constructs such as
"try/catch" - so it should be possible to implement such things without
too much effort (Don't you also hate those people not having any clue,
but saying "this must be simple!"?). "throw" would be a logical
extension of this.
Indeed this belongs to these famous "this must be simple" problems. :-)
Let's start with the testtool. The testtool Basic is not similar
to OOo Basic, it *is* OOo Basic, extended by some testtool speci-
fic commands and some convenience functionality. The try/catch
belongs to the latter. According to Gregor it's only another syn-
tax for the on error functionality that is supported by Basic any-
way. On error also supports UNO exceptions but in a very limited
way. Every UNO exception is mapped to the Basic Runtime Error 1.
So it's possible to identify an error as UNO exception but it's
not possible to identify which exception it is. Example:
Sub Main
on error goto ErrHdl
a = 0
' print 1 / a
oLib = BasicLibraries.getByName( "Foo" )
exit sub
ErrHdl:
if err = 1 then
print "UNO exception"
else
print "Other error"
end if
End Sub
Assuming there is no Library named Foo this program will print
"UNO exception" as a NoSuchElementExcetption will be thrown.
After uncommenting "print 1 / a" it will print "Other error"
as "Division by zero" has the error code 11.
IIRC there is one main problem to realize a better support, es-
pecially to allow catching specific exceptions: To implement
this in the Basic core a generic catch would have to be used,
as it's not possible to write down catch statements for any
known UNO exception, not to speak of exceptions that will be
designed in the future.
So Basic has to catch a very basic exeption type like:
...
}
catch( Exception& e )
{}
Maybe the problem is solved in the mean time, but at least when
I addressed this problem the first time, there was no way to
get the real (UNO) exception type from e. If there is a way now,
e.g. by using C++ RTTI, the implementation of a better exception
support in OOo Basic really shouldn't be too difficult.
A "throw $UNO-Exception-type" statement is easier anyway, as the
UNO type/reflection API can be used to get a type from the type
name. But also this of course has to be evaluated in more detail.
I seriously think we should address this - for better UNO access in
Basic, and on the medium term probably also for better VBA compatibility.
I agree that better UNO exception support in OOo Basic would be
good, but I don't see the connection to VBA compatibility. VB(A)
does not support exceptions as far as I know, only On Error.
This is different for VB.net but VB.net != VB(A).
Regards
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]