Skip to content

Utilities

Converts the provided Base64 encoded string back to its original form. For example, “TWFu” will be converted to “Man”.

Parameters:

NameTypeDescription
inputStringBase64 encoded string to decode

Return Type: String

Returns: Decoded original string

Signatures:

string base64_decode(const string &input)

Converts the provided string into its Base64 encoded representation. For example, “Man” will be converted to “TWFu”.

Parameters:

NameTypeDescription
inputStringString to encode

Return Type: String

Returns: Base64 encoded string

Signatures:

string base64_encode(const string &input)

Converts the provided binary string into an unsigned integer. For example, “1010” will be converted to 10.

Parameters:

NameTypeDescription
binStringBinary string to convert

Return Type: Unsigned Integer

Signatures:

unsigned int bin_to_dec(const string &bin)

Converts the provided binary string into a hexadecimal string representation. For example, “1010” will be converted to “A”.

Parameters:

NameTypeDescription
bin_strStringBinary string to convert

Return Type: String

Returns: Hexadecimal string representation of the binary string, or an empty string if the string is not a valid binary string

Signatures:

string bin_to_hex(const string &bin_str)

Converts the provided binary string into its octal string representation. For example, “1010” will be converted to “12”.

Parameters:

NameTypeDescription
bin_strStringBinary string to convert

Return Type: String

Returns: Octal string representation of the binary string, or an empty string if the string is not a valid binary string

Signatures:

string bin_to_oct(const string &bin_str)

Returns true if the string contains the substring.

Parameters:

NameTypeDescription
textStringThe text to search
subtextStringThe substring to search for

Return Type: Boolean

Returns: True if the substring is found in the text.

Signatures:

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

Usage:  {</>}


Note: This function is deprecated. Use To Double instead.

Parameters:

NameTypeDescription
textStringThe text to convert.

Return Type: Double

Returns: The double value read from the text.

Signatures:

double convert_to_double(const string &text)

Note: This function is deprecated. Use To Integer instead.

Parameters:

NameTypeDescription
textStringThe text to convert.

Return Type: Integer

Returns: The integer value read from the text.

Signatures:

int convert_to_integer(const string &text)

Converts the provided unsigned integer into a binary string. For example, 10 will be converted to “1010”.

Parameters:

NameTypeDescription
decUnsigned IntegerDecimal (unsigned integer) to convert

Return Type: String

Returns: Binary string representation of the decimal

Signatures:

string dec_to_bin(unsigned int dec)

Converts the provided decimal value into its octal string representation. For example, 64 will be converted to “100”.

Parameters:

NameTypeDescription
decimal_valueUnsigned IntegerDecimal (unsigned integer) to convert

Return Type: String

Returns: Octal string representation of the decimal value, or “0” if the value is 0

Signatures:

string dec_to_oct(unsigned int decimal_value)

The greatest common divisor (GCD) of two numbers is the largest positive integer that divides both numbers without a remainder.

Parameters:

NameTypeDescription
number1IntegerFirst number
number2IntegerSecond number

Return Type: Integer

Returns: Greatest common divisor of the two numbers, or 0 if both numbers are 0

Signatures:

int greatest_common_divisor(int number1, int number2)

Converts the provided hexadecimal string into its binary string representation. For example, “A” will be converted to “1010”.

Parameters:

NameTypeDescription
hex_strStringHexadecimal string to convert

Return Type: String

Returns: Binary string representation of the hexadecimal string, or an empty string if the string is not a valid hexadecimal string

Signatures:

string hex_to_bin(const string &hex_str)

Parameters:

NameTypeDescription
hex_stringStringthe data to convert

Return Type: Unsigned Integer

Signatures:

unsigned int hex_to_dec(const string &hex_string)

Converts the provided hexadecimal string into its octal string representation. For example, “A” will be converted to “12”.

Parameters:

NameTypeDescription
hex_strStringHexadecimal string to convert

Return Type: String

Returns: Octal string representation of the hexadecimal string, or an empty string if the string is not a valid hexadecimal string

Signatures:

string hex_to_oct(const string &hex_str)

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

Returns: The index of the first occurrence of the substring in the text, or -1 if the substring is not found.

Signatures:

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

Usage:  {</>}


A binary string is a string that contains only ‘0’ and ‘1’ characters.

Parameters:

NameTypeDescription
bin_strStringBinary string to check

Return Type: Boolean

Returns: True if the string is a valid binary string, false otherwise

Signatures:

bool is_binary(const string &bin_str)

Checks if a string contains a number.

Parameters:

NameTypeDescription
textStringThe text to check.

Return Type: Boolean

Returns: True if the text contains a number (and only a number).

Signatures:

bool is_double(const string &text)

Usage:  {</>}


A hexadecimal string is a string that contains only characters from ‘0’ to ‘9’ and ‘A’ to ‘F’ (or ‘a’ to ‘f’).

Parameters:

NameTypeDescription
hex_strStringHexadecimal string to check

Return Type: Boolean

Returns: True if the string is a valid hexadecimal string, false otherwise

Signatures:

bool is_hex(const string &hex_str)

Checks if a string contains an integer value.

Parameters:

NameTypeDescription
textStringThe text to check.

Return Type: Boolean

Returns: True if the text contains a whole number (and only a whole number).

Signatures:

bool is_integer(const string &text)

Usage:  {</>}


Checks if a string contains a number.

Parameters:

NameTypeDescription
textStringThe text to check.

Return Type: Boolean

Returns: True if the text contains a number (and only a number).

Signatures:

bool is_number(const string &text)

Usage:  {</>}


An octal string is a string that contains only characters from ‘0’ to ‘7’.

Parameters:

NameTypeDescription
octal_strStringOctal string to check

Return Type: Boolean

Returns: True if the string is a valid octal string, false otherwise

Signatures:

bool is_octal(const string &octal_str)

A prime number is a number greater than 1 that has no positive divisors other than 1 and itself.

Parameters:

NameTypeDescription
numberIntegerNumber to check

Return Type: Boolean

Returns: True if the number is a prime number, false otherwise

Signatures:

bool is_prime_number(int number)

The least common multiple (LCM) of two numbers is the smallest positive integer that is divisible by both numbers.

Parameters:

NameTypeDescription
number1IntegerFirst number
number2IntegerSecond number

Return Type: Integer

Returns: Least common multiple of the two numbers, or 0 if either of the numbers are 0

Signatures:

int least_common_multiple(int number1, int number2)

Returns the length of a string in characters.

Parameters:

NameTypeDescription
textStringThe text to get the length of

Return Type: Integer

Returns: The number of characters in the string.

Signatures:

int length_of(const string &text)

Usage:  {</>}


Converts the provided octal string into its binary string representation. For example, “12” will be converted to “1010”.

Parameters:

NameTypeDescription
octal_strStringOctal string to convert

Return Type: String

Returns: Binary string representation of the octal string, or an empty string if the string is not a valid octal string

Signatures:

string oct_to_bin(const string &octal_str)

Converts the provided octal string into its decimal representation. For example, “100” will be converted to 64.

Parameters:

NameTypeDescription
octal_stringStringOctal string to convert

Return Type: Unsigned Integer

Signatures:

unsigned int oct_to_dec(const string &octal_string)

Converts the provided octal string into its hexadecimal string representation. For example, “12” will be converted to “A”.

Parameters:

NameTypeDescription
oct_strStringOctal string to convert

Return Type: String

Returns: Hexadecimal string representation of the octal string, or an empty string if the string is not a valid octal string

Signatures:

string oct_to_hex(const string &oct_str)

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

Parameters:

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

Return Type: String

Returns: The text with all occurrences of the substring replaced with the new text.

Signatures:

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

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

Returns: An array of strings

Signatures:

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

Usage:  {</>}


Calculates the square root of the provided number using the Newton-Raphson method.

Parameters:

NameTypeDescription
numberIntegerNumber to calculate the square root of

Return Type: Double

Returns: Square root of the number

Signatures:

double square_root(int number)

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

Returns: The double value read from the text.

Signatures:

double to_double(const string &text)

Usage:  {</>}


Convert the passed in integer value into a double (decimal value).

Parameters:

NameTypeDescription
valueIntegerThe integer value to convert.

Return Type: Double

Returns: The double value.

Signatures:

double to_double(int value)

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

Returns: The integer value read from the text.

Signatures:

int to_integer(const string &text)

Usage:  {</>}


Return a lowercase version of the passed in string.

Parameters:

NameTypeDescription
textStringThe text to convert.

Return Type: String

Returns: A lower case version of the passed in text.

Signatures:

string to_lowercase(const string &text)

Usage:  {</>}


Convert the passed in double to a string, restricting the output the a given number of decimal places. For example if value is 3.14159265359 and precision is 2 then the output will be “3.14”.

Parameters:

NameTypeDescription
valueDoublethe value to convert to a string.
precisionIntegerthe number of decimal places to output.

Return Type: String

Returns: string containing the double value.

Signatures:

string to_string(double value, int precision)

Usage:  {</>}


Convert the passed in double to a string.

Parameters:

NameTypeDescription
valueDoublethe value to convert to a string.

Return Type: String

Returns: string containing the double value.

Signatures:

string to_string(double value)

Convert the passed in integer to a string.

Parameters:

NameTypeDescription
valueIntegerthe value to convert to a string.

Return Type: String

Returns: string containing the integer value.

Signatures:

string to_string(int value)

Return a UPPERCASE version of the passed in string.

Parameters:

NameTypeDescription
textStringThe text to convert.

Return Type: String

Returns: An upper case version of the passed in text.

Signatures:

string to_uppercase(const string &text)

Usage:  {</>}


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

Returns: A new string with the contents of text, after removing spaces from the start and end.

Signatures:

string trim(const string &text)

Usage:  {</>}


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

Returns: Returns an Integer between and including min and max

Signatures:

int rnd(int min, int max)

Usage:  {</>}


Generates a random number between 0 and 1

Return Type: Float

Returns: Returns a Float between 0 and 1

Signatures:

float rnd()

Usage:  {</>}


Generates a random number between 0 and ubound.

Parameters:

NameTypeDescription
uboundIntegerthe Integer representing the upper bound.

Return Type: Integer

Returns: Returns an Integer between 0 and ubound

Signatures:

int rnd(int ubound)

Usage:  {</>}


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

Return Type: Unsigned Integer

Signatures:

unsigned int current_ticks()

Usage:  {</>}


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)

Usage:  {</>}


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)

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

Returns: The file loaded into a string.

Signatures:

string file_as_string(string filename, resource_kind kind)