Skip to content

Utilities

Functions

Contains

Returns true if the string contains the substring.

Parameters:

NameTypeDescription
textStringThe text to search
subtextStringThe substring to search for

Return Type: Boolean

Signatures:

bool contains(const string &text, const string &subtext)

Convert To Double

Convert the passed in string into a double. This can fail in an error if the value is not a number, consider using Is Number to check before converting a string.

Parameters:

NameTypeDescription
textStringThe text to convert.

Return Type: Double

Signatures:

double convert_to_double(const string &text)

Convert To Integer

Convert the passed in string into an integer. This can fail in an error if the value is not an integer, consider using Is Integer to check before converting a string.

Parameters:

NameTypeDescription
textStringThe text to convert.

Return Type: Integer

Signatures:

int convert_to_integer(const string &text)

Index Of

Returns the index of the first occurrence of the substring in the text.

Parameters:

NameTypeDescription
textStringThe text to search
subtextStringThe substring to search for

Return Type: Integer

Signatures:

int index_of(const string &text, const string &subtext)

Is Double

Checks if a string contains a number.

Parameters:

NameTypeDescription
textStringThe text to check.

Return Type: Boolean

Signatures:

bool is_double(const string &text)

Is Integer

Checks if a string contains an integer value.

Parameters:

NameTypeDescription
textStringThe text to check.

Return Type: Boolean

Signatures:

bool is_integer(const string &text)

Is Number

Checks if a string contains a number.

Parameters:

NameTypeDescription
textStringThe text to check.

Return Type: Boolean

Signatures:

bool is_number(const string &text)

Length Of

Returns the length of a string in characters.

Parameters:

NameTypeDescription
textStringThe text to get the length of

Return Type: Integer

Signatures:

int length_of(const string &text)

Replace All

Replace all occurrences of a substring in a string with another string.

Parameters:

NameTypeDescription
textStringThe text to search
substrStringThe substring to find and replace
newTextStringThe string to replace the substring with

Return Type: String

Signatures:

string replace_all(const string &text, const string &substr, const string &newText)

Split

Split a string into an array of strings based on a delimiter.

Parameters:

NameTypeDescription
textStringThe text to split
delimiterCharThe character to split the text on

Return Type: Vector

Signatures:

vector<string> split(const string &text, char delimiter)

To Lowercase

Return a lowercase version of the passed in string.

Parameters:

NameTypeDescription
textStringThe text to convert.

Return Type: String

Signatures:

string to_lowercase(const string &text)

To Uppercase

Return a UPPERCASE version of the passed in string.

Parameters:

NameTypeDescription
textStringThe text to convert.

Return Type: String

Signatures:

string to_uppercase(const string &text)

Trim

Return a new string that removes the spaces from the start and end of the input string.

Parameters:

NameTypeDescription
textStringThe string to trim.

Return Type: String

Signatures:

string trim(const string &text)

Rnd

Rnd

Generates a random number between ‘min’ and max, including ‘min’ and ‘max’.

Parameters:

NameTypeDescription
minIntegerthe Integer representing of minimum bound.
maxIntegerthe Integer representing of maximum bound.

Return Type: Integer

Signatures:

int rnd(int min, int max)

Rnd

Generates a random number between 0 and 1

Return Type: Float

Signatures:

float rnd()

Rnd

Generates a random number between 0 and ubound.

Parameters:

NameTypeDescription
uboundIntegerthe Integer representing the upper bound.

Return Type: Integer

Signatures:

int rnd(int ubound)

Current Ticks

Gets the number of milliseconds that have passed since the program was started.

Return Type: Unsigned Integer

Signatures:

unsigned int current_ticks()

Delay

Puts the program to sleep for a specified number of milliseconds. If this is larger than 1 second, SplashKit will check to see if the user tries to quit during the delay. If the user does quit, the delay function returns without waiting.

Parameters:

NameTypeDescription
millisecondsIntegerThe number of milliseconds to wait

Signatures:

void delay(int milliseconds)

Display Dialog

Display a dialog to the screen with a message for the user.

Parameters:

NameTypeDescription
titleStringThe title of the dialog window.
msgStringThe message for the dialog window.
output_fontFontThe font for the dialog text
font_sizeIntegerThe size of the font for the dialog text

Signatures:

void display_dialog(const string &title, const string &msg, font output_font, int font_size)

File As String

Return a SplashKit resource of Resource Kind with name filename as a string.

Parameters:

NameTypeDescription
filenameStringThe filename of the resource.
kindResource KindThe kind of resource.

Return Type: String

Signatures:

string file_as_string(string filename, resource_kind kind)