Welcome to the Creatures Wiki! Log in and join the community.

SUBS

From Creatures Wiki
(Redirected from Subs)
Jump to navigation Jump to search

SUBS is a CAOS function which extracts a substring.

Usage[edit]

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!
The behaviour of this function with negative count is based on observed behaviour and is not documented by MANN.

Example[edit]

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

See also[edit]