Futurebasic/language/string expressions

String Expressions edit

Revised for FBtoC 15 February 2008

Description edit

A string expression is anything that can be evaluated as a string of 0 to 255 characters. (Note that FutureBASIC also provides "Containers" with 2GB text capacity that operate very similarly to a standard string). A string can be expressed in any of the following ways:

Simple Expressions edit

  • A string literal, or a string variable. See Appendix C: Data types and Data Representation, for more information.
    Examples:
     surname$(23)      "Friday"
  • A reference to any user-defined function that returns a string value.
    Example:
     fn MyStringFunc$( "something" )
  • A value returned by any built-in FB function whose name ends with $
    Examples:
     chr$( 7 )      hex$( z& )
  • A value returned by the using function, or by the str# function.
    Examples:
     using "##.#"; pi      str#( 130, 5 )

Compound Expressions edit

A compound string expression is a list of simple string expressions separated by the concatenation operator "+". The syntax of a compound string expression is:

simpleExpr1 + simpleExpr2 [+ simpleExpr3 ...]

The "+" operator builds a longer string by concatenating the operands. For example:

"Ex" + "tra" + mid$( "fiction", 3 )

This expression has the value "Extraction".

Notes edit

If a string expression is assigned to a string variable too small to hold it, the expression is silently truncated to fit.

When two string expressions are separated by a data-comparison operator (==, !=, <, >) the result is a numeric expression. See Appendix D: Numeric Expressions.