SUBS

From Creatures Wikia

Jump to: navigation, search

SUBS is a CAOS function which extracts a substring.

Usage

Syntax: SUBS str (string) start (int) count (int)

Extracts and returns a substring of str starting at index start and of length count. String indices start at 1.

start must be no more than STRL str and the value of count must not be such that start + count > STRL str. Otherwise the command fails with "Slice attempted outside string."

If count is negative, SUBS returns str from start to the end. So SUBS str s -1 is like SUBS str s ((STRL str) - s).

Warning sign
The behaviour of this function with negative count is based on observed behaviour and is not documented by MANN.

Example

OUTS SUBS "shush" 2 3
    hus
OUTS SUBS "shush" 3 -1
    ush

See also

Personal tools