Line Continuation
Documentation
Line Continuation character(s) allow to spread out a single line of code into multiple lines.Description
A single '_' (underscore) character at the end of a line of code tells the compiler that the line continues in the next line. This allows a single statement (line of code) to be spread across multiple lines in the input file, which can be a nice formatting help:
'' This Dim statement is spread across multiple lines, using the '_' character
Dim myvariable _
As Integer
'' Here's an example:
Declare Sub drawRectangle( ByVal x As Integer, ByVal y As Integer, ByVal w As Integer, ByVal h As Integer )
'' which can also be written as:
Declare Sub drawRectangle( ByVal x As Integer, ByVal y As Integer, _
ByVal w As Integer, ByVal h As Integer )
'' or:
Declare Sub drawRectangle _
( _
ByVal x As Integer, _
ByVal y As Integer, _
ByVal w As Integer, _
ByVal h As Integer _
)
'' (or any other formatting you like)
Be careful when adding the '_' line continuation character right behind an identifier or keyword. It should be separated with at least one space character, otherwise it would be treated as part of the identifier or keyword:
'' Declare variable "a_"
'' (no line continuation happening, because the '_' character is part of
'' the "a_" identifier)
Dim As Integer a_
'' Declare variable "a" and initialize to value 5
'' (line continuation happening, because the '_' character
'' was separated from the identifier "a" with a space character)
Dim As Integer a _
= 5
Note for fbc version >= 1.08:
In macro/define's use '##_' to escape line continuation character '_' to allow multiple lines of macro expanded code to be combined into a single statement.
See also