Futurebasic/language/string expressions

String ExpressionsEdit

Revised for FBtoC 15 February 2008


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 ExpressionsEdit

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

Compound ExpressionsEdit

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".


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.