3.5.2 Useful Text/String Functions

Two common string operations are changing case and searching for substrings.

Changing a String to Upper/Lower Case

To change a string to uppercase or lowercase, use the 'toUpperCase()' and 'toLowerCase()' functions, respectively. For example:

var s = 'John Lennon';

Text1.text = s.toLowerCase();

For example, to change the header cells of a table to uppercase, add the following lines to the table script:

for(var col = 0; col < table.size; col++) {

  table[0][col] =

    table[0][col].toUpperCase();

}

Searching Within a String

To find one string within another string, use the 'indexOf()' function. The 'indexOf' function returns the starting index of the substring within the parent string. If the substring is not found, the function returns a value of -1. For example:

var state = 'New Jersey';

 

if(state.indexOf('New') > -1) {

  Text1.text = 'With New';

}

else {

  Text1.text = 'Without New';

}

<< 3.5.1 Text Property © 1996-2013 InetSoft Technology Corporation (v11.5) 3.5.3 Useful Date Functions >>