Plain Text

Prev Next

Introduction

In B4P, plain text is any kind of text which is specified without quotation marks. Such text contents are limited to one line and all characters are allowed except B4P specific symbols such as operators and various forms of parentheses / brackets.

Spaces

Plain text may contains spaces, however multiple consecutive spaces and tabs are interpreted as single spaces.
Hello   World is the same as Hello World. Leading and trailing spaces are ignored.

Uses

Plain text can be used for

Rules

Following rules apply for plain text:

  • Choice of characters
    • Alphabetic letters, including foreign letters and characters used around the world
    • All characters which do not interfere with B4P code elements and symbols such as mathematical operators, parentheses, brackets, etc..
  • The text may contain white white spaces (space bar, tab, etc.)
  • A single point (.) is OK as long not used as decimal point in numbers. But 2 consecutive points (..) are not OK as they are ranges.
  • The text must be on the same line.
  • Multiple consecutive white spaces inside the text are interpreted as one single space character.
  • A lone point (.) specified without quotation marks is also interpreted as a string containing this one character as long it is not a decimal point in a numeral.
  • Reserved keywords are automatically interpreted as part of the B4P syntax, e.g. true as Boolean true, and else is also part of the B4P language.
  • If the text is assigned to B4P variables or used inside expressions, then the variable assumes the type string and subtype softquoted string.

Good Examples Interpretation Bad Examples Interpretation
Hello World Text Baden-Baden Minus sign: Text subtraction. Returns blank.
555 1212 Text and not number 1.2 This is a number
1.234.567 Text (multiple points) 1,234.567 Comma is a B4P specifc symbol
_1 Text -1 This is a number
10 Main St. Text 10..12 Main St. '..' describes ranges
25.12.2024 Text (not a B4P date) 25-12-2024 Two subtractions, results in 2011
true Boolean value
True Text



Examples
       echo( Hello World );
       echo(   Hello   World   );  // Same as above (Spaces outside the strings are ignored, so are multiple spaces inside)
       echo( One + One );          // + sign is an operator, result is 'OneOne'
       echo( 'One + One' );        // This one is OK.
       echo( Baden-Baden );        // Empty string.  Hyphen is treated as minus sign (subtraction of strings)
       echo( 'Baden-Baden' );      // This one is OK.
       echo( 1. 23 );              // This is a string because a space is inside.
       echo( 1 200 );              // Same here.  Use function 'clean numeral' to extract 1200 as a number from here
       echo( Dial 555 1212 );
       echo( this is on, new line, the next line );  // new line is a reserved keyword
       echo( Café in Zürich );     // Foreign characters inside
       echo( . );                  // Lone point
       echo( .     . . );          // A string containing 3 lone points (. . .), also showing how spaces are collapsing
       // echo( .. );              // Would cause an error because .. is a b4p language symbol.
       echo( '..' );               // This one is OK
       echo( new line, Line 1, new line, Line 2 );
Hello World
Hello World
OneOne
One + One

Baden-Baden
1. 23
1 200
Dial 555 1212
this is on
the next line
Café in Zürich
.
. . .
..

Line 1
Line 2
Try it yourself: Open LAN_Features_Plain_Text.b4p in B4P_Examples.zip. Decompress before use.

See also

Text inside single quotation marks
Text inside double quotation marks