Wish free the then !

Himred

Member
Licensed User
Longtime User
Hi !

Would you consider allowing in addition of the current ones the 2 following syntaxes:

Syntax 1:
Why a then should be on the same line finally ?
As président of the freedom for then foundation i would love that b4a give more freedom for them/n and allow
B4X:
If a=3
Then
  x=2
  y=3
Else
  X=0
End if

Ultimatly you even could make that then optional, so they can get some rest and allow:
B4X:
If a=3
  x=2
  y=3
Else
  X=0
End if

Allowing additional syntaxes for a much used statement like then will allow more users coming from other languages to love b4a without annoying the basic pros.

Thanks for reading.

Himred président of the FFTF.

Regards.
 

James Chamblin

Active Member
Licensed User
Longtime User
You need a delimiter after the condition exprrssion.
I have used BASIC variants in which a new line acts as an implied then. So
B4X:
If a = 3 Then x = 7

If a = 3 Then x = 7 End If

If a=3 Then
   x = 7
End If

If a=3
   x = 7
End If
Would all be equivalent. However
B4X:
If a = 3 x = 7
would throw an error as neither then nor a new line separates the condition to the rest of the code. I have never seen Then on its own line before though, maybe a VB thing?

My post here isn't to imply a +1. The then requirement doesn't bother me that much. Just wanted to note that it is not an unusual thing.
 

Beja

Expert
Licensed User
Longtime User
AND, OR, XOR.... etc will complain from discrimination .
If a=3 b=2 (implied AND between them)
 

Troberg

Well-Known Member
Licensed User
Longtime User
You need a delimiter after the condition exprrssion.

Not really. Newline works as a delimiter, and if you want it on the same line, colon.

If x=0
DoStuff
End If

One line version:

If X=0 : Dostuff

"Then" is just a useless atavism, like the appendix or the tail bone. I say we put it on a big bonfire and dance happily naked around it, chanting happy songs.

Oh, while we are at it, it would be nice if the editor autocorrected "endif" to "End If". I've noticed that old habits die hard. Very hard.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…