SINS is a CAOS command which searches within a string.


Syntax: SINS haystack (string) from (int) needle (string)

Searches for needle in haystack from the index from. Returns, as an integer, the index in haystack of the first instance of needle, or -1 if not found. You can then use SUBS to fetch relevant parts of the string.

String indices start at 1. This command is case sensitive. See LOWA and UPPA to convert case.

This is similar to the C function strstr().


SETS va00 "shush"
OUTV SINS va00 1 "sh"
OUTV SINS va00 2 "sh"
OUTV SINS va00 5 "sh"

Implement SINS va00 va01 va02, placing the result in va03:

* assume: STRL va02 le STRL va00; va01 gt 0 && va01 le STRL va00.
SETV va03 -1
SETV va04 1
  DOIF va04 ne STRL va02
    DOIF CHAR va00 va01 eq CHAR va02 va04
      DOIF va03 eq -1
        SETV va03 va01
      ADDV va04 1
      SETV va04 1
      SETV va03 -1
  ADDV va01 1
UNTL va01 eq STRL va00

See also

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.