ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


string

String library

ACSUtils provides a rich set of functions for working with strings.

Empty vs invalid strings

ACS strings are actually numbers that identify actual strings in the ACS VM's string table.

A number may not refer to any string at all, in that case it's an invalid string. Unlike some other ACS libraries, ACSUtils doesn't detect and support invalid strings. Passing invalid strings to ACSUtils functions may result in unexpected behavior.

"" is an empty string, i.e. a valid string of length 0. It can be passed to any function and will work as expected.

Checking string equality

Do not use == to check if strings are equal.

Operator == only checks if string numbers are equal. It may mostly work and then stop working randomly, or when used with a string coming from a different ACS library.

To check if strings are equal, you need to compare their contents. ACSUtils provides an easy to use function for this, which returns true if two strings are equal:

bool StrEquals(str a, str b)

Internally, this function calls harder to use StrCmp, but it could just as well be implemented using a combination of StrLen and GetChar.

There is also a case-insensitive version:

bool StrIEquals(str a, str b)

It's implemented using StrICmp.

String functions

StrIsEmpty

bool StrIsEmpty(str s)

Returns true if the string is an empty string ("").

string.txt · Last modified: 2019/04/19 02:48 by korshun