String Data Type

Holds a sequence of 8-bit Unicode (UTF-8) characters. A string can contain from zero to TBD characters.

Instructions

Default value
When you declare a variable of type String and do not initialize it, its default value is the empty string ("").
Type characters
When you put a dollar sign ($) at the end of a name, it declares it has the type String.

String literals

Usual string

{ " [ char… ] " ]}…

File-path string

" [ char… ] " { { / | \ } " [ char… ] " }…

TODO

String constants

{ $ name
| $ decimal
| $H hexadecimal
| $O octal
| $B binary }

TODO

Shared methods and properties

String.CharAt(str As String, pos As Int) As Char
Returns the character at the given position in a string. If pos is larger than the end of the string, then the method throws RangeError. If you must do an operation for each character in a string, then “For Each chr As Char In str” could give better results.
String.Default As String
Returns the default value, "".
String.Find(str As String, what As String, Optional start As Int, length As Int, flags As FindFlags) As Int
String.Find(str As String, what As Char, Optional start As Int, length As Int, flags As FindFlags) As Int
Returns the position of a substring or character (what) in a given string. You can optionally supply where to start (start), how many characters (length), and how to find the next index (flags). Values of FindFlags are: IgnoreCase and FromEnd.
String.Length(str As String) As Int
Returns the number of characters in a string.
String.Lower(str As String) As String
Returns a string with upper-case letters changed to lower-case.
String.Part(str As String, start As Int, Optional length As Int) As String
Returns part of a string at a given position (start), and with a optional given length. If length is not given, then the returned string is from start thru the end of the given string. If start is larger than the end of the given string, then the method throws RangeError.
String.Upper(s As String) As String
Returns a string with lower-case letters changed to upper-case.

Examples

Declarations

Dim foo As String
Dim bar$

Different literals

Const banner = "images"/"banner.jpg"

See also