String DataType

From HEWIKI
Jump to: navigation, search

Contents

The string datatype represents an ordered collection of characters.

Basic Usage

function example()
  var s = "abc"
  assert( s.length = 3, "string length")
  assert( substring(s,1,2) = "ab", "substring")
  assert( s+"def" = "abcdef", "concatenation")
  s += "def"
  assert( findString(s,"cd")=3, "find")
.

Ordering

Comparison operators are case sensitive. Essentially, the UNICODE number for each character is compared until there is a difference. Uppercase A-Z characters are lower numbers than lowercase A-Z characters.

function example()
  var s = "abc"
  assert( s > "ZYX", "lowercase greater than uppercase")
.

The compiler optimizes comparisons involving the external function toLower by doing a case-insensitive comparison.

function example()
  var s = "ABC"
  if toLower(s)="abc"
    // it's true
  .
.

See also

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox