Suggestion: If/Else/End If matching in editor

Widget

Well-Known Member
Licensed User
Longtime User
In the editor, I think it would be a nice feature if the user could click on the "if" of an If Statement, that the matching "else" and "end if" of that If Statement are also highlighted like when the "(" or ")" is selected. This will help the user clearly see the structure if the If Statement.

Widget
 

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
That would be nice. In a long sub, a missing If-Then-Else-End If component can be hard to find.

A related issue is that I break long lines (usually If-Then lines) into multiple lines using the underscore character. If I miss an underscore, the resulting error message is not always on point. For example, the following code will result in the message "Missing Keyword: End Sub" and will point to the "End If" line right after the "Log" line. That makes it far from obvious that the error is a missing "_".

B4X:
Sub DoSomething
    If x = "PUMPERKNICKLE" AND _
       y = "PLUF" AND _
       z = "WOWZER" 
    Then
          If x = y  Then
                Log("Really?")
          End If 
    End If
End Sub
 

margret

Well-Known Member
Licensed User
Longtime User
IF - Else - Endif

Hello,

You could also use:

#Region
......
......
#End Region

This will allow you to collapse all the code in a block to one line. Use it between the IF and ELSE and another between the ELSE and ENDIF! That way you can see the whole IF - Else - Endif block on the screen at the same time to see if all required commands are there and are ok. I use this all the time! It helps!

Thanks,

Margret
 

awama

Active Member
Licensed User
Longtime User

Thanks margret, it's a good tip.
Now I will have more overview in my Code. http://www.b4x.com/forum/images/icons/icon7.gif
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…