Marble Functions

Changes the working directory.
You are required to hold a ChdirPermission to change the working directory

function chdir(string new_directory) : void

@class SQLStatement
Finalizes the query that was provided with setQuery and returns the finalized query as a string.

function finalizeQuery() : string


Returns a part of a string based on the position and total

function substr(string str,number pos,number size) : string

Returns the size of the provided string

function strlen(string str) : number


Returns the position of the needle in the haystack

function strpos(string haystack,string needle,number pos) : number

Splits the desired string and returns an array of strings

function split(string target,string delim) : string[]


Replaces all instances of to_replace from the target with the replace_with string

function str_replace(string target,string to_replace,string replace_with) : string

Matches all occurences in the target based on the regex string provided.
Returns a string array of all the occurences found

function preg_match_all(string target,string regex) : string[]


Trims whitespace from the left and right of the provided string target unless a pattern is provided
If a pattern is provided then the pattern is what is tripped from the string.

function trim(string target,string pattern) : string

Trims whitespace from the left and right of the provided string target unless a pattern is provided
If a pattern is provided then the pattern is what is tripped from the string.

function trim(string target,string pattern) : string


Trims whitespace from the left of the provided string target unless a pattern is provided
If a pattern is provided then the pattern is what is tripped from the string.

function trim(string target,string pattern) : string

Trims whitespace from the left of the provided string target unless a pattern is provided
If a pattern is provided then the pattern is what is tripped from the string.

function ltrim(string target,string pattern) : string


Trims whitespace from the right of the provided string target unless a pattern is provided
If a pattern is provided then the pattern is what is tripped from the string.

function rtrim(string target,string pattern) : string

Trims whitespace from the right of the provided string target unless a pattern is provided
If a pattern is provided then the pattern is what is tripped from the string.

function rtrim(string target,string pattern) : string


Preforms a number format on the given target

function number_format(string target,number places) : string

Returns the given number as a correctly formatted string.
Whole numbers are returned as whole number strings. Doubles may have to be formatted correctly with the number_format function

function number_to_string(number val) : string


Makes the given value string html tag safe. Preventing XSS attacks
str_replace(val, "<", "<");
str_replace(val, ">", ">");

function safe_tags(string val) : string

Converts the given string to upper case and returns it.
Since: V0.2.0

function strtoupper(string val) : string


Converts the given string to lower case and returns it
Since: V0.2.0

function strtolower(string val) : string

This function allows people to load marble modules from within the marble language
The function accepts one argument of type string and this should equal the filename you wish to load
Prototype:
throws PermissionException if interpreter does not have the correct permissions
throws IOException if the module fails to load

function LoadModule(string filename) : void

Returns the current scope's permissions

function getScopePermissions() : Permissions


Returns the current function caller's permissions.
This function should be called when you are implementing your own permissions and want to ensure
the function caller has the permissions required to call your function

function getCallerPermissions() : Permissions


Base64 encodes the given string and returns the encoded result of the given value

function base64_encode(string value) : string

Base64 decodes the given string and returns the decoded result of the given encoded value

function base64_decode(string value) : string

Prints data to the default Marble output stream allowing you to provide information back to your users

function print(string message) : void


Writes one byte to the default Marble output stream allowing you to output one byte back to your users.
Number is converted to byte ((int)b & 0xff);

function write(number b) : void

Reads a line from the default Marble input stream. This works best for applications designed to run in the terminal

function input() : string


Writes a file to the system output such as the web client or terminal what ever is setup
throws an IOException if a problem occurs

function writeFile(string filename) : void

Moves the filename to the destination
E.g
move("./test.txt", "./test2.txt");

function move(string filename,string dst_filename) : void


Returns true if the given path is a file, returns false if it is a directory or an error occured

function isFile(string filename) : boolean


Reads the entire file into memory as a string and returns the file contents.
Important to note that this returns only valid ASCII string data. Please use file_get_binary_contents for binary files

function file_get_contents(string filename) : string

Reads the entire file into memory, returns the file contents as a number array that holds 8 bit characters in each index.
Use this function for reading binary files
Available Since v0.4.0

function file_get_binary_contents(string filename) : number[]


Writes the given string to the file specified by the filename.
If the file does not exist it creates it, if it does exist it overwrites it

function file_put_contents(string filename,string data) : void

Writes the given number array to the file specified by the filename. Each number in your number array
will be treated as a single 8 bit character all other bits of the number are ignored. For example if you have a number with the value 0xffff. Only 0xff will be used
If the file does not exist it creates it, if it does exist it overwrites it
Available Since v0.4.0

function file_put_binary_contents(string filename,number[] data) : void


Changes the mode of the given file

function chmod(string filename,number mode) : string

Hashes the given string with the sha256 algorithm.
Returned is the hashed representation of the given string

function sha256(string input) : string

Hashes the given string with the sha1 algorithm.
Returned is the hashed representation of the given string

function sha1(string input) : string