Utilities

SplashKit provides miscellaneous utilities for unclassified functionality.SplashKit provides some basic data manipulation functions to help make it easy to get some basic tasks performed.SplashKit random provides a simple implementation of random.

The SplashKitS Random Library Provides Two Rnd Methods, Arnd()which generates a random number between 0 and 1, andRnd(int Ubound)which generates a random number between 0 and the value scpeficied inUbound`.

Utilities Guides

Useful Utilities

Functions

Current Ticks

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

Return Type

Unsigned Integer

The number of milliseconds passed

Signatures
unsigned int current_ticks()
public static uint Utilities.CurrentTicks();
public static uint SplashKit.CurrentTicks();
function CurrentTicks(): Cardinal
def 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
Name Type Description
Milliseconds

Unsigned Integer

The number of milliseconds to wait

Signatures
void delay(unsigned int milliseconds)
public static void Utilities.Delay(uint milliseconds);
public static void SplashKit.Delay(uint milliseconds);
procedure Delay(milliseconds: Cardinal)
def delay(milliseconds):

Display Dialog

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

Parameters
Name Type Description
Title

String

The title of the dialog window.

Msg

String

The message for the dialog window.

Output Font

Font

The font for the dialog text

Font Size

Integer

The size of the font for the dialog text

Signatures
void display_dialog(const string &title, const string &msg, font output_font, int font_size)
public static void Utilities.DisplayDialog(string title, string msg, Font outputFont, int fontSize);
public static void SplashKit.DisplayDialog(string title, string msg, Font outputFont, int fontSize);
procedure DisplayDialog(const title: String; const msg: String; outputFont: Font; fontSize: Integer)
def display_dialog(title, msg, output_font, font_size):

File As String

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

Return Type

String

The file loaded into a string.

Parameters
Name Type Description
Filename

String

The filename of the resource.

Kind

Resource Kind

The kind of resource.

Signatures
string file_as_string(string filename, resource_kind kind)
public static string Utilities.FileAsString(string filename, ResourceKind kind);
public static string SplashKit.FileAsString(string filename, ResourceKind kind);
function FileAsString(filename: String; kind: ResourceKind): String
def file_as_string(filename, kind):

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.

Return Type

Double

The double value read from the text.

Parameters
Name Type Description
Text

String

The text to convert.

Signatures
double convert_to_double(const string &text)
public static double Utilities.ConvertToDouble(string text);
public static double SplashKit.ConvertToDouble(string text);
function ConvertToDouble(const text: String): Double
def convert_to_double(text):
Guides
Useful Utilities

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.

Return Type

Integer

The integer value read from the text.

Parameters
Name Type Description
Text

String

The text to convert.

Signatures
int convert_to_integer(const string &text)
public static int Utilities.ConvertToInteger(string text);
public static int SplashKit.ConvertToInteger(string text);
function ConvertToInteger(const text: String): Integer
def convert_to_integer(text):
Guides
Useful Utilities

Is Double

Checks if a string contains a number.

Return Type

Boolean

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

Parameters
Name Type Description
Text

String

The text to check.

Signatures
bool is_double(const string &text)
public static bool Utilities.IsDouble(string text);
public static bool SplashKit.IsDouble(string text);
function IsDouble(const text: String): Boolean
def is_double(text):

Is Integer

Checks if a string contains an integer value.

Return Type

Boolean

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

Parameters
Name Type Description
Text

String

The text to check.

Signatures
bool is_integer(const string &text)
public static bool Utilities.IsInteger(string text);
public static bool SplashKit.IsInteger(string text);
function IsInteger(const text: String): Boolean
def is_integer(text):
Guides
Useful Utilities

Is Number

Checks if a string contains a number.

Return Type

Boolean

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

Parameters
Name Type Description
Text

String

The text to check.

Signatures
bool is_number(const string &text)
public static bool Utilities.IsNumber(string text);
public static bool SplashKit.IsNumber(string text);
function IsNumber(const text: String): Boolean
def is_number(text):
Guides
Useful Utilities

To Lowercase

Return a lowercase version of the passed in string.

Return Type

String

A lower case version of the passed in text.

Parameters
Name Type Description
Text

String

The text to convert.

Signatures
string to_lowercase(const string &text)
public static string Utilities.ToLowercase(string text);
public static string SplashKit.ToLowercase(string text);
function ToLowercase(const text: String): String
def to_lowercase(text):
Guides
Useful Utilities

To Uppercase

Return a UPPERCASE version of the passed in string.

Return Type

String

An upper case version of the passed in text.

Parameters
Name Type Description
Text

String

The text to convert.

Signatures
string to_uppercase(const string &text)
public static string Utilities.ToUppercase(string text);
public static string SplashKit.ToUppercase(string text);
function ToUppercase(const text: String): String
def to_uppercase(text):
Guides
Useful Utilities

Trim

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

Return Type

String

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

Parameters
Name Type Description
Text

String

The string to trim.

Signatures
string trim(const string &text)
public static string Utilities.Trim(string text);
public static string SplashKit.Trim(string text);
function Trim(const text: String): String
def trim(text):
Guides
Useful Utilities

Rnd

This function is overloaded. The following versions exist.

Rnd

Generates a random number between 'min' and Max, including 'min' and 'max'.

Return Type

Integer

Returns an Integer between and including Min and Max

Parameters
Name Type Description
Min

Integer

the Integer representing of minimum bound.

Max

Integer

the Integer representing of maximum bound.

Signatures
int rnd(int min, int max)
public static int Random.Rnd(int min, int max);
public static int SplashKit.Rnd(int min, int max);
function Rnd(min: Integer; max: Integer): Integer
def rnd_range(min, max):

Rnd

Generates a random number between 0 and 1

Return Type

Float

Returns a Float between 0 and 1

Signatures
float rnd()
public static float Random.Rnd();
public static float SplashKit.Rnd();
function Rnd(): Single
def rnd():

Rnd

Generates a random number between 0 and Ubound.

Return Type

Integer

Returns an Integer between 0 and Ubound

Parameters
Name Type Description
Ubound

Integer

the Integer representing the upper bound.

Signatures
int rnd(int ubound)
public static int Random.Rnd(int ubound);
public static int SplashKit.Rnd(int ubound);
function Rnd(ubound: Integer): Integer
def rnd_int(ubound):