string_functions.zh#

Functions#

int

NumCharsOf(char32[] ptr, char32 chr)

int

NumCharsOf(char32[] ptr, int pos, char32 chr)

bool

isControlCode(char32 chr)

bool

isNumber(char32 chr)

bool

isAlphabetic(char32 chr)

bool

isAlphaNumeric(char32 chr)

bool

isHex(char32 chr)

bool

isUpperCase(char32 chr)

bool

isLowerCase(char32 chr)

bool

isSpace(char32 chr)

bool

isVowel(char32 chr)

bool

ContainsChar(char32 chr, char32[] buffer)

int

ContainsCharPos(char32 chr, char32[] buffer)

bool

ContainsChar(char32 chr, int pos, char32[] buffer)

int

ContainsCharPos(char32 chr, int pos, char32[] buffer)

char32

UpperToLower(char32 chr)

char32

LowerToUpper(char32 chr)

char32

ConvertCase(char32 chr)

void

memset(untyped[] ptr, int pos, untyped value, int n)

void

memset(untyped[] ptr, untyped value, int n)

void

memcpy(untyped[] dest, int dpos, untyped[] src, int spos, int n)

void

memcpy(untyped[] dest, untyped[] src, int n)

void

memcpy(untyped[] dest, untyped[] src)

untyped

memmove(untyped[] dest, int dpos, untyped[] src, int spos, int n)

void

arrayset(untyped[] a, untyped[] args, untyped varargs …)

void

strcpy(int[] dest, int dpos, int[] src, int spos)

void

strncpy(int[] dest, int dpos, int[] src, int spos, int n)

void

strncpy(int[] dest, int[] src, int n)

void

remchr(char32[] ptr, int pos)

void

remchr(char32[] ptr)

void

remnchr(char32[] ptr, int pos, int n)

void

strcat(int[] dest, int[] src, int spos)

void

strncat(int[] dest, int[] src, int spos, int n)

void

strncat(int[] dest, int[] src, int n)

int

strchr(char32[] ptr, int pos, char32 chr)

int

strrchr(char32[] ptr, int pos, char32 chr)

int

strstr(char32[] ptr, int pos, char32[] sub)

int

strspn(char32[] ptr, int pos, char32[] keys)

int

strcspn(char32[] ptr, int pos, char32[] keys)

int

strcmp(char32[] ptr1, int pos1, char32[] ptr2, int pos2)

int

strncmp(char32[] ptr1, int pos1, char32[] ptr2, int pos2, int n)

int

atoi(char32[] ptr, int pos)

int

ilen(char32[] ptr, int pos)

int

xtoi(char32[] ptr, int pos)

int

xlen(char32[] ptr, int pos = 0)

int

atof(char32[] ptr, int pos = 0)

int

flen(char32[] ptr, int pos = 0)

int

aton(char32[] ptr, int pos = 0)

int

nlen(char32[] ptr, int pos = 0)

int

itoa(char32[] ptr, int pos, int num)

int

xtoa(char32[] ptr, int pos, int num, bool upper)

int

xtoa(char32[] ptr, int num, bool upper)

int

ftoa(char32[] ptr, int pos, int num, bool printall)

int

ftoa(char32[] ptr, int num, bool printall)

int

ftoa(char32[] ptr, int pos, int num)

int

ftoa(char32[] ptr, int num)

int

ntoa(char32[] ptr, int pos, int num)

int

ntoa(char32[] ptr, int num)

void

strcatf(int[] dest, untyped arg, int format)

void

strncatf(int[] dest, untyped arg, int format, int n)

bool

sprintf_isMFCode(char32 chr)

int

sprintf_MFCodeToInt(char32 chr)

int

ReturnStringCharPos(char32[] ptr, char32 chr)

int

ReturnStringCharPos(char32[] ptr, int pos, char32 chr)

int

ReturnStringCharPosRev(char32[] ptr, char32 chr)

int

ReturnStringCharPosRev(char32[] ptr, int pos, char32 chr)

char32

IsChar(char32 chr)

bool

IsChar(char32 chr, char32 comp)

void

ScreenPrint(char32[] s, untyped v, int[] args)

int

strcmp(char32[] ptr1, char32[] ptr2)

int

strncmp(char32[] ptr1, char32[] ptr2, int n)

int

strlen(char32[] ptr)

void

strcpy(char32[] dest, char32[] src)

int

atoi(char32[] ptr)

void

strcat(char32[] dest, char32[] src)

int

strchr(char32[] ptr, char32 chr)

int

strrchr(char32[] ptr, char32 chr)

int

strspn(char32[] ptr, char32[] keys)

int

strcspn(char32[] ptr, char32[] keys)

int

strstr(char32[] ptr, char32[] sub)

int

ilen(char32[] ptr)

int

xtoi(char32[] ptr)

int

itoa(char32[] ptr, int num)

int

xtoa(char32[] ptr, int num)

int

sprintf(char32[] ret, char32[] formatstr, int a0 = 0, int a1 = 0, int a2 = 0, int a3 = 0, int a4 = 0, int a5 = 0, int a6 = 0, int a7 = 0, int a8 = 0, int a9 = 0, int aa = 0, int ab = 0, int ac = 0, int ad = 0, int ae = 0, int af = 0) deprecated

void

printf(char32[] formatstr, int a0 = 0, int a1 = 0, int a2 = 0, int a3 = 0, int a4 = 0, int a5 = 0, int a6 = 0, int a7 = 0, int a8 = 0, int a9 = 0, int aa = 0, int ab = 0, int ac = 0, int ad = 0, int ae = 0, int af = 0) deprecated

Function descriptions#

int NumCharsOf(char32[] ptr, char32 chr) πŸ”— Source

ZScript string handling functions, akin to those found in C Returns the number of chracters of a given type in a specified string.


int NumCharsOf(char32[] ptr, int pos, char32 chr) πŸ”— Source


bool isControlCode(char32 chr) πŸ”— Source

Single character functions Returns true if β€˜chr’ is in the control code range of ascii characters


bool isNumber(char32 chr) πŸ”— Source

Returns true if β€˜chr’ is in the range of ascii characters β€˜0’ to β€˜9’


bool isAlphabetic(char32 chr) πŸ”— Source

Returns true if β€˜chr’ is an alphabetic character


bool isAlphaNumeric(char32 chr) πŸ”— Source

Returns true if β€˜chr’ is an alphanumeric character


bool isHex(char32 chr) πŸ”— Source

Returns true if β€˜chr’ is in the set { β€˜0’-β€˜9’, β€˜A’-β€˜F’ , β€˜a’-β€˜f’ }


bool isUpperCase(char32 chr) πŸ”— Source

Returns true if β€˜chr’ is an upper-case character


bool isLowerCase(char32 chr) πŸ”— Source

Returns true if β€˜chr’ is a lower-case character


bool isSpace(char32 chr) πŸ”— Source

Retruns true if a β€˜chr’ is a blank space.


bool isVowel(char32 chr) πŸ”— Source

Returns true if β€˜chr’ is a vowel.


bool ContainsChar(char32 chr, char32[] buffer) πŸ”— Source

Returns true if the string contains a specific character.


int ContainsCharPos(char32 chr, char32[] buffer) πŸ”— Source

Returns first character position if the string contains a specific character, else -1.


bool ContainsChar(char32 chr, int pos, char32[] buffer) πŸ”— Source

Returns true if the string contains a specific character.


int ContainsCharPos(char32 chr, int pos, char32[] buffer) πŸ”— Source

Returns first character position if the string contains a specific character, else -1.


char32 UpperToLower(char32 chr) πŸ”— Source

Converts all upper case characters to lower case, leaving non-alphabetic characters unchanged


char32 LowerToUpper(char32 chr) πŸ”— Source

Converts all lower case characters to upper case, leaving non-alphabetic characters unchanged


char32 ConvertCase(char32 chr) πŸ”— Source

Converts lower case to upper case and upper case to lower case


void memset(untyped[] ptr, int pos, untyped value, int n) πŸ”— Source

Memory Manipulation Memory Set Sets block of memory of size β€˜n’ pointed by β€˜ptr’ to β€˜value’


void memset(untyped[] ptr, untyped value, int n) πŸ”— Source


void memcpy(untyped[] dest, int dpos, untyped[] src, int spos, int n) πŸ”— Source

Memory Copy Copys block of memory pointed by β€˜src’ of size β€˜n’ to β€˜dest’


void memcpy(untyped[] dest, untyped[] src, int n) πŸ”— Source


void memcpy(untyped[] dest, untyped[] src) πŸ”— Source


untyped memmove(untyped[] dest, int dpos, untyped[] src, int spos, int n) πŸ”— Source

Memory Move As memcpy, but uses a buffer so memory space can overlap


void arrayset(untyped[] a, untyped[] args, untyped varargs …) πŸ”— Source

Array Set Assign all elements of array.


void strcpy(int[] dest, int dpos, int[] src, int spos) πŸ”— Source

String Manipulation String Copy Copys string β€˜src’ into string β€˜dest’ without checking for overflow in β€˜dest’


void strncpy(int[] dest, int dpos, int[] src, int spos, int n) πŸ”— Source

As strcpy, but only takes the first β€˜n’ characters from src


void strncpy(int[] dest, int[] src, int n) πŸ”— Source


void remchr(char32[] ptr, int pos) πŸ”— Source

Remove Characters Remove all characters starting from pointer β€˜string’


void remchr(char32[] ptr) πŸ”— Source


void remnchr(char32[] ptr, int pos, int n) πŸ”— Source

Remove β€˜n’ characters and shift string back to pointer β€˜string’


void strcat(int[] dest, int[] src, int spos) πŸ”— Source

String Concatenate Appends string β€˜src’ onto string β€˜dest’ (assuming dest has enough extra memory allocated to allow the operation)


void strncat(int[] dest, int[] src, int spos, int n) πŸ”— Source

strcat up to β€˜n’ characters in src


void strncat(int[] dest, int[] src, int n) πŸ”— Source


int strchr(char32[] ptr, int pos, char32 chr) πŸ”— Source

String Searching String Character Returns the position of the first occurence of β€˜character’ in β€˜string’, or -1 if none are found


int strrchr(char32[] ptr, int pos, char32 chr) πŸ”— Source

String Reverse Character Returns the position of the last occurence of β€˜character’ in β€˜string’ starting from the end, or -1 if none are found


int strstr(char32[] ptr, int pos, char32[] sub) πŸ”— Source

String Sub-String Returns the position of the first occurence of sub-string β€˜sub’ in β€˜string’, or -1 if sub is not found


int strspn(char32[] ptr, int pos, char32[] keys) πŸ”— Source

String Span Returns the length of characters in β€˜ptr’ before a character not contained in β€˜keys’ is found


int strcspn(char32[] ptr, int pos, char32[] keys) πŸ”— Source

String Complement Span Returns the length of characters in β€˜ptr’ before a character contained in β€˜keys’ is found


int strcmp(char32[] ptr1, int pos1, char32[] ptr2, int pos2) πŸ”— Source

String Comparison String Compare Iterates through ptr1 and ptr2 until a character is found which is not the same in both strings, and then returns > 0 if the character is larger in ptr1, and < 0 if it is larger in ptr2. Returns 0 if the strings are equal


int strncmp(char32[] ptr1, int pos1, char32[] ptr2, int pos2, int n) πŸ”— Source

strcmp up to β€˜n’ characters


int atoi(char32[] ptr, int pos) πŸ”— Source

Converting between variables and strings ASCII to Integer Returns the decimal integer pointed by β€˜string’


int ilen(char32[] ptr, int pos) πŸ”— Source

Integer Length Returns the length of characters of the decimal integer pointed by β€˜string’


int xtoi(char32[] ptr, int pos) πŸ”— Source

Hexadecimal ASCII to Integer Returns the (positive) hexadecimal integer pointed by β€˜string’


int xlen(char32[] ptr, int pos = 0) πŸ”— Source

Hexadecimal Length Returns the length of characters of the (positive) hexadecimal integer pointed by β€˜string’


int atof(char32[] ptr, int pos = 0) πŸ”— Source

ASCII to Float Returns the floating point number pointed by β€˜string’


int flen(char32[] ptr, int pos = 0) πŸ”— Source

Float Length Returns the length of characters of the floating point number pointed by β€˜string’


int aton(char32[] ptr, int pos = 0) πŸ”— Source

ASCII to Number Calls either atoi or atof depending on context


int nlen(char32[] ptr, int pos = 0) πŸ”— Source

Number Length Calls either flen or ilen depending on context


int itoa(char32[] ptr, int pos, int num) πŸ”— Source

Integer to ASCII Places integer β€˜num’ into string β€˜string’ without checking for overflow, and returns the number of characters used


int xtoa(char32[] ptr, int pos, int num, bool upper) πŸ”— Source

Hexadecimal Integer to ASCII Places integer β€˜num’ into string β€˜string’ in base 16 without checking for overflow, and returns the number of characters used


int xtoa(char32[] ptr, int num, bool upper) πŸ”— Source


int ftoa(char32[] ptr, int pos, int num, bool printall) πŸ”— Source

Float to ASCII Places float β€˜num’ into string β€˜string’ without checking for overflow, and returns the number of characters used. If β€˜printall’ is true, it will add 4 decimal places regardless of the most significant digit


int ftoa(char32[] ptr, int num, bool printall) πŸ”— Source


int ftoa(char32[] ptr, int pos, int num) πŸ”— Source


int ftoa(char32[] ptr, int num) πŸ”— Source


int ntoa(char32[] ptr, int pos, int num) πŸ”— Source

Number to ASCII Checks whether β€˜num’ is an integer or not, and calls the appropriate function


int ntoa(char32[] ptr, int num) πŸ”— Source


void strcatf(int[] dest, untyped arg, int format) πŸ”— Source

String Formating String Concatenate Format Appends β€˜arg’ onto β€˜dest’ as the MF_ constant passed into β€˜format’


void strncatf(int[] dest, untyped arg, int format, int n) πŸ”— Source

As strcatf, using only β€˜n’ characters of β€˜arg’


bool sprintf_isMFCode(char32 chr) πŸ”— Source

Used by sprintf


int sprintf_MFCodeToInt(char32 chr) πŸ”— Source


int ReturnStringCharPos(char32[] ptr, char32 chr) πŸ”— Source


int ReturnStringCharPos(char32[] ptr, int pos, char32 chr) πŸ”— Source


int ReturnStringCharPosRev(char32[] ptr, char32 chr) πŸ”— Source


int ReturnStringCharPosRev(char32[] ptr, int pos, char32 chr) πŸ”— Source


char32 IsChar(char32 chr) πŸ”— Source


bool IsChar(char32 chr, char32 comp) πŸ”— Source


void ScreenPrint(char32[] s, untyped v, int[] args) πŸ”— Source

Prints a formatted string to the screen. int v can be a string, a float, or an int and is inserted to the string using the tokens %s, %f, and %d respectively. int args is an array literal with the following format required: { LAYER, X, Y, FONT, TEXT_COLOUR, TEXT_BG_COLOUR, FORMAT, OPCITY }


int strcmp(char32[] ptr1, char32[] ptr2) πŸ”— Source

Now an internal function. -Z ( 15th May, 2019 )


int strncmp(char32[] ptr1, char32[] ptr2, int n) πŸ”— Source

Now an internal function. -Z ( 15th May, 2019 )


int strlen(char32[] ptr) πŸ”— Source

Internal as of 2.55 Alpha 23, 15th may, 2019 String Length Returns the length of string β€˜string’


void strcpy(char32[] dest, char32[] src) πŸ”— Source


int atoi(char32[] ptr) πŸ”— Source


void strcat(char32[] dest, char32[] src) πŸ”— Source


int strchr(char32[] ptr, char32 chr) πŸ”— Source


int strrchr(char32[] ptr, char32 chr) πŸ”— Source


int strspn(char32[] ptr, char32[] keys) πŸ”— Source


int strcspn(char32[] ptr, char32[] keys) πŸ”— Source


int strstr(char32[] ptr, char32[] sub) πŸ”— Source


int ilen(char32[] ptr) πŸ”— Source


int xtoi(char32[] ptr) πŸ”— Source


int itoa(char32[] ptr, int num) πŸ”— Source


int xtoa(char32[] ptr, int num) πŸ”— Source


int sprintf(char32[] ret, char32[] formatstr, int a0 = 0, int a1 = 0, int a2 = 0, int a3 = 0, int a4 = 0, int a5 = 0, int a6 = 0, int a7 = 0, int a8 = 0, int a9 = 0, int aa = 0, int ab = 0, int ac = 0, int ad = 0, int ae = 0, int af = 0) πŸ”— Source

Prints string β€˜formatstr’ into β€˜ret’ according to the arguments inputted (see C function for reference) Maximum 16 arguments

Warning

Deprecated! Use the internal sprintf() instead.


void printf(char32[] formatstr, int a0 = 0, int a1 = 0, int a2 = 0, int a3 = 0, int a4 = 0, int a5 = 0, int a6 = 0, int a7 = 0, int a8 = 0, int a9 = 0, int aa = 0, int ab = 0, int ac = 0, int ad = 0, int ae = 0, int af = 0) πŸ”— Source

Uses a buffer to print the results of sprintf(formatstr,…) straight to allegro.log

Warning

Deprecated! Use the internal printf() instead.