Nougat Documentation
VI - The Standard Library
6.1 The Array Functions
Nougat's API is still at its very infancy. However, these functions are mainly for array operations. It includes functions for manipulating, searching, and reversing arrays.
Array.contains(array, data) |
Description
Checks if an array contains the data parameter passed. Parameters • array — Array object to be checked. • data: object — The data that will be checked if whether it exists on the array. Return Value Returns a boolean value of true if the array contains data parameter value; otherwise, returns false. |
Array.insert(array, data) |
Description
Inserts an item at the end of an array and returns the array. Parameters • array — Array where the item will be appended. • data: object — Data to be inserted to the array parameter. Return Value Returns the array where the item was appended to. |
Array.insertArray(array, index, arrayObj) |
Description
Inserts an entire array at the specified index of an array and returns the array. Parameters • array — Array where the array item will be inserted to. • index: number — The index where the arrayObj will be inserted to. • arrayObj: array — Array object to be written in the array parameter. Return Value Returns the new array that contains the arrayObj parameter inserted to the defined index. |
Array.insertAt(array, index, data) |
Description
Inserts an item at the specified index of an array and returns the array. Parameters • array — Array where the item will be appended. • index: number — The index where the item in the array will be added. Must not be greater than the array size nor a negative number. • data: object — Data to be inserted to the array parameter. Return Value Returns the array where the item was inserted to. |
Array.indexOf(array, data) |
Description
Gets the zero-based index of the first occurence of the data parameter in the array. Parameters • array — Source array where the data parameter will be fetched. • data: object — Data object to locate from the array parameter. Return Value Returns the zero-based first occurence index of the data parameter, if not found or doesn't exists in the array, then -1. |
Array.lastIndexOf(array, data) |
Description
Gets the zero-based index of the last occurence of the data parameter in the array. Parameters • array — Source array where the data parameter will be fetched. • data: object — Data object to locate from the array parameter. Return Value Returns the zero-based last occurence index of the data parameter, if not found or doesn't exists in the array, then -1. |
Array.remove(array, data) |
Description
Removes a specified item from an array and returns the array. Parameters • array — Array where the item will be removed from. • data: object — Data to be removed from the array parameter. Return Value Returns the array where the item was removed from. |
Array.removeAt(array, index) |
Description
Removes an item from the specified index of an array and returns the array. Parameters • array — Array where the item will be removed from. • index: number — The index where the item in the array will be removed. Must not be greater than the array size nor a negative number. Return Value Returns the array where the item was removed from. |
Array.removeRange(array, index, count) |
Description
Removes the items in an array starting from the specified index. The numbers of the item that will be removed is as specified in the count parameter. Parameters • array — Array where the items will be removed from. • index: number — The starting point index where items will be removed. • count: number — Number of items to be removed in the array parameter. Return Value Returns the new array without the removed items, as described from the parameter descriptions. |
Array.reverse(array) |
Description
Reverses the items from an array. Parameters • array — Array object that will be reversed. Return Value Returns the new array with the reversed items. |
Array.reverseRange(array, index, count) |
Description
Reverses the items from specified range, starting from the specified index. Parameters • array — Array where the items will be reversed from. • index: number — The starting point index where items will be reversed. • count: number — Number of items to be reversed starting from the specified index in the array parameter. Return Value Returns the new array with the reversed items. |
Array.size(array) |
Description
Gets the number of items in an array. Parameters • array — Items' array object. Return Value Returns the number of items in an array. |
Array.slice(array, index, count) |
Description
Makes a new copy of items in an array starting point index, with number of items specified in the count parameter. Parameters • array — The array object to be sliced. • index — Zero-based index of the starting point. • count — Number of items to be copied. Return Value Returns the new array containing the copied items starting from index parameter, with number of items specified in the count parameter. |
6.2 The IO Functions
Nougat was never intended to be created with a huge API libraries. The IO (stands for Input/Output) library, however, contains some of important functions for input and output operations within Nougat, such as printing and reading text from the user, reading and writing files, and some utilization functions.
Below is the complete list of the IO functions (all of which are defined at bin\Nougat-API.dll), including its names, descriptions, parameters, and return values.
IO.appendToFile(path, data) |
Description
Appends a certain data to an existing file. Parameters • path: string — File path where the data will be written. • data: object — Data to be appended to the specified file path. Return Value Returns a default nil value. |
IO.backgroundColor(color) |
Description
Changes the background color of the text in the whole console. Check this out for possible console color values. Parameter • color: number — The number value that represents a color to be used as background color of the texts in the whole console. Complete list here. Return Value Returns a default nil value. |
IO.cls() |
Description
Clears all the text/content of the current corresponding console. Return Value Returns a default nil value. |
IO.createDir(path) |
Description
Create a folder to a specific path. Does nothing if the folder path specified already exists. Parameter • path: string — Path of the folder to be created. Return Value Returns a boolean value of true if the folder was successfully created, otherwise false. |
IO.deleteDir(path) |
Description
Deletes a directory/folder including its files and nested directories/folder. Does nothing if the folder path specified was already deleted. Parameter • path: string — Path of the folder to be deleted. Return Value Returns a boolean value of true if the folder was already deleted or was deleted successfully, otherwise false. |
IO.deleteFile(path) |
Description
Deletes the specified file. Does nothing if the file specified was already deleted. Parameter • path: string — Path of the file to be deleted. Return Value Returns a boolean value of true if the file was already deleted or was deleted successfully, otherwise false. |
IO.dirExists(path) |
Description
Checks if the specified folder exists. Parameter • path: string — Path of the folder to be checked if it exists. Return Value Returns a boolean value of true if the directory/folder exists, otherwise false. |
IO.exit(exitCode) |
Description
Terminates the current executed process (mainly the Nougat interpreter), then returns the exitCode value to the operating system. Parameter • exitCode: number — Exit code value, usually 0. Return Value Returns a default nil value. |
IO.fileExists(path) |
Description
Checks if the specified file exists. Parameter • path: string — Path of the file to be checked if it exists. Return Value Returns a boolean value of true if the file exists, otherwise false. |
IO.foregroundColor(color) |
Description
Changes the foreground color of the text in the whole console. Check this out for possible console color values. Parameter • color: number — The number value that represents a color to be used as foreground color of the texts in the whole console. Complete list here. Return Value Returns a default nil value. |
IO.isFile(path) |
Description
Checks if the specified path is a file. Parameter • path: string — The path to be checked if it is a file. Return Value Returns a boolean value of true if the specified path is a file, otherwise false. |
IO.isFolder(path) |
Description
Checks if the specified path is a folder. Parameter • path: string — The path to be checked if it is a folder. Return Value Returns a boolean value of true if the specified path is a folder, otherwise false. |
IO.listDirFiles(path) |
Description
Lists the files and folders inside the specified path. Parameter • path: string — The parent path of the files and folders to be enlisted. Return Value Returns an array value that contains the files and folders/directories inside the specified path. |
IO.print(data) |
Description
Prints a text representation of the data parameter to the standard console output. Parameter • data: object — The data/object to be printed. Return Value Returns the data parameter. |
IO.printLine(data) |
Description
Prints a text representation of the data parameter to the standard console output, and appends a new line at the end. Parameter • data: object — The data/object to be printed. Return Value Returns the data parameter. |
IO.readFromFile(path) |
Description
Reads a text from a specified file path. Parameter • path: string — Path of the file to be read. Return Value Returns the text as string read from the specified file path. |
IO.readKey() |
Description
Gets an input single character from the user via standard console input. Return Value Returns the single character input from the user. |
IO.readLine() |
Description
Let's the user to enter sequences of characters until new line will be encountered, thus, stops in fetching characters and returns the string to the user. Return Value Returns the input from the user as single line string. |
IO.sleep(timeout) |
Description
Suspends the current running thread with a defined timeout interval in millisecond. Parameter • timeout: number — The millisecond timeout interval. Return Value Returns the timeout parameter. |
IO.writeToFile(path, data) |
Description
Writes a certain data to a file. Parameters • path: string — File path where the data will be written. • data: object — Data to be written to the specified file path. Return Value Returns a default nil value. |
6.3 Language Utility Functions
This group of function contains some of the Nougat language utilizations such as object type-identification checking and fetching the Nougat interpreter's informations.
Lang.getType(object) |
Description
Returns a string of object parameter's type. Parameters • object — Object to be checked. Return Value Returns either "string", "number", "function", "array", "map", or "boolean" depending on the value of the object parameter; otherwise, undefined if the object is nil. |
Lang.info() |
Description
Returns a map containing the current Nougat interpreter's informations. Return Value Returns a map containing keys version and author (both are of string type), and a boolean type stable which defines if the compiler is a stable released interpreter. |
Lang.isArray(object) |
Description
Checks object if it contains an object of array type. Parameter • object — Object to be checked. Return Value Returns true if the object parameter contains an array; otherwise false. |
Lang.isFun(object) |
Description
Checks object if it contains an object of function type. Parameter • object — Object to be checked. Return Value Returns true if the object parameter contains a function; otherwise false. |
Lang.isMap(object) |
Description
Checks object if it contains an object of map type. Parameter • object — Object to be checked. Return Value Returns true if the object parameter contains a map; otherwise false. |
Lang.isNumber(object) |
Description
Checks object if it contains an object of number type. Parameter • object — Object to be checked. Return Value Returns true if the object parameter contains a number; otherwise false. |
Lang.isString(object) |
Description
Checks object if it contains an object of string type. Parameter • object — Object to be checked. Return Value Returns true if the object parameter contains a string; otherwise false. |
Lang.tryCatch(tryCallback, catchCallback) |
Description
Performs a virtual try-catch block through callbacks. Parameter • tryCallback: fun — The function that will act as try block. • catchCallback: fun(placeholder) — Callback for catch block that requires a placeholder parameter for thrown object. Return Value Returns nil in default. However, if the try-block or the catch-block returns a value, then the value return from the callback will be returned. |