next up previous contents index
Next: Records Up: ValuesTypes, and Constants Previous: Numeric Types

Strings

  The string type holds character-string values, used to represent and manipulate text.

String Constants

 

  You create string constants by enclosing text within either single (') or double (") quotes.

  Glish treats text within single quotes as a single string value; these constants are scalars. For example,

    'hello there'
yields a string value of one element. That element has 11 characters.

  Glish breaks up text within double quotes into words at each block of whitespace (blanks, tabs, or newlines). The whitespace is removed from the result. Thus

    "hello there"
yields a two-element string value, the first element of which is the character string hello and the second element the string there. Leading and trailing whitespace is ignored, so
    " hello     there "
is equivalent to
    "hello there"

  In both kinds of string constants, a backslash character (\) introduces an escape sequence. Currently four escape sequences are recognized: \n  yields a newline character, \t  a tab character, \r  a carriage-return, and \f  a formfeed. Any other character following a \ is passed along literally. For example,

    "hello \"there\" how \
     are\nyou?"
yields the string
    hello "there" how are you?
whose length is 5 (recall that the \n newline is treated as whitespace and removed from the string), while
    'hello \'there\' how \
     are\nyou?'
yields the single-element string
    hello 'there' how are
    you?
 

String Operators

  Currently the only string operators provided are the comparison operators discussed in § 3.2.5, page gif. These operators perform character by character comparisons based on the native character set, usually ASCII.

Some functions for manipulating strings are also available. See § 9.5, page gif.  



Thu Nov 13 16:44:05 EST 1997