Link Search Menu Expand Document

Strings (Текстовые)

Функции


atof

float atof(string text)

atoi

int atoi(string text)

charcode

int charcode(string text)

Returns ASCII code for the first character in given string.


get_string_pointer

funcX

int get_string_pointer(string text)

Returns a pointer to a string variable or to a text.


get_text_width

funcX

int get_text_width(string text)

Returns the text width in pixels for the currently set font.


message_str_game

string message_str_game(int fileId, int messageId)

Works exactly the same as message_str, except you get messages from files in text/english/game folder. Use GAME_MSG_* defines or mstr_* macros from sfall.h to use specific msg file

  • Additional game msg files added by ExtraGameMsgFileList setting will have consecutive fileIds assigned beginning from 0x2000 to 0x2FFF. (e.g. if you set ExtraGameMsgFileList=foo,bar in ddraw.ini, foo.msg will be associated with 0x2000 and bar.msg with 0x2001.).
  • If a file has a specific number assigned in ExtraGameMsgFileList, its fileId will be (0x2000 + assigned number). (e.g. with ExtraGameMsgFileList=foo,bar:2,foobar in ddraw.ini, bar.msg will be associated with 0x2002 and foobar.msg with 0x2003.)

sfall_func2(“string_compare”, string str1, string str2)

funcX

bool sfall_func2("string_compare", string str1, string str2)

Compares two strings case-insensitive, and returns True if the two strings are matched.


sfall_func3(“string_compare”, string str1, string str2, int codePage)

funcX

bool sfall_func3("string_compare", string str1, string str2, int codePage)

Compares two strings case-insensitive, and returns True if the two strings are matched

  • codePage: code page number to properly compare national characters in the range 128-255 of the ASCII code table available encodings: 1250-1252, 866

sprintf

string sprintf(string format, any value)

Formats given value using standart syntax of C printf function (google “printf” for format details). However it is limited to formatting only 1 value. Can be used to get character by ASCII code (“%c”).


string_format

funcX

string string_format(string format, any val1, any val2, ...)

Formats given value using standard syntax of C printf function (google “printf” for format details). However it is limited to formatting up to 4 values.

  • formatting is only supported for %s and %d, and the format string is limited to 1024 characters

string_split

array string_split(string, split)

Takes a string and a seperator, searches the string for all instances of the seperator, and returns a temp array filled with the pieces of the string split at each instance. If you give an empty string as the seperator, the string is split into individual characters. You can use this to search for a substring in a string like this: strlen(get_array(string_split(haystack, needle), 0))


string_to_case

string sfall_func2("string_to_case", string text, int toCase)

Converts all letters in the given string to the specified case.

toCase: 0 - lowercase, 1 - uppercase

NOTE: this function works only for English letters of A-Z/a-z.


strlen

int strlen(string text)

Returns string length.


substr

string substr(string, start, length)

Cuts a substring from a string starting at “start” up to “length” characters. The first character position is 0 (zero).

  • If start is negative - it indicates starting position from the end of the string (for example substr("test", -2, 2) will return last 2 charactes: “st”).
  • If length is negative - it means so many characters will be omitted from the end of string (example: substr("test", 0, -2) will return string without last 2 characters: “te”).
  • If length is zero - it will return a string from the starting position to the end of the string New behavior for sfall 4.2.2/3.8.22