Plain Text

Prev Next

Introduction

Plain text can be used for

Rules

Following rules apply for plain text:

  • It may consist of any character which does not interfere with the B4P code syntax: Letters, letters combined with numbers, and special symbols not interfering with B4P code syntax (e.g. parentheses, commas, operators, etc.).
    • 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, then the variable assumes the 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