-
Notifications
You must be signed in to change notification settings - Fork 3
function
mixed *distinct_array(mixed *arr)
mixed[] arr - An array of mixed types.
mixed[] - A new array with distinct elements from the input array.
Returns a new array containing the distinct elements of the input array.
varargs mixed *remove_array_element(mixed *arr, int start, int end)
mixed[] arr - The input array.
int start - The starting index of elements to be removed.
int [end] - The ending index of elements to be removed. Defaults to start if not specified.
mixed[] - A new array with specified elements removed.
Returns a new array containing the elements of the input array from index 0 to start-1, and from end+1 to the end of the input array. If start is greater than end, the new array will contain all the elements of the input array.
mixed *reverse_array(mixed *arr)
mixed[] arr - The input array.
mixed[] - A new array with elements in reverse order.
Returns a new array with the elements of the input array in reverse order.
varargs mixed *splice(mixed *arr, int start, int delete_count, mixed *items_to_add)
mixed[] arr - The array from which elements will be removed and to which new elements may be added.
int start - The zero-based index at which to start changing the array. If negative, it will begin that many elements from the end.
int delete_count - The number of elements to remove from the array, starting from the index specified by start. If delete_count is 0, no elements are removed.
mixed[] [items_to_add] - An array of elements to add to the array at the start index. Can be omitted or passed as null if no elements are to be added.
mixed[] - A new array reflecting the desired modifications.
Modifies the content of an array by removing existing elements and/or adding new elements. Returns a new array with the modifications.
string base64_decode(string source)
string source - The Base64 encoded string to be decoded.
string - The decoded string.
Decodes a given Base64 encoded string.
string base64_encode(mixed source_str)
mixed source_str - The string or buffer to be encoded.
string - The Base64 encoded string.
Encodes a given string or buffer into Base64 format.
int data_del(string file, string key)
string file - The file to modify.
string key - The key to delete.
int - 1 if the key was found and deleted, 0 otherwise.
Deletes the key-value pair from the file.
varargs int data_inc(string file, string key, int inc)
string file - The file to modify.
string key - The key to increment the value for.
int inc - The amount to increment by.
int - The new value after incrementing.
Increments the value associated with the given key in the file by the specified amount. If the key does not exist, it is created with the increment value.
varargs mixed data_value(string file, string key, mixed def)
string file - The file to read from.
string key - The key to search for.
mixed [def] - The default value to return if the key is not found.
mixed - The value associated with the key, or the default value if the key is not found.
Retrieves the value associated with a given key from a file.
varargs void data_write(string file, string key, mixed data...)
string file - The file to write to.
string key - The key to write.
mixed data - The value(s) to write.
Writes a key-value pair to a file. If the key already exists, the value is updated.
string get_long(object ob, int extras: (: 1 :))
object ob - The object to get the long description of.
int [extras=1] - Whether to include extra long descriptions. Defaults to 1 (include extras).
string - The long description of the object, including any extra long descriptions.
Returns the long description of an object, optionally including extra long descriptions.
string get_short(object ob, int extras: (: 1 :))
object ob - The object to get the short description of.
int [extras=1] - Whether to include extra short descriptions. Defaults to 1 (include extras).
string - The short description of the object, including any extra short descriptions.
Returns the short description of an object, optionally including extra short descriptions in parentheses.
int assure_dir(string path)
string path - The path of the directory to ensure.
int - 1 if the directory exists or was created successfully, otherwise 0.
Ensures that a directory exists by creating it and its parent directories if necessary.
string query_directory(object ob)
object ob - The object to query the directory of.
string - The directory path of the object.
Returns the directory of the given object. If no object is provided, it defaults to the previous object.
varargs string cap_significant_words(string str, int title)
string str - The string to capitalize.
int [title=0] - Whether to capitalize the first word as a title.
string - The string with significant words capitalized.
Capitalizes significant words in a string, ignoring certain insignificant words. Optionally capitalizes the first word as a title.
string cap_words(string str)
string str - The string to capitalize.
string - The capitalized string.
Capitalizes the first letter of each word in a string.
string objective(mixed ob)
mixed ob - The object or gender string to convert.
string - The objective pronoun.
Returns the objective pronoun corresponding to the object's gender. Defaults to "it" for non-string or unknown gender.
string possessive(mixed ob)
mixed ob - The object or gender string to convert.
string - The possessive adjective.
Returns the possessive adjective corresponding to the object's gender. Defaults to "its" for non-string or unknown gender.
string possessive_noun(mixed ob)
mixed ob - The object or string to convert to possessive form.
string - The possessive form of the noun.
Returns the possessive form of a noun. If the noun ends with 's', it adds an apostrophe; otherwise, it adds 's.
string possessive_pronoun(mixed ob)
mixed ob - The object or gender string to convert.
string - The possessive pronoun.
Returns the possessive pronoun corresponding to the object's gender. Defaults to "its" for non-string or unknown gender.
string reflexive(mixed ob)
mixed ob - The object or gender string to convert.
string - The reflexive pronoun.
Returns the reflexive pronoun corresponding to the object's gender. Defaults to "itself" for non-string or unknown gender.
string subjective(mixed ob)
mixed ob - The object or gender string to convert.
string - The subjective pronoun.
Returns the subjective pronoun corresponding to the object's gender. Defaults to "it" for non-string or unknown gender.
int cfile_exists(string file)
string file - The base name of the file to check.
int - 1 if the compiled file exists, otherwise 0.
Checks if a compiled file (.c) exists.
int directory_exists(string dirname)
string dirname - The name of the directory to check.
int - 1 if the directory exists, otherwise 0.
Checks if a directory exists.
int file_exists(string file)
string file - The name of the file to check.
int - 1 if the file exists, otherwise 0.
Checks if a file exists.
int ofile_exists(string file)
string file - The base name of the file to check.
int - 1 if the save file exists, otherwise 0.
Checks if a save file exists.
int user_exists(string user)
string user - The username to check.
int - 1 if the user data file exists, otherwise 0.
Checks if a user data file exists.
void assure_file(string file)
string file - The path of the file to ensure.
Given a file, ensures that the directory structure leading to the file exists, creating directories as needed.
string *dir_file(string path)
string path - The path to extract the components from.
string[] - An array containing the directory and file name components.
Given a path, returns an array containing the directory and file name components.
string *explode_file(string file)
string file - The path of the file to read.
string[] - An array of lines from the file.
Reads a file and returns its content as an array of lines, excluding comment lines and empty lines.
string file_owner(string file)
string file - The path of the file to check.
string - The owner of the file, or 0 if not found.
Determines the owner of a file based on its path.
varargs void implode_file(string file, string *lines, int overwrite)
string file - The path of the file to write to.
string[] lines - The array of lines to write.
int [overwrite=0] - Whether to overwrite the existing content. Defaults to 0 (append).
Writes an array of lines to a specified file, optionally overwriting the existing content.
varargs int log_file(string file, string str, mixed arg...)
string file - The name of the log file.
string str - The log message to write.
mixed [arg] - Additional arguments to include in the log message.
int - 1 if the log message was written successfully, otherwise 0.
Writes a log message to a specified log file.
string query_file_name(object ob)
object ob - The object to query the file name of.
string - The name of the file corresponding to the object.
Returns the name of the file corresponding to a given object.
varargs string tail(string path, int line_count)
string path - The path of the file to read.
int [line_count=25] - The number of lines to read from the end of the file. Defaults to 25.
string - The last few lines of the file.
Returns the last few lines of a file, similar to the Unix
tail command.
varargs string temp_file(mixed arg)
mixed arg - The file or object to create a temporary file for.
string - The path to the temporary file.
Generates a temporary file name based on the provided argument.
mixed *assemble_call_back(mixed arg...)
mixed arg - The arguments to assemble into a callback.
mixed[] - The assembled callback.
Assembles a callback function from the provided arguments. This function is used to create a callable structure that can be invoked later. The callback can be either a method on an object or a function. The assembled callback is returned as an array. Usage:
- When you need to create a callback for an object method:
assemble_call_back(object, "method", args...) - When you need to create a callback for a function:
assemble_call_back(function, args...)The function performs the following steps:
- Checks if the provided arguments form a valid array.
- Determines the size of the arguments array.
- Checks if the first argument is an object. If so, it verifies that the second argument is a valid method name on the object.
- If the first argument is a function, it creates a callback with the function and any additional arguments.
- Returns the assembled callback as an array.
mixed call_back(mixed cb, mixed new_arg...)
mixed cb - The callback to execute.
mixed new_arg - The arguments to pass to the callback.
mixed - The result of the callback execution.
Executes a callback with the given arguments.
varargs string call_trace(int colour)
int [colour=0] - Whether to include ANSI colour codes. Defaults to 0 (no colour).
string - The formatted call stack trace.
Returns a formatted string of the current call stack trace.
int valid_function(mixed f)
mixed f - The function to check.
int - 1 if the function is valid, otherwise 0.
Checks if a given function is valid and not owned by a destructed object.