GRID CARTOGRAPHER 4
Shortcuts

String Values

2019-04-12

Methods available on string values.

CharAt

str.CharAt( index: int ): int

Returns the character in the string at the given index as an integer. Use ToChar to turn into a string value.

Find

str.Find( substr: string, [start: int] ): int|null

Search through the string for the given substr value. If the start index is provided then search begins at this index. If the substr value is found, the offset into the string is returned. If the sub-string is not found, the call will return null.

Length

str.Length(): int

Returns the length of the string in characters.

Slice

str.Slice( start: int, [end: int] ): string

Returns a section of the string starting at start and continuing until the character before end. If end is omitted the slice will contain the whole of the remainder of the string. If start is negative the index is calculated as length + start. If end is negative the index is calculated as length + end.

Split

str.Split( delim: string ): array

Splits the string into an array of sub-strings whenever the given delimiting string found in the original. The delimiter and resulting empty sub-strings are not included in the output.

For example:

    var message = "HELLO WORLD";
    var arr = message.Split( "L" );
    printobj( arr );

    // output is:
    //  [
    //      0 : "HE"
    //      1 : "O WOR"
    //      2 : "D"
    //  ]

ToFloat

str.ToFloat(): float

Convert the string to a float. Stops at the first non-digit. If no digits are found, returns 0 (zero).

ToInt

str.ToInt(): int

Convert the string to an integer. Stops at the first non-digit. If no digits are found, returns 0 (zero).

ToLower

str.ToLower(): string

Returns a lower-case copy of the string. The original string is not changed.

ToUpper

str.ToUpper(): string

Returns an upper-case copy of the string. The original string is not changed.

Trim

str.Trim(): string

Returns a copy of the string with all of the white-space characters removed from the beginning and the end. Trimming stops as soon as the first non-whitespace character is found.

White-space characters are:

Character Hex Value Name
' ' 0x20 Space
\t 0x09 Horizontal Tab
\n 0x0a New-line
\v 0x0b Vertical Tab
\f 0x0c Form-feed
\r 0x0d Carriage return

TrimLeft

str.TrimLeft(): string

Returns a copy of the string with all white-space characters (see above) removed from the beginning of the string only.

TrimRight

str.TrimRight(): string

Returns a copy of the string with all white-space characters (see above) removed from the end of the string only.