Similar to Python and other modern programming languages, B4P supports multline strings, for both
Following rules apply for multi-line text items:
Multi-line string contents can start immediately after the three quotation symbols or on the next row. Same applies for the
end: The multi-line string can be ended on the same line with three quotation marks, or immediately on the following row.
If you want to include new line symbols at the beginning and/or at the end of the multi-line string, then include additional
blank rows.
Attention: If the multi-line string is not properly delimited with the same triple quotation marks, then an error message
will occur at the end of the B4P program file because B4P assumed all contents further down as part of the long string.
special offer[] = '''
4 pounds of bananas cost € 2.90.
""" This is today's special bargain """
''';
echo("Attention!", special offer[], "As long supplies last?" );
Attention!
4 pounds of bananas cost € 2.90.
""" This is today's special bargain """
As long supplies last?
code example[] = """
/* Comments are part of the multi-line string */
a[] = 4;
b[] = sqrt(a[]) + 1; // Square root calculation
echo( " sqrt(4)+1 equals ", b[] );
""";
echo( code example[] );
echo( new line, "Code output:" );
exec( :code example[] );
/* Comments are part of the multi-line string */
a[] = 4;
b[] = sqrt(a[]) + 1; // Square root calculation
echo( " sqrt(4)+1 equals ", b[] );
Code output:
sqrt(4)+1 equals 3
example[A] = """This 1st
text fits on
3 rows""";
example[B] = """
This 2st
text fits on
3 rows""";
example[C] = """
This 3rd
text fits on
5 rows (blank rows above and below)
""";
example[D] = """Use Following quotation marks: "Hello" or 'Hello' or '''Hello'''.""";
echo("--------");
for all variables( example[], ex[] )
{
echo(ex[]);
echo("--------");
}
--------
This 1st
text fits on
3 rows
--------
This 2st
text fits on
3 rows
--------
This 3rd
text fits on
5 rows (blank rows above and below)
--------
Use Following quotation marks: "Hello" or 'Hello' or '''Hello'''.
--------
Text inside single quotation marks
Text inside double quotation marks