if not

drfjm

Member
Licensed User
Longtime User
Hello,
I notice that
If Not renonceTF Then
is flagged as erroneous
renonceTF has been declared as boolean, of course.
However, when I write
If Not (renonceTF) Then
the expression is accepted.
a bit weird
 
Last edited:
Brackets are not needed in this case.

:confused:

When I write something like
Code: Copy
Sub MyLog(s As String)'As Void
  Log(DateTime.Now & ": " & s)
End Sub

Sub Caller
  MyLog "OK" '<--no brackets
End Sub
I get an syntax error!?! (In VB it's valid syntax.)

'Cause I don't like to much brackets I've ever prefered VB to C++ or C! ;)
 
Those Void return functions also often appear in the tooltips as being As String returns too. I think it is just how BASIC Subs/Functions differ from C++/JAVA Methods/Functions. In BASIC a Function without a return is a Sub and can be accessed like a statement (with/without parentheses). JAVA/C++ really doesn't have this and everything returns something...even if it is just VOID. B4A just uses the Sub keyword since it wouldn't be logical to split them like BASIC does when going to JAVA in the end.

More code could be added in the parser I guess to allow for this and convert it, but then you'd also need to have both Function and Sub keywords to not be confusing.
 
More code could be added in the parser I guess to allow for this and convert it, but then you'd also need to have both Function and Sub keywords to not be confusing.

Personaly I could live very well with a Sub ... As Void to show the compiler, that I don't expect String (or smething else) as return type.
 
Back
Top