gbdev/rgbds

Add `STRSLICE(str, start, end)` function with zero-based and indexing

Closed this issue · 1 comments

Based on ISSOtm/rsgbds#9

This would be an alternative to STRSUB without the 1-based indexing issue and with a negative end index possibility.

This would let you do STRSLICE("string", start, end) instead of the more verbose STRSUB("string", start, STRLEN("string") - end - start). (And when you want a fixed length, STRSLICE("string", start, start + length) is not much more verbose than STRSUB("string", start, length), though either would still be an option.)

The other function that currently has 1-based indexing is CHARSUB. We could add a CHARAT function with 0-based indexing, in the hopes that STRSUB and CHARSUB will one day be deprecated or changed.