[Gambas-user] TRY bug example

nando nando_f at ...951...
Sat Dec 10 08:21:00 CET 2005


Benoit,

This is causing me a bit of trouble..and narrowed it down.


Example 1:
-------------------------------------------------------------
PUBLIC SUB Form_Open()

PRINT ERROR
TRY RMDIR "/home/stupid"    'make sure stupid does not exist
PRINT ERROR
PRINT "HELLO: " & ERROR & " is the error"
TRY RMDIR "/home/stupid"
TRY PRINT "HELLO: " & ERROR & " is the error"

END



Output I get on Console:
-------------------------------------------------------------
False
True
HELLO: T is the error   <---  Error shown as T and not True
HELLO:  is the error    <---  The T or F value for ERROR is missing 



Example 2:
-------------------------------------------------------------
Also, include TRY on the first and third lines and the output
gets more wierd...

PUBLIC SUB Form_Open()

TRY PRINT ERROR
TRY RMDIR "/home/stupid"
TRY PRINT ERROR               'Error should be true from previous line
PRINT "HELLO: " & ERROR & " is the error"
TRY RMDIR "/home/stupid"
TRY PRINT "HELLO: " & ERROR & " is the error"

END

Output is...
------------------------------------------------------------

False
False            <---- I expected True ...see question 3 below.
HELLO:  is the error  <--- What is the error?
HELLO:  is the error


--------------------------------------------------------------------
Questions ??
(1) Why does ERROR print out as False or True but sometimes is T or F ??
(2) Why is ERROR blank sometimes ??
(3) Is printing ERROR within a TRY statement showing the previous ERROR ?
    I'm thinking TRY PRINT can never make ERROR TRUE so that PRINT shouldn't
    affect ERROR.
(4) Is it mandatory to ERROR.CLEAR after every TRY ??
(5) or does TRY clear ERROR after the next statement ??

I'm thinking ERROR should always be T/F or always True/False but not mixed.
I get better consistent results with STR$(ERROR) but I didn't think I
needed to force conversion.

Thanks in advance.
-Fernando




More information about the User mailing list