Plain Text

Prev Next

Introduction

In B4P, plain text is any kind of text which is specified without any quotation marks. Such text contents are limited to one line and the character set is limited to avoid confusion with B4P specific symbols such as operators, for example text hyphens with minus signs. Plain text may contains spaces, however multiple consecutive spaces and tabs are condensed to one space. Plain text can be used for

Rules

Following rules apply for plain text:

  • Choice of characters
    • Alphabetic letters, including foreign letters and characters
    • All characters which do not interfere with B4P code elements and symbols such as mathematical operators. A single point (.) is OK, however hyphens, parentheses, brackets, commas create issues as they are interpreted as B4P symbols.
    • Numerals only OK if combined with spaces or letters or other characters described above.
    • Good example: A.1 (The single point is not a dedicated B4P symbol).
    • Bad example: Baden-Baden (The hyphen is interpreted as a minus sign and results in a successful string subtraction. The outcome would be a blank string.
  • The text may contain white white spaces (space bar, tab, etc.)
    • Example 1: 4200 Pennsylvania Avenue or Number 1
    • Example 2: 555 1212 (phone number is a text and not a number because of the space inside)
    • Example 3: 1.234.567 (multiple decimal points between numeric digits constitute a text)
  • The text must be on the same line.
  • Multiple consecutive white spaces inside the text are interpreted as one single space character.
    • Example: Hello   World is the same as Hello World.
  • Leading and trailing spaces are ignored.
    • Example: echo(Hello World) outputs the same as echo(  Hello World ).
  • 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.

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