Indexing Into Strings

You can index into variables as though they are character arrays. Indices are zero-based. For example:

s = "abc"
x = s[0]    // x now contains the string "a"

 

Indexing into a variable yields a new string containing a single character.

The string that is returned by indexing one past the last character is an empty string. This is similar to zero-terminated strings in C, only the zero “character” is an empty string.

s = "abc"
length = strlen(s)
ch = s[length] // ch now contains the empty string
if (ch == "")
    msg "End of string."