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


From Creatures Wiki
Jump to navigation Jump to search

SUBS is a CAOS function which extracts a substring.


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).

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


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

See also[edit]