Functions
Converts the provided Base64 encoded string back to its original form. For example, “TWFu” will be converted to “Man”.
Parameters:
Name Type Description input String
Base64 encoded string to decode
Return Type: String
Signatures:
string base64_decode ( const string & input )
public static string SplashKit . Base64Decode ( string input);
def base64_decode ( input ) :
function Base64Decode ( const input: String ): String
Converts the provided string into its Base64 encoded representation. For example, “Man” will be converted to “TWFu”.
Parameters:
Name Type Description input String
String to encode
Return Type: String
Signatures:
string base64_encode ( const string & input )
public static string SplashKit . Base64Encode ( string input);
def base64_encode ( input ) :
function Base64Encode ( const input: String ): String
Converts the provided binary string into an unsigned integer. For example, “1010” will be converted to 10.
Parameters:
Name Type Description bin String
Binary string to convert
Return Type: Unsigned Integer
Signatures:
unsigned int bin_to_dec ( const string & bin )
public static uint SplashKit . BinToDec ( string bin);
function BinToDec ( const bin: String ): Cardinal
Converts the provided binary string into a hexadecimal string representation. For example, “1010” will be converted to “A”.
Parameters:
Name Type Description bin_str String
Binary string to convert
Return Type: String
Signatures:
string bin_to_hex ( const string & bin_str )
public static string SplashKit . BinToHex ( string binStr);
function BinToHex ( const binStr: String ): String
Converts the provided binary string into its octal string representation. For example, “1010” will be converted to “12”.
Parameters:
Name Type Description bin_str String
Binary string to convert
Return Type: String
Signatures:
string bin_to_oct ( const string & bin_str )
public static string SplashKit . BinToOct ( string binStr);
function BinToOct ( const binStr: String ): String
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 SplashKit . Contains ( string text, string subtext);
def contains ( text , subtext ) :
function Contains ( const text: String ; const subtext: String ): Boolean
Usage: {</>}
See Code Examples Example 1 : Checking if a string contains a word
string text = " Hello World, hello world " ;
string subtext = " World " ;
write_line ( " Text: " + text);
write_line ( " Subtext: " + subtext);
// Check if "Hello World" contains "World"
if ( contains (text, subtext))
write_line ( " The string contains 'World'. " );
write_line ( " The string does not contain 'World'. " );
using static SplashKitSDK . SplashKit;
string text = " Hello World, hello world " ;
string subtext = " World " ;
WriteLine ( " Text: " + text);
WriteLine ( " Subtext: " + subtext);
// Check if "Hello World" contains "World"
if ( Contains (text, subtext))
WriteLine ( " Text contains 'World'. " );
WriteLine ( " Text does not contain 'World'. " );
namespace ContainsExample
public static void Main ()
string text = " Hello World, hello world " ;
string subtext = " World " ;
SplashKit . WriteLine ( " Text: " + text);
SplashKit . WriteLine ( " Subtext: " + subtext);
// Check if "Hello World" contains "World"
if ( SplashKit . Contains (text, subtext))
SplashKit . WriteLine ( " Text contains 'World'. " );
SplashKit . WriteLine ( " Text does not contain 'World'. " );
text = " Hello World, hello world "
write_line ( " Text: " + text )
write_line ( " Subtext: " + subtext )
# Check if "Hello World" contains "World"
if contains ( text , subtext ):
write_line ( " The string contains 'World'. " )
write_line ( " The string does not contain 'World'. " )
Output :
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 SplashKit . ConvertToDouble ( string text);
def convert_to_double ( text ) :
function ConvertToDouble ( const text: String ): Double
Usage: {</>}
See Implementations in Guides
See Code Examples Example 1 : Simple Interest Calculator
write_line ( " Welcome to the Simple Interest Calculator! " );
// Get principal amount from the user
write_line ( " Please enter the principal amount (in dollars): " );
string principal_input = read_line ();
// Get the interest rate from the user
write_line ( " Please enter the interest rate (as a percentage, e.g., 5 for 5%): " );
string rate_input = read_line ();
// Get the time period from the user
write_line ( " Please enter the time period (in years): " );
string time_input = read_line ();
// Convert inputs to double
double principal = convert_to_double (principal_input);
double rate = convert_to_double (rate_input);
double time = convert_to_double (time_input);
// Calculate simple interest: Interest = Principal * Rate * Time / 100
double interest = (principal * rate * time) / 100 ;
write_line ( " Calculating interest... " );
write_line ( " For a principal of $ " + std:: to_string (principal) + " at an interest rate of " + std:: to_string (rate) + " % o ver " + std:: to_string (time) + " years: " );
write_line ( " The simple interest is: $ " + std:: to_string (interest));
using static SplashKitSDK . SplashKit;
WriteLine ( " Welcome to the Simple Interest Calculator! " );
// Get principal amount from the user
WriteLine ( " Please enter the principal amount (in dollars): " );
string principalInput = ReadLine ();
// Get the interest rate from the user
WriteLine ( " Please enter the interest rate (as a percentage, e.g., 5 for 5%): " );
string rateInput = ReadLine ();
// Get the time period from the user
WriteLine ( " Please enter the time period (in years): " );
string timeInput = ReadLine ();
// Convert inputs to double
double principal = ConvertToDouble (principalInput);
double rate = ConvertToDouble (rateInput);
double time = ConvertToDouble (timeInput);
// Calculate simple interest: Interest = Principal * Rate * Time / 100
double interest = (principal * rate * time) / 100 ;
WriteLine ( " Calculating interest... " );
WriteLine ( $" For a principal of ${ principal } at an interest rate of { rate }% over { time } years: " );
WriteLine ( $" The simple interest is: ${ interest } " );
namespace ConvertToDoubleExample
public static void Main ()
SplashKit . WriteLine ( " Welcome to the Simple Interest Calculator! " );
// Get principal amount from the user
SplashKit . WriteLine ( " Please enter the principal amount (in dollars): " );
string principalInput = SplashKit . ReadLine ();
// Get the interest rate from the user
SplashKit . WriteLine ( " Please enter the interest rate (as a percentage, e.g., 5 for 5%): " );
string rateInput = SplashKit . ReadLine ();
// Get the time period from the user
SplashKit . WriteLine ( " Please enter the time period (in years): " );
string timeInput = SplashKit . ReadLine ();
// Convert inputs to double
double principal = SplashKit . ConvertToDouble (principalInput);
double rate = SplashKit . ConvertToDouble (rateInput);
double time = SplashKit . ConvertToDouble (timeInput);
// Calculate simple interest: Interest = Principal * Rate * Time / 100
double interest = (principal * rate * time) / 100 ;
SplashKit . WriteLine ( " Calculating interest... " );
SplashKit . WriteLine ( $" For a principal of ${ principal } at an interest rate of { rate }% over { time } years: " );
SplashKit . WriteLine ( $" The simple interest is: ${ interest } " );
write_line ( " Welcome to the Simple Interest Calculator! " )
# Get principal amount from the user
write_line ( " Please enter the principal amount (in dollars): " )
principal_input = read_line ()
# Get the interest rate from the user
write_line ( " Please enter the interest rate (as a percentage, e.g., 5 for 5%): " )
# Get the time period from the user
write_line ( " Please enter the time period (in years): " )
# Convert inputs to double
principal = convert_to_double ( principal_input )
rate = convert_to_double ( rate_input )
time = convert_to_double ( time_input )
# Calculate simple interest: Interest = Principal * Rate * Time / 100
interest = (principal * rate * time) / 100
write_line ( " Calculating interest... " )
write_line ( f "For a principal of $ {principal} at an interest rate of {rate} % over {time} years:" )
write_line ( f "The simple interest is: $ {interest} " )
Output :
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 SplashKit . ConvertToInteger ( string text);
def convert_to_integer ( text ) :
function ConvertToInteger ( const text: String ): Integer
Usage: {</>}
See Implementations in Guides
See Code Examples Example 1 : Guessing Game
write_line ( " Welcome to the Number Guessing Game! " );
write_line ( " I'm thinking of a number between 1 and 100... " );
string input; // User input
int secret_number = 42 ; // Set a secret number
int guess = - 1 ; // Initialise with an invalid guess
while (guess != secret_number)
// Ask the user for their guess
write_line ( " Please enter your guess: " );
// Validate if the input is a valid integer
// Convert input string to integer
guess = convert_to_integer (input);
// Check if the guess is correct
if (guess > secret_number)
write_line ( " Too high! Try again. " );
else if (guess < secret_number)
write_line ( " Too low! Try again. " );
write_line ( " That's not a valid integer! Please enter a number. " );
write_line ( " Congratulations! You've guessed the correct number: " + std:: to_string (guess));
using static SplashKitSDK . SplashKit;
WriteLine ( " Welcome to the Number Guessing Game! " );
WriteLine ( " I'm thinking of a number between 1 and 100... " );
string input; // User input
int secretNumber = 42 ; // Set a secret number
int guess = - 1 ; // Initialise with an invalid guess
while (guess != secretNumber)
// Ask the user for their guess
WriteLine ( " Please enter your guess: " );
// Validate if the input is a valid integer
// Convert input string to integer
guess = ConvertToInteger (input);
// Check if the guess is correct
if (guess > secretNumber)
WriteLine ( " Too high! Try again. " );
else if (guess < secretNumber)
WriteLine ( " Too low! Try again. " );
WriteLine ( " That's not a valid integer! Please enter a number. " );
WriteLine ( $" Congratulations! You've guessed the correct number: { guess } " );
namespace ConvertToIntegerExample
public static void Main ()
SplashKit . WriteLine ( " Welcome to the Number Guessing Game! " );
SplashKit . WriteLine ( " I'm thinking of a number between 1 and 100... " );
string input; // User input
int secretNumber = 42 ; // Set a secret number
int guess = - 1 ; // Initialise with an invalid guess
while (guess != secretNumber)
// Ask the user for their guess
SplashKit . WriteLine ( " Please enter your guess: " );
input = SplashKit . ReadLine ();
// Validate if the input is a valid integer
if ( SplashKit . IsInteger (input))
// Convert input string to integer
guess = SplashKit . ConvertToInteger (input);
// Check if the guess is correct
if (guess > secretNumber)
SplashKit . WriteLine ( " Too high! Try again. " );
else if (guess < secretNumber)
SplashKit . WriteLine ( " Too low! Try again. " );
SplashKit . WriteLine ( " That's not a valid integer! Please enter a number. " );
SplashKit . WriteLine ( $" Congratulations! You've guessed the correct number: { guess } " );
write_line ( " Welcome to the Number Guessing Game! " )
write_line ( " I'm thinking of a number between 1 and 100... " )
secret_number = 42 ; # Set a secret number
guess = - 1 ; # Initialise with an invalid guess
while guess != secret_number:
# Ask the user for their guess
write_line ( " Please enter your guess: " )
input_value = read_line ()
# Validate if the input is a valid integer
if is_integer ( input_value ):
# Convert input string to integer
guess = convert_to_integer ( input_value )
# Check if the guess is correct
if guess > secret_number:
write_line ( " Too high! Try again. " )
elif guess < secret_number:
write_line ( " Too low! Try again. " )
write_line ( " That's not a valid integer! Please enter a number. " )
write_line ( f "Congratulations! You've guessed the correct number: {guess} " )
Output :
Converts the provided unsigned integer into a binary string. For example, 10 will be converted to “1010”.
Parameters:
Name Type Description dec unsigned int Decimal (unsigned integer) to convert
Return Type: String
Signatures:
string dec_to_bin ( unsigned int dec )
public static string SplashKit . DecToBin ( uint dec);
function DecToBin (dec: Cardinal ): String
Converts the provided decimal value into its octal string representation. For example, 64 will be converted to “100”.
Parameters:
Name Type Description decimal_value unsigned int Decimal (unsigned integer) to convert
Return Type: String
Signatures:
string dec_to_oct ( unsigned int decimal_value )
public static string SplashKit . DecToOct ( uint decimalValue);
def dec_to_oct ( decimal_value ) :
function DecToOct (decimalValue: Cardinal ): String
The greatest common divisor (GCD) of two numbers is the largest positive integer that divides both numbers without a remainder.
Parameters:
Name Type Description number1 Integer
First number number2 Integer
Second number
Return Type: Integer
Signatures:
int greatest_common_divisor ( int number1 , int number2 )
public static int SplashKit . GreatestCommonDivisor ( int number1, int number2);
def greatest_common_divisor ( number1 , number2 ) :
function GreatestCommonDivisor (number1: Integer ; number2: Integer ): Integer
Converts the provided hexadecimal string into its binary string representation. For example, “A” will be converted to “1010”.
Parameters:
Name Type Description hex_str String
Hexadecimal string to convert
Return Type: String
Signatures:
string hex_to_bin ( const string & hex_str )
public static string SplashKit . HexToBin ( string hexStr);
function HexToBin ( const hexStr: String ): String
Parameters:
Name Type Description hex_string String
the data to convert
Return Type: Unsigned Integer
Signatures:
unsigned int hex_to_dec ( const string & hex_string )
public static uint SplashKit . HexToDec ( string hexString);
def hex_to_dec ( hex_string ) :
function HexToDec ( const hexString: String ): Cardinal
Converts the provided hexadecimal string into its octal string representation. For example, “A” will be converted to “12”.
Parameters:
Name Type Description hex_str String
Hexadecimal string to convert
Return Type: String
Signatures:
string hex_to_oct ( const string & hex_str )
public static string SplashKit . HexToOct ( string hexStr);
function HexToOct ( const hexStr: String ): String
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 SplashKit . IndexOf ( string text, string subtext);
def index_of ( text , subtext ) :
function IndexOf ( const text: String ; const subtext: String ): Integer
Usage: {</>}
See Code Examples Example 1 : Check the index of a given word in a string
// Get sentence input from the user
write_line ( " Enter a sentence: " );
string sentence = read_line ();
// Get the word to search for
write_line ( " Enter the word to search for: " );
string word = read_line ();
// Find index of the word in the sentence
int index = index_of (sentence, word);
// Display results based on whether the word was found or not
write_line ( " The word ' " + word + " ' starts at index: " + std:: to_string (index));
write_line ( " The word ' " + word + " ' was not found in the sentence. " );
using static SplashKitSDK . SplashKit;
// Get sentence input from the user
WriteLine ( " Enter a sentence: " );
string sentence = ReadLine ();
// Get the word to search for
WriteLine ( " Enter the word to search for: " );
string word = ReadLine ();
// Find index of the word in the sentence
int index = IndexOf (sentence, word);
// Display results based on whether the word was found or not
WriteLine ( $" The word '{ word }' starts at index: { index } " );
WriteLine ( $" The word '{ word }' was not found in the sentence. " );
public static void Main ()
// Get sentence input from the user
SplashKit . WriteLine ( " Enter a sentence: " );
string sentence = SplashKit . ReadLine ();
// Get the word to search for
SplashKit . WriteLine ( " Enter the word to search for: " );
string word = SplashKit . ReadLine ();
// Find index of the word in the sentence
int index = SplashKit . IndexOf (sentence, word);
// Display results based on whether the word was found or not
SplashKit . WriteLine ( $" The word '{ word }' starts at index: { index } " );
SplashKit . WriteLine ( $" The word '{ word }' was not found in the sentence. " );
# Get sentence input from the user
write_line ( " Enter a sentence: " )
# Get the word to search for
write_line ( " Enter the word to search for: " )
# Find index of the word in the sentence
index = index_of ( sentence , word )
# Display results based on whether the word was found or not
write_line ( f "The word ' {word} ' starts at index: {index} " )
write_line ( f "The word ' {word} ' was not found in the sentence." )
Output :
A binary string is a string that contains only ‘0’ and ‘1’ characters.
Parameters:
Name Type Description bin_str String
Binary string to check
Return Type: Boolean
Signatures:
bool is_binary ( const string & bin_str )
public static bool SplashKit . IsBinary ( string binStr);
function IsBinary ( const binStr: String ): Boolean
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 SplashKit . IsDouble ( string text);
function IsDouble ( const text: String ): Boolean
Usage: {</>}
See Code Examples Example 1 : Double type?
string values [ 6 ] = { " 123 " , " 45.67 " , " -50 " , " abc " , " 789 " , " 0 " };
for ( int i = 0 ; i < 6 ; i ++ )
// Print the value along with the result using "true" or "false"
write ( values [i] + " - " );
// Check if string is a valid double
if ( is_double ( values [i]))
using static SplashKitSDK . SplashKit;
string [] values = { " 123 " , " 45.67 " , " -50 " , " abc " , " 789 " , " 0 " };
foreach ( string value in values)
// Print the value along with the result using "true" or "false"
// Check if string is a valid double
namespace IsDoubleExample
public static void Main ()
string [] values = { " 123 " , " 45.67 " , " -50 " , " abc " , " 789 " , " 0 " };
foreach ( string value in values)
// Print the value along with the result using "true" or "false"
SplashKit . Write ( value + " - " );
// Check if string is a valid double
if ( SplashKit . IsDouble ( value ))
SplashKit . WriteLine ( " true " );
SplashKit . WriteLine ( " false " );
values = [ " 123 " , " 45.67 " , " -50 " , " abc " , " 789 " , " 0 " ]
# Print the value along with the result using "true" or "false"
# Check if string is a valid double
Output :
A hexadecimal string is a string that contains only characters from ‘0’ to ‘9’ and ‘A’ to ‘F’ (or ‘a’ to ‘f’).
Parameters:
Name Type Description hex_str String
Hexadecimal string to check
Return Type: Boolean
Signatures:
bool is_hex ( const string & hex_str )
public static bool SplashKit . IsHex ( string hexStr);
function IsHex ( const hexStr: String ): Boolean
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 SplashKit . IsInteger ( string text);
function IsInteger ( const text: String ): Boolean
Usage: {</>}
See Implementations in Guides
See Code Examples Example 1 : Input Validation of Integers
write_line ( " Welcome to the Integer Validation Checker! " );
// Get the user input as a string
write_line ( " Please enter a valid integer: " );
string input = read_line ();
// Check if the input is a valid integer
// Loop while the user input is NOT valid (aka check for the wrong answers here)
while ( ! is_integer (input))
write_line ( " Oops! That's not a valid integer. Please try again. " );
// Allow the user to enter their input again
write_line ( " Please enter a valid integer: " );
// Convert input to integer
int number = convert_to_integer (input);
write_line ( " Great! You've entered a valid integer: " + std:: to_string (number));
write_line ( " Thank you for using the Integer Validation Checker! " );
using static SplashKitSDK . SplashKit;
WriteLine ( " Welcome to the Integer Validation Checker! " );
// Get the user input as a string
WriteLine ( " Please enter a valid integer: " );
string input = ReadLine ();
// Check if the input is a valid integer
// Loop while the user input is NOT valid (aka check for the wrong answers here)
while ( ! IsInteger (input))
WriteLine ( " Oops! That's not a valid integer. Please try again. " );
// Allow the user to enter their input again
WriteLine ( " Please enter a valid integer: " );
// Convert input to integer
int number = ConvertToInteger (input);
WriteLine ( $" Great! You've entered a valid integer: { number } " );
WriteLine ( " Thank you for using the Integer Validation Checker! " );
namespace IsIntegerExample
public static void Main ()
SplashKit . WriteLine ( " Welcome to the Integer Validation Checker! " );
// Get the user input as a string
SplashKit . WriteLine ( " Please enter a valid integer: " );
string input = SplashKit . ReadLine ();
// Check if the input is a valid integer
// Loop while the user input is NOT valid (aka check for the wrong answers here)
while ( ! SplashKit . IsInteger (input))
SplashKit . WriteLine ( " Oops! That's not a valid integer. Please try again. " );
// Allow the user to enter their input again
SplashKit . WriteLine ( " Please enter a valid integer: " );
input = SplashKit . ReadLine ();
// Convert input to integer
int number = SplashKit . ConvertToInteger (input);
SplashKit . WriteLine ( $" Great! You've entered a valid integer: { number } " );
SplashKit . WriteLine ( " Thank you for using the Integer Validation Checker! " );
write_line ( " Welcome to the Integer Validation Checker! " )
# Get the user input as a string
write_line ( " Please enter a valid integer: " )
# Check if the input is a valid integer
# Loop while the user input is NOT valid (aka check for the wrong answers here)
while ( not is_integer ( input )):
write_line ( " Oops! That's not a valid integer. Please try again. " )
# Allow the user to enter their input again
write_line ( " Please enter a valid integer: " )
# Convert input to integer
number = convert_to_integer ( input )
write_line ( f "Great! You've entered a valid integer: {number} " )
write_line ( " Thank you for using the Integer Validation Checker! " )
Output :
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 SplashKit . IsNumber ( string text);
function IsNumber ( const text: String ): Boolean
Usage: {</>}
See Implementations in Guides
An octal string is a string that contains only characters from ‘0’ to ‘7’.
Parameters:
Name Type Description octal_str String
Octal string to check
Return Type: Boolean
Signatures:
bool is_octal ( const string & octal_str )
public static bool SplashKit . IsOctal ( string octalStr);
function IsOctal ( const octalStr: String ): Boolean
A prime number is a number greater than 1 that has no positive divisors other than 1 and itself.
Parameters:
Name Type Description number Integer
Number to check
Return Type: Boolean
Signatures:
bool is_prime_number ( int number )
public static bool SplashKit . IsPrimeNumber ( int number);
def is_prime_number ( number ) :
function IsPrimeNumber (number: Integer ): Boolean
The least common multiple (LCM) of two numbers is the smallest positive integer that is divisible by both numbers.
Parameters:
Name Type Description number1 Integer
First number number2 Integer
Second number
Return Type: Integer
Signatures:
int least_common_multiple ( int number1 , int number2 )
public static int SplashKit . LeastCommonMultiple ( int number1, int number2);
def least_common_multiple ( number1 , number2 ) :
function LeastCommonMultiple (number1: Integer ; number2: Integer ): Integer
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 SplashKit . LengthOf ( string text);
function LengthOf ( const text: String ): Integer
Usage: {</>}
See Code Examples Example 1 : How long is a string?
// Array of strings to analyse
string texts [ 7 ] = { " SplashKit " , " Hello " , " 12345 " , " A quick brown fox leaps high " , " 3.141592653589793 " , " hi " , "" };
// Loop through each string and print its length
for ( int i = 0 ; i < 7 ; i ++ )
int length = length_of (text); // Get the length of the string
write_line ( " The length of ' " + text + " ' is: " + std:: to_string (length) + " characters. " );
using static SplashKitSDK . SplashKit;
// Array of strings to analyse
string [] texts = { " SplashKit " , " Hello " , " 12345 " , " A quick brown fox leaps high " , " 3.141592653589793 " , " hi " , "" };
// Loop through each string and print its length
foreach ( string text in texts)
int length = LengthOf (text); // Get the length of the string
WriteLine ( $" The length of '{ text }' is: { length } characters. " );
namespace LengthOfExample
public static void Main ()
// Array of strings to analyse
string [] texts = { " SplashKit " , " Hello " , " 12345 " , " A quick brown fox leaps high " , " 3.141592653589793 " , " hi " , "" };
// Loop through each string and print its length
foreach ( string text in texts)
int length = SplashKit . LengthOf (text); // Get the length of the string
SplashKit . WriteLine ( $" The length of '{ text }' is: { length } characters. " );
# Array of strings to analyse
texts = [ " SplashKit " , " Hello " , " 12345 " , " A quick brown fox leaps high " , " 3.141592653589793 " , " hi " , "" ]
# Loop through each string and print its length
length = length_of ( text ) # Get the length of the string
write_line ( f "The length of ' {text} ' is: {length} characters." )
Output :
Converts the provided octal string into its binary string representation. For example, “12” will be converted to “1010”.
Parameters:
Name Type Description octal_str String
Octal string to convert
Return Type: String
Signatures:
string oct_to_bin ( const string & octal_str )
public static string SplashKit . OctToBin ( string octalStr);
def oct_to_bin ( octal_str ) :
function OctToBin ( const octalStr: String ): String
Converts the provided octal string into its decimal representation. For example, “100” will be converted to 64.
Parameters:
Name Type Description octal_string String
Octal string to convert
Return Type: Unsigned Integer
Signatures:
unsigned int oct_to_dec ( const string & octal_string )
public static uint SplashKit . OctToDec ( string octalString);
def oct_to_dec ( octal_string ) :
function OctToDec ( const octalString: String ): Cardinal
Converts the provided octal string into its hexadecimal string representation. For example, “12” will be converted to “A”.
Parameters:
Name Type Description oct_str String
Octal string to convert
Return Type: String
Signatures:
string oct_to_hex ( const string & oct_str )
public static string SplashKit . OctToHex ( string octStr);
function OctToHex ( const octStr: String ): String
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 new_text String
The string to replace the substring with
Return Type: String
Signatures:
string replace_all ( const string & text , const string & substr , const string & new_text )
public static string SplashKit . ReplaceAll ( string text, string substr, string newText);
def replace_all ( text , substr , new_text ) :
function ReplaceAll ( const text: String ; const substr: String ; const newText: String ): String
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 > SplashKit . Split ( string text, char delimiter);
def split ( text , delimiter ) :
function Split ( const text: String ; delimiter: Char ): ArrayOfString
Calculates the square root of the provided number using the Newton-Raphson method.
Parameters:
Name Type Description number Integer
Number to calculate the square root of
Return Type: Double
Signatures:
double square_root ( int number )
public static double SplashKit . SquareRoot ( int number);
function SquareRoot (number: Integer ): Double
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 SplashKit . ToLowercase ( string text);
function ToLowercase ( const text: String ): String
Usage: {</>}
See Implementations in Guides
See Code Examples Example 1 : Convert text to lowercase
write_line ( " Type a phrase in ALL CAPS (SHOUT IT!): " );
string input = read_line ();
// Convert input to lowercase
string quieted = to_lowercase (input);
write_line ( " Calm down... here it is in lowercase: " + quieted);
using static SplashKitSDK . SplashKit;
WriteLine ( " Type a phrase in ALL CAPS (SHOUT IT!): " );
string input = ReadLine ();
// Convert input to lowercase
string quieted = ToLowercase (input);
WriteLine ( " Calm down... here it is in lowercase: " + quieted);
namespace ToLowercaseExample
public static void Main ()
SplashKit . WriteLine ( " Type a phrase in ALL CAPS (SHOUT IT!): " );
string input = SplashKit . ReadLine ();
// Convert input to lowercase
string quieted = SplashKit . ToLowercase (input);
SplashKit . WriteLine ( " Calm down... here it is in lowercase: " + quieted);
write_line ( " Type a phrase in ALL CAPS (SHOUT IT!): " )
# Convert input to lowercase
quieted = to_lowercase ( input_text )
write_line ( f "Calm down... here it is in lowercase: {quieted} " )
Output :
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 SplashKit . ToUppercase ( string text);
function ToUppercase ( const text: String ): String
Usage: {</>}
See Implementations in Guides
See Code Examples Example 1 : Case-insensitive string comparison
write ( " What is your favourite colour: " );
string input = read_line ();
// Convert input to uppercase for comparison
if ( to_uppercase (input) == " PURPLE " )
write_line ( " WOO HOO Purple club! " );
write_line ( " Great colour! " );
using static SplashKitSDK . SplashKit;
Write ( " What is your favourite colour: " );
string input = ReadLine ();
// Convert input to uppercase for comparison
if ( ToUppercase (input) == " PURPLE " )
WriteLine ( " WOO HOO Purple club! " );
WriteLine ( " Great colour! " );
namespace ToUppercaseExample
public static void Main ()
SplashKit . Write ( " What is your favourite colour: " );
string input = SplashKit . ReadLine ();
// Convert input to uppercase for comparison
if ( SplashKit . ToUppercase (input) == " PURPLE " )
SplashKit . WriteLine ( " WOO HOO Purple club! " );
SplashKit . WriteLine ( " Great colour! " );
SplashKit . WriteLine ( " --- " );
write ( " What is your favourite colour: " )
# Convert input to uppercase for comparison
if ( to_uppercase ( input ) == " PURPLE " ):
write_line ( " WOO HOO Purple club! " )
write_line ( " Great colour! " )
Output :
Example 2 : Swap between upper and lower case in a string
string text = " Monkeys love bananas, but penguins prefer ice cream sundaes. " ;
// Loop through each character in the string
for ( int i = 0 ; i <= length_of (text); i ++ )
if (i == length_of (text) || text [i] == ' ' )
// Process the word (alternate between uppercase and lowercase)
result += to_uppercase (word);
result += to_lowercase (word);
if (i != length_of (text))
result += " " ; // Add space after word if not at end of string
to_upper = ! to_upper; // Alternate case for next word
word += text [i]; // Add character to current word
write_line ( " Original text: " + text);
write_line ( " Modified text: " + result);
using static SplashKitSDK . SplashKit;
string text = " Monkeys love bananas, but penguins prefer ice cream sundaes. " ;
// Loop through each character in the string
for ( int i = 0 ; i <= LengthOf (text); i ++ )
if (i == LengthOf (text) || text [i] == ' ' )
// Process the word (alternate between uppercase and lowercase)
result += ToUppercase (word);
result += ToLowercase (word);
result += " " ; // Add space after word if not at end of string
toUpper = ! toUpper; // Alternate case for next word
word += text [i]; // Add character to current word
WriteLine ( " Original text: " + text);
WriteLine ( " Modified text: " + result);
namespace ConvertToAlternateCase
public static void Main ()
string text = " Monkeys love bananas, but penguins prefer ice cream sundaes. " ;
// Loop through each character in the string
for ( int i = 0 ; i <= SplashKit . LengthOf (text); i ++ )
if (i == SplashKit . LengthOf (text) || text [i] == ' ' )
// Process the word (alternate between uppercase and lowercase)
result += SplashKit . ToUppercase (word);
result += SplashKit . ToLowercase (word);
if (i != SplashKit . LengthOf (text))
result += " " ; // Add space after word if not at end of string
toUpper = ! toUpper; // Alternate case for next word
word += text [i]; // Add character to current word
SplashKit . WriteLine ( " Original text: " + text);
SplashKit . WriteLine ( " Modified text: " + result);
text = " Monkeys love bananas, but penguins prefer ice cream sundaes. "
# Loop through each character in the string
for i in range ( len ( text ) + 1 ):
if i == len ( text ) or text[i] == ' ' :
# Process the word (alternate between uppercase and lowercase)
result += to_uppercase ( word )
result += to_lowercase ( word )
result += " " # Add space after word if not at end of string
to_upper = not to_upper # Alternate case for next word
word += text[i] # Add character to current word
write_line ( " Original text: " + text )
write_line ( " Modified text: " + result )
Output :
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 SplashKit . Trim ( string text);
function Trim ( const text: String ): String
Usage: {</>}
See Implementations in Guides
See Code Examples Example 1 : Remove whitespace from a string
string text = " Whitespace is sneaky! " ;
write_line ( " Original string with sneaky spaces: ' " + text + " ' " );
write_line ( " Let's get rid of those pesky spaces... " );
// Trim spaces from the start and end
string trim med = trim (text);
write_line ( " Trimmed string: ' " + trim med + " ' " );
write_line ( " Aha! Much better without those sneaky spaces! " );
using static SplashKitSDK . SplashKit;
string text = " Whitespace is sneaky! " ;
WriteLine ( " Original string with sneaky spaces: ' " + text + " ' " );
WriteLine ( " Let's get rid of those pesky spaces... " );
// Trim spaces from the start and end
string trimmed = Trim (text);
WriteLine ( " Trim med string: ' " + trimmed + " ' " );
WriteLine ( " Aha! Much better without those sneaky spaces! " );
public static void Main ()
string text = " Whitespace is sneaky! " ;
SplashKit . WriteLine ( " Original string with sneaky spaces: ' " + text + " ' " );
SplashKit . WriteLine ( " Let's get rid of those pesky spaces... " );
// Trim spaces from the start and end
string trimmed = SplashKit . Trim (text);
SplashKit . WriteLine ( " Trimmed string: ' " + trimmed + " ' " );
SplashKit . WriteLine ( " Aha! Much better without those sneaky spaces! " );
text = " Whitespace is sneaky! "
write_line ( f "Original string with sneaky spaces: ' {text} '" )
write_line ( " Let's get rid of those pesky spaces... " )
# Trim spaces from the start and end
write_line ( f "Trimmed string: ' { trim med} '" )
write_line ( " Aha! Much better without those sneaky spaces! " )
Output :
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 SplashKit . Rnd ( int min, int max);
function Rnd (min: Integer ; max: Integer ): Integer
Usage: {</>}
See Code Examples Example 1 : Random Number Generator With Range
write_line ( " Let's make this more interesting! " );
// Loop until a valid range is provided
while (min_value >= max_value)
// Get user input for the range
write_line ( " Please enter the minimum number: " );
min_value = convert_to_integer ( read_line ());
write_line ( " Please enter the maximum number: " );
max_value = convert_to_integer ( read_line ());
// Check if min is smaller than max
if (min_value >= max_value)
write_line ( " Oops! The minimum value should be less than the maximum value. Let's re-enter both values. " );
write_line ( " Get ready to generate a random number between " + std:: to_string (min_value) + " and " + std:: to_string (max_value) + " ... " );
write_line ( " Drum roll please... " );
// Generate a random number in the specified range
int random_number = rnd (min_value, max_value);
write_line ( " Your lucky number is: " + std:: to_string (random_number) + " ! " );
write_line ( " How does it feel? Want to try again? " );
using static SplashKitSDK . SplashKit;
WriteLine ( " Let's make this more interesting! " );
// Loop until a valid range is provided
while (minValue >= maxValue)
// Get user input for the range
WriteLine ( " Please enter the minimum number: " );
minValue = Convert . ToInt32 ( ReadLine ());
WriteLine ( " Please enter the maximum number: " );
maxValue = Convert . ToInt32 ( ReadLine ());
// Check if min is smaller than max
if (minValue >= maxValue)
WriteLine ( " Oops! The minimum value should be less than the maximum value. Let's re-enter both values. " );
WriteLine ( $" Get ready to generate a random number between { minValue } and { maxValue }... " );
WriteLine ( " Drum roll please... " );
// Generate a random number in the specified range
int randomNumber = Rnd (minValue, maxValue);
WriteLine ( $" Your lucky number is: { randomNumber }! " );
WriteLine ( " How does it feel? Want to try again? " );
public static void Main ()
SplashKit . WriteLine ( " Let's make this more interesting! " );
// Loop until a valid range is provided
while (minValue >= maxValue)
// Get user input for the range
SplashKit . WriteLine ( " Please enter the minimum number: " );
minValue = Convert . ToInt32 ( SplashKit . ReadLine ());
SplashKit . WriteLine ( " Please enter the maximum number: " );
maxValue = Convert . ToInt32 ( SplashKit . ReadLine ());
// Check if min is smaller than max
if (minValue >= maxValue)
SplashKit . WriteLine ( " Oops! The minimum value should be less than the maximum value. Let's re-enter both values. " );
SplashKit . WriteLine ( $" Get ready to generate a random number between { minValue } and { maxValue }... " );
SplashKit . WriteLine ( " Drum roll please... " );
// Generate a random number in the specified range
int randomNumber = SplashKit . Rnd (minValue, maxValue);
SplashKit . WriteLine ( $" Your lucky number is: { randomNumber }! " );
SplashKit . WriteLine ( " How does it feel? Want to try again? " );
write_line ( " Let's make this more interesting! " )
# Loop until a valid range is provided
while (min_value >= max_value):
# Get user input for the range
write_line ( " Please enter the minimum number: " )
min_value = int ( read_line ())
write_line ( " Please enter the maximum number: " )
max_value = int ( read_line ())
# Validate if min is smaller than max
if min_value < max_value:
write_line ( " Oops! The minimum value should be less than the maximum value. Let's re-enter both values. " )
write_line ( f "Get ready to generate a random number between {min_value} and {max_value} ..." )
write_line ( " Drum roll please... " )
# Generate a random number in the specified range
random_number = rnd_range ( min_value , max_value )
write_line ( f "Your lucky number is: {random_number} !" )
write_line ( " How does it feel? Want to try again? " )
Output :
Generates a random number between 0 and 1
Return Type: Float
Signatures:
public static float SplashKit . Rnd ();
Usage: {</>}
See Code Examples Example 1 : Coin Flip
write_line ( " Let's simulate a Coin Flip! " );
write_line ( " Flipping coin ... " );
// Add extra "randomness"
for ( int i = 0 ; i < 100 ; i ++ )
// 50% chance of heads or tails
using static SplashKitSDK . SplashKit;
WriteLine ( " Let's simulate a Coin Flip! " );
WriteLine ( " Flipping coin ... " );
// Add extra "randomness"
for ( int i = 0 ; i < 100 ; i ++ )
// 50% chance of heads or tails
public static void Main ()
SplashKit . WriteLine ( " Let's simulate a Coin Flip! " );
SplashKit . WriteLine ( " Flipping coin ... " );
// Add extra "randomness"
for ( int i = 0 ; i < 100 ; i ++ )
random = SplashKit . Rnd ();
// 50% chance of heads or tails
SplashKit . WriteLine ( " Heads! " );
SplashKit . WriteLine ( " Tails! " );
write_line ( " Let's simulate a Coin Flip! " )
write_line ( " Flipping coin ... " )
# 50% chance of heads or tails
Output :
Example 2 : Magic 8-Ball
// Write a terminal welcome message and instructions
write_line ( " Welcome to the Magic 8-Ball! " );
write_line ( " Ask a question, and let the universe decide your fate... " );
write_line ( " Choose a question by typing the number: " );
write_line ( " 1. Will I have a good week? " );
write_line ( " 2. Is it my lucky day? " );
write_line ( " 3. Should I take that risk? " );
write_line ( " 4. Will I find what I'm looking for? " );
write_line ( " Your choice (1-4): " );
int choice = convert_to_integer ( read_line ());
write_line ( " \n Shaking the Magic 8-Ball... " );
delay ( 2000 ); // Add suspense
// Generate a random float and determine the response
float random_value = rnd ();
write_line ( " The universe whispers... " );
// Less than 0.5 responses
write_line ( " \" Not likely, but keep your head up. \" " );
write_line ( " \" The odds aren't in your favor, but miracles happen. \" " );
write_line ( " \" It's better to wait and see. \" " );
write_line ( " \" Keep searching. It's not your time yet. \" " );
write_line ( " \" Hmm... the universe is confused by your question. \" " );
// Greater than or equal to 0.5 responses
write_line ( " \" Yes! This week is yours to conquer. \" " );
write_line ( " \" Absolutely, luck is on your side! \" " );
write_line ( " \" Go for it! Fortune favors the bold. \" " );
write_line ( " \" Yes, you'll find it sooner than you think. \" " );
write_line ( " \" Hmm... the universe is confused by your question. \" " );
write_line ( " \n The Magic 8-Ball has spoken. Have a great day! " );
using static SplashKitSDK . SplashKit;
// Write a terminal welcome message and instructions
WriteLine ( " Welcome to the Magic 8-Ball! " );
WriteLine ( " Ask a question, and let the universe decide your fate... " );
WriteLine ( " Choose a question by typing the number: " );
WriteLine ( " 1. Will I have a good week? " );
WriteLine ( " 2. Is it my lucky day? " );
WriteLine ( " 3. Should I take that risk? " );
WriteLine ( " 4. Will I find what I'm looking for? " );
WriteLine ( " Your choice (1-4): " );
int choice = ConvertToInteger ( ReadLine ());
WriteLine ( " \n Shaking the Magic 8-Ball... " );
Delay ( 2000 ); // Add suspense
// Generate a random float and determine the response
float randomValue = Rnd ();
WriteLine ( " The universe whispers... " );
// Less than 0.5 responses
WriteLine ( " \" Not likely, but keep your head up. \" " );
WriteLine ( " \" The odds aren't in your favor, but miracles happen. \" " );
WriteLine ( " \" It's better to wait and see. \" " );
WriteLine ( " \" Keep searching. It's not your time yet. \" " );
WriteLine ( " \" Hmm... the universe is confused by your question. \" " );
// Greater than or equal to 0.5 responses
WriteLine ( " \" Yes! This week is yours to conquer. \" " );
WriteLine ( " \" Absolutely, luck is on your side! \" " );
WriteLine ( " \" Go for it! Fortune favors the bold. \" " );
WriteLine ( " \" Yes, you'll find it sooner than you think. \" " );
WriteLine ( " \" Hmm... the universe is confused by your question. \" " );
WriteLine ( " \n The Magic 8-Ball has spoken. Have a great day! " );
public static void Main ()
// Write a terminal welcome message and instructions
SplashKit . WriteLine ( " Welcome to the Magic 8-Ball! " );
SplashKit . WriteLine ( " Ask a question, and let the universe decide your fate... " );
SplashKit . WriteLine ( " Choose a question by typing the number: " );
SplashKit . WriteLine ( " 1. Will I have a good week? " );
SplashKit . WriteLine ( " 2. Is it my lucky day? " );
SplashKit . WriteLine ( " 3. Should I take that risk? " );
SplashKit . WriteLine ( " 4. Will I find what I'm looking for? " );
SplashKit . WriteLine ( " Your choice (1-4): " );
int choice = SplashKit . ConvertToInteger ( SplashKit . ReadLine ());
SplashKit . WriteLine ( " \n Shaking the Magic 8-Ball... " );
SplashKit . Delay ( 2000 ); // Add suspense
// Generate a random float and determine the response
float randomValue = SplashKit . Rnd ();
SplashKit . WriteLine ( " The universe whispers... " );
// Less than 0.5 responses
SplashKit . WriteLine ( " \" Not likely, but keep your head up. \" " );
SplashKit . WriteLine ( " \" The odds aren't in your favor, but miracles happen. \" " );
SplashKit . WriteLine ( " \" It's better to wait and see. \" " );
SplashKit . WriteLine ( " \" Keep searching. It's not your time yet. \" " );
SplashKit . WriteLine ( " \" Hmm... the universe is confused by your question. \" " );
// Greater than or equal to 0.5 responses
SplashKit . WriteLine ( " \" Yes! This week is yours to conquer. \" " );
SplashKit . WriteLine ( " \" Absolutely, luck is on your side! \" " );
SplashKit . WriteLine ( " \" Go for it! Fortune favors the bold. \" " );
SplashKit . WriteLine ( " \" Yes, you'll find it sooner than you think. \" " );
SplashKit . WriteLine ( " \" Hmm... the universe is confused by your question. \" " );
SplashKit . WriteLine ( " \n The Magic 8-Ball has spoken. Have a great day! " );
# Write a terminal welcome message and instructions
write_line ( " Welcome to the Magic 8-Ball! " )
write_line ( " Ask a question, and let the universe decide your fate... " )
write_line ( " Choose a question by typing the number: " )
write_line ( " 1. Will I have a good week? " )
write_line ( " 2. Is it my lucky day? " )
write_line ( " 3. Should I take that risk? " )
write_line ( " 4. Will I find what I'm looking for? " )
write_line ( " Your choice (1-4): " )
choice = int ( read_line ())
write_line ( " \n Shaking the Magic 8-Ball... " )
delay ( 2000 ) # Add suspense
# Generate a random float and determine the response
write_line ( " The universe whispers... " )
# Less than 0.5 responses
write_line ( " \" Not likely, but keep your head up. \" " )
write_line ( " \" The odds aren't in your favor, but miracles happen. \" " )
write_line ( " \" It's better to wait and see. \" " )
write_line ( " \" Keep searching. It's not your time yet. \" " )
write_line ( " \" Hmm... the universe is confused by your question. \" " )
# Greater than or equal to 0.5 responses
write_line ( " \" Yes! This week is yours to conquer. \" " )
write_line ( " \" Absolutely, luck is on your side! \" " )
write_line ( " \" Go for it! Fortune favors the bold. \" " )
write_line ( " \" Yes, you'll find it sooner than you think. \" " )
write_line ( " \" Hmm... the universe is confused by your question. \" " )
write_line ( " \n The Magic 8-Ball has spoken. Have a great day! " )
Output :
Generates a random number between 0 and ubound
.
Parameters:
Name Type Description ubound Integer
the Integer
representing the upper bound.
Return Type: Integer
Signatures:
public static int SplashKit . Rnd ( int ubound);
function Rnd (ubound: Integer ): Integer
Usage: {</>}
See Code Examples Example 1 : Random Number Generator
write_line ( " Get ready to generate a random number up to 1000... " );
write_line ( " Drum roll please... " );
delay ( 2000 ); // Delay for 2 seconds
// Generate a random number up to the ubound
int random_number = rnd ( 1000 );
write_line ( " Your lucky number is: " + std:: to_string (random_number) + " !! " );
write_line ( " Feeling lucky? Maybe it's time to play the lottery! " );
using static SplashKitSDK . SplashKit;
WriteLine ( " Get ready to generate a random number up to 1000... " );
WriteLine ( " Drum roll please... " );
Delay ( 2000 ); // Delay for 2 seconds
// Generate a random number up to the ubound
int randomNumber = Rnd ( 1000 );
WriteLine ( $" Your lucky number is: { randomNumber }!! " );
WriteLine ( " Feeling lucky? Maybe it's time to play the lottery! " );
public static void Main ()
SplashKit . WriteLine ( " Get ready to generate a random number up to 1000... " );
SplashKit . WriteLine ( " Drum roll please... " );
SplashKit . Delay ( 2000 ); // Delay for 2 seconds
// Generate a random number up to the ubound
int randomNumber = SplashKit . Rnd ( 1000 );
SplashKit . WriteLine ( $" Your lucky number is: { randomNumber }!! " );
SplashKit . WriteLine ( " Feeling lucky? Maybe it's time to play the lottery! " );
write_line ( " Get ready to generate a random number up to 1000... " )
write_line ( " Drum roll please... " )
delay ( 2000 ) # Delay for 2 seconds
# Generate a random number up to the ubound
random_number = rnd_int ( 1000 )
write_line ( f "Your lucky number is: {random_number} " )
write_line ( " Feeling lucky? Maybe it's time to play the lottery! " )
Output :
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 SplashKit . CurrentTicks ();
function CurrentTicks (): Cardinal
Usage: {</>}
See Code Examples Example 1 : How many ticks?
Note: The ‘tick’ numbers may vary slightly on different machines.
// Get the ticks before delay
unsigned int ticks_before = current_ticks ();
write_line ( " Starting tick capture... " );
write_line ( " Ticks before any delay: " + std:: to_string (ticks_before));
// Delay for 1 second (1000 milliseconds) and capture ticks
unsigned int ticks_after_1s = current_ticks ();
write_line ( " Ticks after 1 second: " + std:: to_string (ticks_after_1s));
// Delay for 2 more seconds (2000 milliseconds) and capture ticks
unsigned int ticks_after_2s = current_ticks ();
write_line ( " Ticks after 2 more seconds (3 seconds total): " + std:: to_string (ticks_after_2s));
// Delay for 4 more seconds (4000 milliseconds) and capture ticks
unsigned int ticks_after_4s = current_ticks ();
write_line ( " Ticks after 4 more seconds (7 seconds total): " + std:: to_string (ticks_after_4s));
// Show the difference in ticks at each capture point
unsigned int diff_1s = ticks_after_1s - ticks_before;
unsigned int diff_2s = ticks_after_2s - ticks_after_1s;
unsigned int diff_4s = ticks_after_4s - ticks_after_2s;
write_line ( " Ticks passed in the first second: " + std:: to_string (diff_1s));
write_line ( " Ticks passed in the next 2 seconds: " + std:: to_string (diff_2s));
write_line ( " Ticks passed in the final 4 seconds: " + std:: to_string (diff_4s));
using static SplashKitSDK . SplashKit;
WriteLine ( " Starting tick capture... " );
// Get the ticks before delay
uint ticksBefore = CurrentTicks ();
WriteLine ( " Ticks before any delay: " + ticksBefore);
// Delay for 1 second (1000 milliseconds) and capture ticks
uint ticksAfter1s = CurrentTicks ();
WriteLine ( " Ticks after 1 second: " + ticksAfter1s);
// Delay for 2 more seconds (2000 milliseconds) and capture ticks
uint ticksAfter2s = CurrentTicks ();
WriteLine ( " Ticks after 2 more seconds (3 seconds total): " + ticksAfter2s);
// Delay for 4 more seconds (4000 milliseconds) and capture ticks
uint ticksAfter4s = CurrentTicks ();
WriteLine ( " Ticks after 4 more seconds (7 seconds total): " + ticksAfter4s);
// Show the difference in ticks at each capture point
uint diff1s = ticksAfter1s - ticksBefore;
uint diff2s = ticksAfter2s - ticksAfter1s;
uint diff4s = ticksAfter4s - ticksAfter2s;
WriteLine ( " Ticks passed in the first second: " + diff1s);
WriteLine ( " Ticks passed in the next 2 seconds: " + diff2s);
WriteLine ( " Ticks passed in the final 4 seconds: " + diff4s);
namespace CurrentTicksExample
public static void Main ()
SplashKit . WriteLine ( " Starting tick capture... " );
// Get the ticks before delay
uint ticksBefore = SplashKit . CurrentTicks ();
SplashKit . WriteLine ( " Ticks before any delay: " + ticksBefore);
// Delay for 1 second (1000 milliseconds) and capture ticks
uint ticksAfter1s = SplashKit . CurrentTicks ();
SplashKit . WriteLine ( " Ticks after 1 second: " + ticksAfter1s);
// Delay for 2 more seconds (2000 milliseconds) and capture ticks
uint ticksAfter2s = SplashKit . CurrentTicks ();
SplashKit . WriteLine ( " Ticks after 2 more seconds (3 seconds total): " + ticksAfter2s);
// Delay for 4 more seconds (4000 milliseconds) and capture ticks
uint ticksAfter4s = SplashKit . CurrentTicks ();
SplashKit . WriteLine ( " Ticks after 4 more seconds (7 seconds total): " + ticksAfter4s);
// Show the difference in ticks at each capture point
uint diff1s = ticksAfter1s - ticksBefore;
uint diff2s = ticksAfter2s - ticksAfter1s;
uint diff4s = ticksAfter4s - ticksAfter2s;
SplashKit . WriteLine ( " Ticks passed in the first second: " + diff1s);
SplashKit . WriteLine ( " Ticks passed in the next 2 seconds: " + diff2s);
SplashKit . WriteLine ( " Ticks passed in the final 4 seconds: " + diff4s);
write_line ( " Starting tick capture... " )
# Get the ticks before delay
ticks_before = current_ticks ()
write_line ( f "Ticks before any delay: {ticks_before} " )
# Delay for 1 second (1000 milliseconds) and capture ticks
ticks_after_1s = current_ticks ()
write_line ( f "Ticks after 1 second: {ticks_after_1s} " )
# Delay for 2 more seconds (2000 milliseconds) and capture ticks
ticks_after_2s = current_ticks ()
write_line ( f "Ticks after 2 more seconds (3 seconds total): {ticks_after_2s} " )
# Delay for 4 more seconds (4000 milliseconds) and capture ticks
ticks_after_4s = current_ticks ()
write_line ( f "Ticks after 4 more seconds (7 seconds total): {ticks_after_4s} " )
# Show the difference in ticks at each capture point
diff_1s = ticks_after_1s - ticks_before
diff_2s = ticks_after_2s - ticks_after_1s
diff_4s = ticks_after_4s - ticks_after_2s
write_line ( f "Ticks passed in the first second: {diff_1s} " )
write_line ( f "Ticks passed in the next 2 seconds: {diff_2s} " )
write_line ( f "Ticks passed in the final 4 seconds: {diff_4s} " )
Output :
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 SplashKit . Delay ( int milliseconds);
procedure Delay (milliseconds: Integer )
Usage: {</>}
See Implementations in Guides
See Code Examples Example 1 : Simulating a Conversation
// Write a string to the console with a delay between each character
void write_with_ delay ( const string & text , int delay _time )
write (word); // Output the last word if there’s no trailing space
write_with_ delay ( " Hello there stranger! \n " , 200 );
write_with_ delay ( " Oh, Hi! I didn't see you there. \n " , 200 );
write_with_ delay ( " Wait, did you just whisper that? " , 200 );
write_with_ delay ( " Come on, let's try that again... \n " , 200 );
write_with_ delay ( " HELLO THERE! \n " , 200 );
write_with_ delay ( " Okay, okay... I felt that! " , 200 );
write_with_ delay ( " But can you go even LOUDER? \n " , 200 );
write_with_ delay ( " HELLOOOOOOO! \n " , 200 );
write_with_ delay ( " Wow! That was intense. Let's cool down a bit... " , 200 );
write_with_ delay ( " Why are we even shouting? \n " , 200 );
write_with_ delay ( " Oh well, it's been fun. " , 200 );
write_with_ delay ( " Catch you later! " , 200 );
using static SplashKitSDK . SplashKit;
// Write a string to the console with a delay between each word
static void WriteWith Delay ( string text, int delayTime)
string [] words = text . Split ( ' ' );
foreach ( string word in words)
Write ( "" ); // Output the last word if there’s no trailing space
WriteWith Delay ( " Hello there stranger! \n " , 200 );
WriteWith Delay ( " Oh, Hi! I didn't see you there. \n " , 200 );
WriteWith Delay ( " Wait, did you just whisper that? " , 200 );
WriteWith Delay ( " Come on, let's try that again... \n " , 200 );
WriteWith Delay ( " HELLO THERE! \n " , 200 );
WriteWith Delay ( " Okay, okay... I felt that! " , 200 );
WriteWith Delay ( " But can you go even LOUDER? \n " , 200 );
WriteWith Delay ( " HELLOOOOOOO! \n " , 200 );
WriteWith Delay ( " Wow! That was intense. Let's cool down a bit... " , 200 );
WriteWith Delay ( " Why are we even shouting? \n " , 200 );
WriteWith Delay ( " Oh well, it's been fun. " , 200 );
WriteWith Delay ( " Catch you later! " , 200 );
// Write a string to the console with a delay between each word
public static void WriteWithDelay ( string text, int delayTime)
string [] words = text . Split ( ' ' );
foreach ( string word in words)
SplashKit . Write (word + " " );
SplashKit . Delay (delayTime);
SplashKit . Write ( "" ); // Output the last word if there’s no trailing space
public static void Main ()
WriteWithDelay ( " Hello there stranger! \n " , 200 );
WriteWithDelay ( " Oh, Hi! I didn't see you there. \n " , 200 );
WriteWithDelay ( " Wait, did you just whisper that? " , 200 );
WriteWithDelay ( " Come on, let's try that again... \n " , 200 );
WriteWithDelay ( " HELLO THERE! \n " , 200 );
WriteWithDelay ( " Okay, okay... I felt that! " , 200 );
WriteWithDelay ( " But can you go even LOUDER? \n " , 200 );
WriteWithDelay ( " HELLOOOOOOO! \n " , 200 );
WriteWithDelay ( " Wow! That was intense. Let's cool down a bit... " , 200 );
WriteWithDelay ( " Why are we even shouting? \n " , 200 );
WriteWithDelay ( " Oh well, it's been fun. " , 200 );
WriteWithDelay ( " Catch you later! " , 200 );
# Write a string to the console with a delay between each word
def write_with_ delay ( text , delay _time ) :
write ( "" ) # Output the last word if there’s no trailing space
write_with_ delay ( " Hello there stranger! \n " , 200 )
write_with_ delay ( " Oh, Hi! I didn't see you there. \n " , 200 )
write_with_ delay ( " Wait, did you just whisper that? " , 200 )
write_with_ delay ( " Come on, let's try that again... \n " , 200 )
write_with_ delay ( " HELLO THERE! \n " , 200 )
write_with_ delay ( " Okay, okay... I felt that! " , 200 )
write_with_ delay ( " But can you go even LOUDER? \n " , 200 )
write_with_ delay ( " HELLOOOOOOO! \n " , 200 )
write_with_ delay ( " Wow! That was intense. Let's cool down a bit... " , 200 )
write_with_ delay ( " Why are we even shouting? \n " , 200 )
write_with_ delay ( " Oh well, it's been fun. " , 200 )
write_with_ delay ( " Catch you later! " , 200 )
Output :
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 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 )
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 SplashKit . FileAsString ( string filename, ResourceKind kind);
def file_as_string ( filename , kind ) :
function FileAsString (filename: String ; kind: ResourceKind): String