Utilities
Functions
Contains
Returns true if the string contains the substring.
Parameters:
| Name | Type | Description |
|---|---|---|
| text | String | The text to search |
| subtext | String | The substring to search for |
Return Type: Boolean
Signatures:
bool contains(const string &text, const string &subtext)public static bool Utilities.Contains(string text, string subtext);public static bool SplashKit.Contains(string text, string subtext);def contains(text, subtext):function Contains(const text: String; const subtext: String): BooleanConvert 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:
| Name | Type | Description |
|---|---|---|
| text | String | The text to convert. |
Return Type: Double
Signatures:
double convert_to_double(const string &text)public static double Utilities.ConvertToDouble(string text);public static double SplashKit.ConvertToDouble(string text);def convert_to_double(text):function ConvertToDouble(const text: String): DoubleConvert 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:
| Name | Type | Description |
|---|---|---|
| text | String | The text to convert. |
Return Type: Integer
Signatures:
int convert_to_integer(const string &text)public static int Utilities.ConvertToInteger(string text);public static int SplashKit.ConvertToInteger(string text);def convert_to_integer(text):function ConvertToInteger(const text: String): IntegerIndex Of
Returns the index of the first occurrence of the substring in the text.
Parameters:
| Name | Type | Description |
|---|---|---|
| text | String | The text to search |
| subtext | String | The substring to search for |
Return Type: Integer
Signatures:
int index_of(const string &text, const string &subtext)public static int Utilities.IndexOf(string text, string subtext);public static int SplashKit.IndexOf(string text, string subtext);def index_of(text, subtext):function IndexOf(const text: String; const subtext: String): IntegerIs Double
Checks if a string contains a number.
Parameters:
| Name | Type | Description |
|---|---|---|
| text | String | The text to check. |
Return Type: Boolean
Signatures:
bool is_double(const string &text)public static bool Utilities.IsDouble(string text);public static bool SplashKit.IsDouble(string text);def is_double(text):function IsDouble(const text: String): BooleanIs Integer
Checks if a string contains an integer value.
Parameters:
| Name | Type | Description |
|---|---|---|
| text | String | The text to check. |
Return Type: Boolean
Signatures:
bool is_integer(const string &text)public static bool Utilities.IsInteger(string text);public static bool SplashKit.IsInteger(string text);def is_integer(text):function IsInteger(const text: String): BooleanIs Number
Checks if a string contains a number.
Parameters:
| Name | Type | Description |
|---|---|---|
| text | String | The text to check. |
Return Type: Boolean
Signatures:
bool is_number(const string &text)public static bool Utilities.IsNumber(string text);public static bool SplashKit.IsNumber(string text);def is_number(text):function IsNumber(const text: String): BooleanLength Of
Returns the length of a string in characters.
Parameters:
| Name | Type | Description |
|---|---|---|
| text | String | The text to get the length of |
Return Type: Integer
Signatures:
int length_of(const string &text)public static int Utilities.LengthOf(string text);public static int SplashKit.LengthOf(string text);def length_of(text):function LengthOf(const text: String): IntegerReplace All
Replace all occurrences of a substring in a string with another string.
Parameters:
| Name | Type | Description |
|---|---|---|
| text | String | The text to search |
| substr | String | The substring to find and replace |
| newText | String | The string to replace the substring with |
Return Type: String
Signatures:
string replace_all(const string &text, const string &substr, const string &newText)public static string Utilities.ReplaceAll(string text, string substr, string newtext);public static string SplashKit.ReplaceAll(string text, string substr, string newtext);def replace_all(text, substr, newText):function ReplaceAll(const text: String; const substr: String; const newtext: String): StringSplit
Split a string into an array of strings based on a delimiter.
Parameters:
| Name | Type | Description |
|---|---|---|
| text | String | The text to split |
| delimiter | Char | The character to split the text on |
Return Type: Vector
Signatures:
vector<string> split(const string &text, char delimiter)public static List<string> Utilities.Split(string text, char delimiter);public static List<string> SplashKit.Split(string text, char delimiter);def split(text, delimiter):function Split(const text: String; delimiter: Char): ArrayOfStringTo Lowercase
Return a lowercase version of the passed in string.
Parameters:
| Name | Type | Description |
|---|---|---|
| text | String | The text to convert. |
Return Type: String
Signatures:
string to_lowercase(const string &text)public static string Utilities.ToLowercase(string text);public static string SplashKit.ToLowercase(string text);def to_lowercase(text):function ToLowercase(const text: String): StringTo Uppercase
Return a UPPERCASE version of the passed in string.
Parameters:
| Name | Type | Description |
|---|---|---|
| text | String | The text to convert. |
Return Type: String
Signatures:
string to_uppercase(const string &text)public static string Utilities.ToUppercase(string text);public static string SplashKit.ToUppercase(string text);def to_uppercase(text):function ToUppercase(const text: String): StringTrim
Return a new string that removes the spaces from the start and end of the input string.
Parameters:
| Name | Type | Description |
|---|---|---|
| text | String | The string to trim. |
Return Type: String
Signatures:
string trim(const string &text)public static string Utilities.Trim(string text);public static string SplashKit.Trim(string text);def trim(text):function Trim(const text: String): StringRnd
Rnd
Generates a random number between ‘min’ and max, including ‘min’ and ‘max’.
Parameters:
| Name | Type | Description |
|---|---|---|
| min | Integer | the Integer representing of minimum bound. |
| max | Integer | the Integer representing of maximum bound. |
Return Type: Integer
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);def rnd_range(min, max):function Rnd(min: Integer; max: Integer): IntegerRnd
Generates a random number between 0 and 1
Return Type: Float
Signatures:
float rnd()public static float Random.Rnd();public static float SplashKit.Rnd();def rnd():function Rnd(): SingleRnd
Generates a random number between 0 and ubound.
Parameters:
| Name | Type | Description |
|---|---|---|
| ubound | Integer | the Integer representing the upper bound. |
Return Type: Integer
Signatures:
int rnd(int ubound)public static int Random.Rnd(int ubound);public static int SplashKit.Rnd(int ubound);def rnd_int(ubound):function Rnd(ubound: Integer): IntegerCurrent Ticks
Gets the number of milliseconds that have passed since the program was started.
Return Type: Unsigned Integer
Signatures:
unsigned int current_ticks()public static uint Utilities.CurrentTicks();public static uint SplashKit.CurrentTicks();def current_ticks():function CurrentTicks(): CardinalDelay
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 | Integer | The number of milliseconds to wait |
Signatures:
void delay(int milliseconds)public static void Utilities.Delay(int milliseconds);public static void SplashKit.Delay(int milliseconds);def delay(milliseconds):procedure Delay(milliseconds: Integer)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);def display_dialog(title, msg, output_font, font_size):procedure DisplayDialog(const title: String; const msg: String; outputFont: Font; fontSize: Integer)File As String
Return a SplashKit resource of Resource Kind with name filename as a string.
Parameters:
| Name | Type | Description |
|---|---|---|
| filename | String | The filename of the resource. |
| kind | Resource Kind | The kind of resource. |
Return Type: String
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);def file_as_string(filename, kind):function FileAsString(filename: String; kind: ResourceKind): String