Bug? B4A v5 - End Sub bug

Robert Valentino

Well-Known Member
Licensed User
I do a lot of these single line routines

B4X:
Sub sAdd_Modify_Courses_Click : StartActivity("aCourses") : End Sub
Sub sAdd_Modify_Players_Click : StartActivity("aPlayers") : End Sub
Sub sPlayer_ScoreCards_Click : StartActivity("aScoreCards") : End Sub
Sub sPlayer_Stats_Click : StartActivity("aStats") : End Sub
In all my single line routines I am getting a B4A v5 Error - End Sub missing

Bob
 

Attachments

Robert Valentino

Well-Known Member
Licensed User
Is this restriction ever going to be removed?

I have a lot lines of code like this that I prefer not to have to convert
 

Robert Valentino

Well-Known Member
Licensed User
I'm a C++ guy and in header templates there are always a ton of
B4X:
Bool Something(int IfSomething) {  return IfSomething = -1 ? false : true }
Now just because you do not like it does not make it wrong.

Personal Style
 

LucaMs

Expert
Licensed User
and Luca, pretty unreadable
:(

I meant...

Se io avessi saputo che in B4A 4.x esisteva la possibilità di mettere "End Sub" su una riga non vuota... io non l'avrei fatto comunque.


I hope that now it is more readable :p
 

LucaMs

Expert
Licensed User
ok, I do not speak English well, but I think you understand that, in my opinion, put an "End Sub" in a non-blank line is deprecable.

I "don't like" also "End If" at the end of "an empty line":

If sdf and adflj or (adlfj and fjlla).... End If !!!

It is hardly readable and maintainable.

So...

I'm not sure that it will be supported in the future
is a "good news" ;)
 

sorex

Expert
Licensed User
@Robert Valentino,

I don't know if C++ allows it but some languages even allow you to leave out the { } brackets if it is a single line if statement which makes even more sense.
 

Robert Valentino

Well-Known Member
Licensed User
Erel. I understand your position. But this is a major change in style for me and currently stops me from upgrading to 5.x


To everyone else:

Much as many may not like my style (as I do not like tabs in my code - but prefer spaces) to me coding is more like an artist painting a picture no two artists paint the same way and usually do not have the same style. But in the end they all have beautiful works to look at.

My style may be different, but wrote some code in the 1980's for mainframes that a friend of mine still supports (now that is a long time for some code to be around) was even coded back then to handle the 1999-2000 change because I new some day it was coming (and I got picked on for that), and the code is still running in 2015

I love one line coding. I can look at twenty or thirty lines at once and know all the functions in a module as seen below

B4X:
#Region Single Line Grid Commands
Sub SetGridBGColor(Color As Int)  : mGridBGColor  = Color  :  End Sub

Sub SetGridSize(Size As Int)  : mGridSize  = (Size * 1dip)  :  SetHeaderHeight(mFixedDataHeight)  :  End Sub
Sub SetGridSizeColor(Color As Int)  : mGridSizeColor  = Color  :  End Sub

Sub SetGridSpacing(Spacing As Int)  : mGridSpacing  = (Spacing * 1dip)  :  SetHeaderHeight(mFixedDataHeight)  :  End Sub
Sub SetGridSpacingColor(Color As Int)  : mGridSpacingColor = Color  :  End Sub

Sub GridSize()  As Int  : Return mGridSize  :  End Sub
Sub GridSizeColor() As Int  : Return mGridSizeColor  :  End Sub

Sub GridSpacing() As Int  : Return mGridSpacing  :  End Sub
Sub GridSpacingColor() As Int  : Return mGridSpacingColor  :  End Sub

Sub NumberRows  As Int  : Return mRowsCols.Size  :  End Sub
#End Region
Now the above lines of code may look like crap here (because of Tabs) but you can see what they look like in the editor from the attached pictures.

Everything lines up nice, easy to C (Oops did I really mean C++) easy to read (my opinion)

All my code lines up. I am a fast typist and hitting the space bar is not a problem.

But thanks for all the feeback guys.



CodeStyle.png
CodeStyle2.png
 

thedesolatesoul

Expert
Licensed User
To be fair to you, I feel this is a step backwards because it is an IDE imposed restriction on coding style rather than a compiler imposed restriction. I'm sure the code is compilable in command line mode.
It makes B4A 5 to be not backwards compatible, but if that needs to be done then it should be made more clear, documented and not be incremental.
 

LucaMs

Expert
Licensed User
I love one line coding. I can look at twenty or thirty lines at once and know all the functions in a module as seen below
1) those "are" (should be, if their name started with a lower case "set") Properties, and one line of code only;
2) you can be an artist when you design your sw, but to keep the code maintainable and readable, perhaps even by other people, it is better to be at all artistic;
3) if your routines would consist of many lines, you may see them listed, each in a single line, collapsing the page (module). Use Regions to group routines is another big advantage.
 
Top