Skip to content

Utilities

Utilities Guides

Using Utilities Examples & Guides

Functions

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)

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)

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 - undefined

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)