Nyl Builtin Functions

This document provides a comprehensive reference for all builtin functions and modules available in the Nyl language.

Global Functions

Function: @dump

  • Signature: fn @dump(bool asJson) any?
  • Description: Dumps the current VM state (locals and globals) for debugging. Returns JSON if requested.

Example:

nyl
@dump() // Visual dump
json = @dump(true) // JSON dump

Function: @eval

  • Signature: fn @eval(string script, bool isolated) any?
  • Description: Asynchronously evaluates a string as Nyl code. Returns a NylTask that can be awaited or canceled.

Example:

nyl
t = @eval("os.sleep(100); return 1 + 2")
res = await t // 3

Function: @getUILocalLanguage

  • Signature: fn @getUILocalLanguage() string
  • Description: Gets the current UI/Messages localization language.

Example:

nyl
lang = @getUILocalLanguage()

Function: @listEmbedded

  • Signature: fn @listEmbedded() list
  • Description: Lists all available embedded resources.

Example:

nyl
resources = @listEmbedded()

Function: @loadEmbedded

  • Signature: fn @loadEmbedded(string path, bool asText) any?
  • Description: Loads an embedded resource as a string.

Example:

nyl
content = @loadEmbedded("resource_name")

Function: @printBrand

  • Signature: fn @printBrand() void
  • Description: Prints the Nyl brand/version information to the console.

Example:

nyl
@printBrand()

Function: @setUILocalLanguage

  • Signature: fn @setUILocalLanguage(string culture) bool
  • Description: Sets the localization language for UI/Messages.

Example:

nyl
@setUILocalLanguage("pt-BR")

Function: add

  • Signature: fn add(map obj, string name, any value) bool

Function: compareVersions

  • Signature: fn compareVersions(string targetSemVerToCompare, string currentSemVer) number
  • Description: Compares two semantic versions. Returns 0 if equal, 1 if target is newer, -1 if older.

Function: concatStr

  • Signature: fn concatStr(list values) string
  • Description: Concatenates a list of values into a single string.

Function: contains

  • Signature: fn contains(string str, string value, bool caseSenitive) bool
  • Description: Checks if a string contains another substring.

Function: countdownTimeStr

  • Signature: fn countdownTimeStr(datetime initDate) string
  • Description: Calculates the time remaining until a target date.

Function: createDate

  • Signature: fn createDate(number year, number month, number day, number hour, number minute, number second) datetime
  • Description: Creates a new DateTime object.

Function: cutStr

  • Signature: fn cutStr(string str, number counter, bool withEllipsis) string
  • Description: Abbreviates a long string with ellipses.

Function: endsWith

  • Signature: fn endsWith(string str, string value, bool caseSenitive) bool
  • Description: Checks if a string ends with the specified value.

Function: endWithAnyStr

  • Signature: fn endWithAnyStr(string str, list values) bool
  • Description: Checks if a string ends with any of the values in a list.

Function: filter

  • Signature: fn filter(list array, fn predicate) []any
  • Description: Filters an array using a predicate callback

Example:

nyl
numbers = [1, 2, 3, 4, 5]
even = filter(numbers, fn(x) => x % 2 == 0)
println(even) // [2, 4]

Function: findWithRegex

  • Signature: fn findWithRegex(string input, string pattern) list
  • Description: Finds all occurrences of a regex pattern and returns matched groups.

Function: fingerPrintId

  • Signature: fn fingerPrintId(bool includeProcessId) (string fullhash, string shorthash)
  • Description: Generates a unique fingerprint ID for the machine based on hardware and system information.

Example:

nyl
fingerPrintId()
// >[
//    "69c040757cf148367bbfe5046ec4453fa5691f817788b3251ec69e7e9584f057", // fullhash
//    "79c540757cf74836" // shorthash
//  ]
fingerPrintId().shorthash // or fingerPrintId()[0]
// > "79c540757cf74836"

Function: fnExists

  • Signature: fn fnExists(string fnName) bool
  • Description: Checks if a function with the specified name exists in the global scope.

Example:

nyl
if fnExists("myFunc") {
    myFunc()
}

Function: formatFileLength

  • Signature: fn formatFileLength(string str) string
  • Description: Formats a byte count into a human-readable file size (KB, MB, GB...).

Function: formatStr

  • Signature: fn formatStr(string str, list values) string
  • Description: Formats a string using placeholder substitution.

Function: formatTime

  • Signature: fn formatTime(number value, bool isSeconds, bool ignoreEmptyValues) string
  • Description: Formats a millisecond value into a human-readable duration.

Function: formatToStr

  • Signature: fn formatToStr(any obj, string keyValueDelimiter, bool setNameInCamelCase, string camelCaseDelimiter, bool useNegriteAndItalicToKeyValue) string
  • Description: Formats a complex object (Instance, Map) into a human-readable string.

Function: free

  • Signature: fn free(any value) bool
  • Description: Manually triggers resource disposal or removes an object from memory.

Example:

nyl
obj = os.newTerminal()
free(obj)

Function: freeAll

  • Signature: fn freeAll() bool
  • Description: Clears all non-system globals and triggers a garbage collection.

Example:

nyl
freeAll()

Function: fromBase64

  • Signature: fn fromBase64(string str) string
  • Description: Decodes a Base64 string back to plain text.

Function: genGuidV4

  • Signature: fn genGuidV4(bool onlyNumbers, string? format) string
  • Description: Generates a random GUID (Version 4).

Example:

nyl
id = genGuidV4()

Function: genGuidV7

  • Signature: fn genGuidV7(bool onlyNumbers, string? format) string
  • Description: Generates a time-ordered GUID (Version 7).

Example:

nyl
id = genGuidV7()

Function: genToken

  • Signature: fn genToken() void
  • Description: Generates a security token based on username and passkey inputs.

Example:

nyl
# Interactive command to generate keys
genToken()

Function: getFileMD5Checksum

  • Signature: fn getFileMD5Checksum(string filePath) string
  • Description: Calculates the MD5 checksum of a file.

Example:

nyl
md5 = os.getFileMD5Checksum("app.exe")

Function: getFileSHA1Checksum

  • Signature: fn getFileSHA1Checksum(string filePath) string
  • Description: Calculates the SHA1 checksum of a file.

Example:

nyl
sha1 = os.getFileSHA1Checksum("app.exe")

Function: getFileSHA256Checksum

  • Signature: fn getFileSHA256Checksum(string filePath) string
  • Description: Calculates the SHA256 checksum of a file.

Example:

nyl
sha256 = os.getFileSHA256Checksum("app.exe")

Function: getFileSHA512Checksum

  • Signature: fn getFileSHA512Checksum(string filePath) string
  • Description: Calculates the SHA512 checksum of a file.

Example:

nyl
sha512 = os.getFileSHA512Checksum("app.exe")

Function: getLoggerLocation

  • Signature: fn getLoggerLocation() (string File, string Location)

Function: getTime

  • Signature: fn getTime() datetime
  • Description: Gets the current system local time.

Function: getTimeUtc

  • Signature: fn getTimeUtc() datetime
  • Description: Gets the current UTC time.

Function: getTimeZones

  • Signature: fn getTimeZones() list
  • Description: Returns a list of all available system time zone IDs.

Function: getTimeZoneUtc

  • Signature: fn getTimeZoneUtc(string zoneId) datetime
  • Description: Gets the current time adjusted for a specific time zone.

Function: hashMD5

  • Signature: fn hashMD5(string str) string
  • Description: Generates an MD5 hash of the string.

Function: hashOf

  • Signature: fn hashOf(any value) number
  • Description: Returns a deep hash code for the given value.

Example:

nyl
h = hashOf([1, 2, 3])

Function: hashSHA256

  • Signature: fn hashSHA256(string str) string
  • Description: Generates a SHA256 hash of the string.

Function: indexOf

  • Signature: fn indexOf(string str, string value, bool caseSenitive) number
  • Description: Returns the index of the first occurrence of a substring.

Function: input

  • Signature: fn input(string label, string cursor) any?
  • Description: Reads an input from the console with an optional label and cursor.

Example:

nyl
name = input("Enter your name", ":")
println("Hello {name}!")

Function: isCurrentVersion

  • Signature: fn isCurrentVersion(string targetSemVerToCompare, string currentSemVer) bool
  • Description: Checks if the target version is equal to the current version.

Function: isNextVersion

  • Signature: fn isNextVersion(string nextSemVerToCompare, string currentSemVer) bool
  • Description: Checks if the target version is a newer version than current.

Function: isNilOrEmpty

  • Signature: fn isNilOrEmpty(string? str) bool
  • Description: Checks if a string is null or empty.

Function: isNilOrWhiteSpace

  • Signature: fn isNilOrWhiteSpace(string? value) bool
  • Description: Checks if a string is null, empty, or only whitespace.

Function: isPreviousVersion

  • Signature: fn isPreviousVersion(string previousSemVerToCompare, string currentSemVer) bool
  • Description: Checks if the target version is an older version than current.

Function: isValidUriScheme

  • Signature: fn isValidUriScheme(string str) bool
  • Description: Checks if a string represents a valid URI/URL.

Function: joinstr

  • Signature: fn joinstr(string? separator, any values) string
  • Description: Joins elements of a list or map into a single string using a separator.

Function: len

  • Signature: fn len(any? value) number
  • Description: Returns the length of a string, array, or map.

Example:

nyl
l1 = len("abc") // 3
l2 = len([1, 2]) // 2

Function: logerr

  • Signature: fn logerr(string message, bool printOnConsole) void
  • Description: Logs an error message to the current logger.

Example:

nyl
logerr("An error occurred!")

Function: loggerInfo

  • Signature: fn loggerInfo() map
  • Description: Gets information about the current logger configuration.

Example:

nyl
info = loggerInfo()
println(info.location)

Function: loginfo

  • Signature: fn loginfo(string message, bool printOnConsole) void
  • Description: Logs an information message to the current logger.

Example:

nyl
loginfo("Starting process...")

Function: logwarn

  • Signature: fn logwarn(string message, bool printOnConsole) void
  • Description: Logs a warning message to the current logger.

Example:

nyl
logwarn("Resource usage is high.")

Function: map

  • Signature: fn map(list array, fn callback) []any
  • Description: Maps an array through a callback function and returns a new list

Example:

nyl
numbers = [1, 2, 3, 4]
doubled = map(numbers, fn(x) => x * 2)
println(doubled) // [2, 4, 6, 8]

Function: nameOf

  • Signature: fn nameOf(any value) string
  • Description: Returns the name of a variable, function, or type.

Example:

nyl
x = 10
println(nameOf(x)) // "x"

Function: openLogger

  • Signature: fn openLogger() void
  • Description: Opens the current log folder in the file explorer.

Example:

nyl
openLogger()

Function: parse

  • Signature: fn parse(any targetType, any value) any?
  • Description: Parses a value to a specified target type.

Example:

nyl
val = parse("int", "123")

Function: pause

  • Signature: fn pause(bool returnKey) any?
  • Description: Pauses execution until a key is pressed. Optionally returns the key pressed.

Example:

nyl
println("Press any key to continue...")
pause()

Function: pid

  • Signature: fn pid(Process process) number
  • Description: Returns the Process ID (PID) of the given Process object.

Example:

nyl
id = proc.pid()

Function: pKill

  • Signature: fn pKill(Process process, bool killChilds) void
  • Description: Kills the given Process object.

Example:

nyl
proc.pKill()

Function: pName

  • Signature: fn pName(Process process) string
  • Description: Returns the name of the given Process object.

Example:

nyl
name = proc.pName()

Function: print

  • Signature: fn print(any? input) void
  • Description: Print value to console

Example:

nyl
print("Hello ")
print("World")

Function: println

  • Signature: fn println(any? input) void
  • Description: Print value to console with newline

Example:

nyl
println("Hello World")
println(123)

Function: psTable

  • Signature: fn psTable(list processInfos) void
  • Description: Displays a list of processes in a formatted table on the console.

Example:

nyl
os.getProcesses().psTable()

Function: pWrite

  • Signature: fn pWrite(Process process, string message) void
  • Description: Writes a message to the standard input of the given Process object.

Example:

nyl
proc.pWrite("exit
")

Function: random

  • Signature: fn random(number min, number max) number

Function: randomStr

  • Signature: fn randomStr(string alphalet, number size) string
  • Description: Generates a cryptographically strong random string.

Function: repeat

  • Signature: fn repeat(number count, fn callback) void
  • Description: Repeats a callback function N times

Example:

nyl
repeat(3, fn(i) {
    println("Iteration: {i}")
})

Function: replace

  • Signature: fn replace(string? str, string oldStr, string newStr) string
  • Description: Replaces all occurrences of a substring with another.

Function: replaceWithRegex

  • Signature: fn replaceWithRegex(string input, string pattern, map replacements) string
  • Description: Replaces substrings matching a regex pattern using a replacement map.

Function: reverse

  • Signature: fn reverse(string str) string
  • Description: Reverses the characters in a string.

Function: setLoggerLocation

  • Signature: fn setLoggerLocation(string locationInAppdataPath, string fileNameExt) void

Function: split

  • Signature: fn split(string? str, string separator) []string
  • Description: Splits a string into an array of substrings based on a separator.

Function: startsWith

  • Signature: fn startsWith(string str, string value, bool caseSenitive) bool
  • Description: Checks if a string starts with the specified value.

Function: startTime

  • Signature: fn startTime() Stopwatch
  • Description: Starts a high-precision stopwatch.

Function: startWithAnyStr

  • Signature: fn startWithAnyStr(string str, list values) bool
  • Description: Checks if a string starts with any of the values in a list.

Function: stopTime

  • Signature: fn stopTime(Stopwatch sw, bool inSeconds, bool formatted) string
  • Description: Stops the stopwatch and returns the elapsed time.

Function: substr

  • Signature: fn substr(string? str, number startIndex, number length) string
  • Description: Returns a part of the string (substring).

Function: toBase64

  • Signature: fn toBase64(string str) string
  • Description: Encodes a string into Base64.

Function: toBytes

  • Signature: fn toBytes(string str) []byte
  • Description: Encodes a string into a byte array.

Function: toCamelCase

  • Signature: fn toCamelCase(string str, string delimiter) string
  • Description: Converts a delimited string into CamelCase.

Function: toLower

  • Signature: fn toLower(string? str) string
  • Description: Converts the string to lowercase.

Function: toStr

  • Signature: fn toStr(any bytes, bool removeTrailingNilChars) string
  • Description: Decodes a byte array or list of bytes into a string.

Function: toString

  • Signature: fn toString(any value, string? formatter) string
  • Description: Converts a value to its string representation with optional formatting.

Function: toUpper

  • Signature: fn toUpper(string? str) string
  • Description: Converts the string to uppercase.

Function: trim

  • Signature: fn trim(string? str) string
  • Description: Removes leading and trailing whitespace.

Function: typeOf

  • Signature: fn typeOf(any value) string
  • Description: Returns the type name of the given value.

Example:

nyl
println(typeOf(123)) // "int"
println(typeOf("abc")) // "string"

Modules

Module: array

Function: array.clear

  • Signature: fn clear(list list) void
  • Description: Clear all items from ArrayList

Function: array.indexOf

  • Signature: fn indexOf(list list, any item, bool caseSensitive) number
  • Description: Get index of item in ArrayList

Function: array.insert

  • Signature: fn insert(list list, number index, any value) list
  • Description: Insert item at specific index in ArrayList

Function: array.join

  • Signature: fn join(list arrayList, string separator) string
  • Description: Join ArrayList items into a string with separator

Function: array.len

  • Signature: fn len(list list) number
  • Description: Get length of ArrayList

Function: array.pop

  • Signature: fn pop(list list) any?
  • Description: Remove last of ArrayList

Function: array.push

  • Signature: fn push(list list, any value) list
  • Description: Add new item to ArrayList

Function: array.remove

  • Signature: fn remove(list list, any item, bool caseSensitive) bool
  • Description: Remove item from ArrayList

Function: array.removeAt

  • Signature: fn removeAt(list list, number index) any?
  • Description: Remove item at specific index in ArrayList

Function: array.reverse

  • Signature: fn reverse(list arrayList) list
  • Description: Reverse the ArrayList

Function: array.sort

  • Signature: fn sort(list arrayList) list
  • Description: Sort the ArrayList in ascending order

Function: array.sortDescending

  • Signature: fn sortDescending(list arrayList) list
  • Description: Sort the ArrayList in descending order

Module: auth

Function: auth.addOrUpdateUser

  • Signature: fn addOrUpdateUser(NylServer server, string username, string passwordOrToken, string role, bool isToken) bool
  • Description: Add or update a user in the auth store

Function: auth.addUser

  • Signature: fn addUser(NylServer server, string username, string passwordOrToken, string role, bool isToken, bool forceReplace) bool
  • Description: Register a user in the auth store

Function: auth.approve

  • Signature: fn approve(NylServer server, map credentials, string redirectUrl) NylTuple
  • Description: Validate credentials and generate session token

Function: auth.deny

  • Signature: fn deny(string message) NylTuple
  • Description: Return auth failure JSON

Function: auth.removeUser

  • Signature: fn removeUser(NylServer server, string username) bool
  • Description: Remove a user from the auth store

Function: auth.updateUser

  • Signature: fn updateUser(NylServer server, string username, string passwordOrToken, string? role, bool isToken) bool
  • Description: Update an existing user's credentials

Module: byte

Function: byte.parse

  • Signature: fn parse(any value) any?
  • Description: Parses a value to a byte (0-255).

Example:

nyl
b = byte.parse("255")

Module: datetime

Function: datetime.parse

  • Signature: fn parse(any value) any?
  • Description: Parses a string to a DateTime object.

Example:

nyl
dt = datetime.parse("2026-04-10")

Module: decimal

Function: decimal.parse

  • Signature: fn parse(any value) any?
  • Description: Parses a string to a high-precision decimal number.

Example:

nyl
d = decimal.parse("123.456789")

Module: float

Function: float.parse

  • Signature: fn parse(any value) any?
  • Description: Parses a string to a floating-point number.

Example:

nyl
n = number.parse("123.45")

Module: html

Function: html.a

  • Signature: fn a(string href) HtmlNode
  • Description: Creates an <a> (link) element.

Function: html.addClass

  • Signature: fn addClass(HtmlNode htmlNode, string className) HtmlNode
  • Description: Adds a CSS class to an HTML element.

Function: html.addClasses

  • Signature: fn addClasses(HtmlNode htmlNode, []string classNames) HtmlNode
  • Description: Adds multiple CSS classes to an HTML element.

Function: html.append

  • Signature: fn append(HtmlNode htmlNode, HtmlNode child) HtmlNode
  • Description: Appends a child element to an existing HTML element.

Function: html.appendText

  • Signature: fn appendText(HtmlNode htmlNode, string text) HtmlNode
  • Description: Appends raw text to an HTML element.

Function: html.body

  • Signature: fn body() HtmlNode
  • Description: Creates a <body> element.

Function: html.button

  • Signature: fn button(string id, string title, string onClickFunction) HtmlNode
  • Description: Creates a <button> element.

Function: html.create

  • Signature: fn create(bool forceWhiteBackground) HtmlNode
  • Description: Creates a specialized HTML element with optional attributes and body.

Function: html.createElement

  • Signature: fn createElement(string tagName, bool isVoidTag) HtmlNode
  • Description: Creates a generic HTML element by tag name.

Function: html.cssAttr

  • Signature: fn cssAttr(HtmlNode htmlNode, string name, string value) HtmlNode
  • Description: Applies a CSS property/style to an HTML element.

Function: html.customElement

  • Signature: fn customElement(string tagName) HtmlNode
  • Description: Creates a custom HTML element (e.g. <app></app>).

Function: html.div

  • Signature: fn div() HtmlNode
  • Description: Creates a <div> element.

Function: html.form

  • Signature: fn form() HtmlNode
  • Description: Creates a <form> element.

Function: html.h1

  • Signature: fn h1(string text) HtmlNode
  • Description: Creates an <h1> element.

Function: html.h2

  • Signature: fn h2(string text) HtmlNode
  • Description: Creates an <h2> element.

Function: html.h3

  • Signature: fn h3(string text) HtmlNode
  • Description: Creates an <h3> element.

Function: html.head

  • Signature: fn head() HtmlNode
  • Description: Creates a <head> element.

Function: html.img

  • Signature: fn img(string src, string alt) HtmlNode
  • Description: Creates an <img> element.

Function: html.input

  • Signature: fn input(string type, string name, string value) HtmlNode
  • Description: Creates an <input> element.

Function: html.label

  • Signature: fn label(string text) HtmlNode
  • Description: Creates a <label> element.

Function: html.li

  • Signature: fn li(string text) HtmlNode
  • Description: Creates a <li> (list item) element.

  • Signature: fn link(string href) HtmlNode
  • Description: Creates a <link> element.

Function: html.meta

  • Signature: fn meta(string charset) HtmlNode
  • Description: Creates a <meta> element.

Function: html.p

  • Signature: fn p(string text) HtmlNode
  • Description: Creates a <p> (paragraph) element.

Function: html.script

  • Signature: fn script(string src, string content) HtmlNode
  • Description: Creates a <script> element.

Function: html.setAttr

  • Signature: fn setAttr(HtmlNode htmlNode, string name, string value) HtmlNode
  • Description: Sets an attribute (e.g. id, class, src) on an HTML element.

Function: html.span

  • Signature: fn span() HtmlNode
  • Description: Creates a <span> element.

Function: html.style

  • Signature: fn style() HtmlNode
  • Description: Creates a <style> element.

Function: html.title

  • Signature: fn title(string text) HtmlNode
  • Description: Creates a <title> element.

Function: html.ul

  • Signature: fn ul() HtmlNode
  • Description: Creates a <ul> (unordered list) element.

Module: int

Function: int.parse

  • Signature: fn parse(any value) any?
  • Description: Parses a string or number to an integer.

Example:

nyl
i = int.parse("123")

Module: json

Function: json.atomicParse

  • Signature: fn atomicParse(string json) any
  • Description: Fast, atomic parsing of a JSON string.

Function: json.isValid

  • Signature: fn isValid(string strInput) bool
  • Description: Checks if a string is a valid JSON document.

Function: json.parse

  • Signature: fn parse(string json, any? targetType) any
  • Description: Parses a JSON string into a Nyl object (map or array).

Example:

nyl
obj = json.parse('{"a": 1}')

Function: json.stringify

  • Signature: fn stringify(any obj) string
  • Description: Serializes a Nyl value into a JSON string.

Example:

nyl
json = json.stringify([1, 2, "three"])

Module: kv

Function: kv.clear

  • Signature: fn clear(KeyValueDB keyValueDB) void
  • Description: Removes all entries from the database.

Function: kv.create

  • Signature: fn create(string filePath, string? password) KeyValueDB
  • Description: Opens or creates a persistent Key-Value database.

Function: kv.createDrop

  • Signature: fn createDrop(string filePath, string? password) KeyValueDB
  • Description: Creates a new Key-Value database, overwriting any existing one.

Function: kv.get

  • Signature: fn get(KeyValueDB keyValueDB, string key) any?
  • Description: Retrieves a value by its key from the database.

Function: kv.remove

  • Signature: fn remove(KeyValueDB keyValueDB, string key) void
  • Description: Removes a key and its value from the database.

Function: kv.set

  • Signature: fn set(KeyValueDB keyValueDB, string key, any value) void
  • Description: Stores a value associated with a key in the database.

Function: kv.show

  • Signature: fn show(KeyValueDB keyValueDB, string? filterByKey) void
  • Description: Displays the database contents in a formatted table.

Function: kv.showInExplorer

  • Signature: fn showInExplorer(KeyValueDB keyValueDB) void
  • Description: Opens the database file location in the file explorer.

Module: long

Function: long.parse

  • Signature: fn parse(any value) any?
  • Description: Parses a string or number to a long integer.

Example:

nyl
l = long.parse("1234567890")

Module: math

Function: math.abs

  • Signature: fn abs(number value) number
  • Description: Returns the absolute value of a number.

Example:

nyl
v = math.abs(-5) // 5

Function: math.acos

  • Signature: fn acos(number value) number
  • Description: Returns the angle whose cosine is the specified number.

Example:

nyl
v = math.acos(1) // 0

Function: math.asin

  • Signature: fn asin(number value) number
  • Description: Returns the angle whose sine is the specified number.

Example:

nyl
v = math.asin(0) // 0

Function: math.atan

  • Signature: fn atan(number value) number
  • Description: Returns the angle whose tangent is the specified number.

Example:

nyl
v = math.atan(0) // 0

Function: math.ceil

  • Signature: fn ceil(number value) number
  • Description: Returns the smallest integral value that is greater than or equal to the specified number.

Example:

nyl
v = math.ceil(1.2) // 2

Function: math.cos

  • Signature: fn cos(number value) number
  • Description: Returns the cosine of the specified angle.

Example:

nyl
v = math.cos(0) // 1

Function: math.cosh

  • Signature: fn cosh(number value) number
  • Description: Returns the hyperbolic cosine of the specified angle.

Example:

nyl
v = math.cosh(0) // 1

Function: math.exp

  • Signature: fn exp(number value) number
  • Description: Returns e raised to the specified power.

Example:

nyl
v = math.exp(1) // 2.718...

Function: math.floor

  • Signature: fn floor(number value) number
  • Description: Returns the largest integral value that is less than or equal to the specified number.

Example:

nyl
v = math.floor(1.8) // 1

Function: math.log

  • Signature: fn log(number value) number
  • Description: Returns the natural (base e) logarithm of a specified number.

Example:

nyl
v = math.log(2.718) // ~1

Function: math.log10

  • Signature: fn log10(number value) number
  • Description: Returns the base 10企 logarithm of a specified number.

Example:

nyl
v = math.log10(100) // 2

Function: math.round

  • Signature: fn round(number value) number
  • Description: Rounds a value to the nearest integer.

Example:

nyl
v = math.round(1.5) // 2

Function: math.sin

  • Signature: fn sin(number value) number
  • Description: Returns the sine of the specified angle.

Example:

nyl
v = math.sin(0) // 0

Function: math.sinh

  • Signature: fn sinh(number value) number
  • Description: Returns the hyperbolic sine of the specified angle.

Example:

nyl
v = math.sinh(0) // 0

Function: math.sqrt

  • Signature: fn sqrt(number value) number
  • Description: Calculate binary square root.

Example:

nyl
v = math.sqrt(16) // 4

Function: math.tan

  • Signature: fn tan(number value) number
  • Description: Returns the tangent of the specified angle.

Example:

nyl
v = math.tan(0) // 0

Function: math.tanh

  • Signature: fn tanh(number value) number
  • Description: Returns the hyperbolic tangent of the specified angle.

Example:

nyl
v = math.tanh(0) // 0

Module: net

Function: net.downloadFile

  • Signature: fn downloadFile(string url, bool silentlyFail, bool printErrOnConsole) []byte
  • Description: Downloads a file from a URL to a local destination.

Example:

nyl
net.downloadFile("https://example.com/image.png", "download.png")

Function: net.downloadFileAsync

  • Signature: fn downloadFileAsync(string url, bool silentlyFail, bool printErrOnConsole) NylTask
  • Description: Downloads a file from a URL asynchronously.

Function: net.downloadFileInChunks

  • Signature: fn downloadFileInChunks(string url, string destPath, number chunkSize, bool silentlyFail) bool
  • Description: Downloads a file in chunks for better memory management.

Function: net.downloadString

  • Signature: fn downloadString(string url, bool silentlyFail, bool printErrOnConsole) string?
  • Description: Downloads the content of a URL as a string.

Function: net.downloadStringAsync

  • Signature: fn downloadStringAsync(string url, bool silentlyFail, bool printErrOnConsole) NylTask
  • Description: Downloads content from a URL as a string asynchronously.

Function: net.getExternalIP

  • Signature: fn getExternalIP() string
  • Description: Retrieves the public IP address of the current machine.

Example:

nyl
ip = net.getExternalIP()

Function: net.getExternalIPAsync

  • Signature: fn getExternalIPAsync() NylTask
  • Description: Retrieves the public IP address asynchronously.

Function: net.getHostInfoJson

  • Signature: fn getHostInfoJson() string
  • Description: Retrieves geographic and technical info about the current IP in JSON format.

Example:

nyl
info = net.getHostInfoJson()

Function: net.getHostInfoJsonAsync

  • Signature: fn getHostInfoJsonAsync() NylTask
  • Description: Retrieves host info JSON asynchronously.

Function: net.getLocalDns

  • Signature: fn getLocalDns() string?
  • Description: Returns the primary DNS server address of the machine.

Function: net.getLocalIP

  • Signature: fn getLocalIP(bool returnDns) string
  • Description: Returns the local IP address (IPv4) of the machine.

Example:

nyl
ip = net.getLocalIP()

Function: net.getRealMacAddress

  • Signature: fn getRealMacAddress() string
  • Description: Returns the physical (MAC) address of the primary active network interface.

Function: net.httpDelete

  • Signature: fn httpDelete(string url, any? headers) HttpResult?
  • Description: Sends a HTTP DELETE request.

Function: net.httpDeleteAsync

  • Signature: fn httpDeleteAsync(string url, any? headers) NylTask
  • Description: Sends a HTTP DELETE request asynchronously.

Function: net.httpGet

  • Signature: fn httpGet(string url, any? headers) HttpResult?
  • Description: Sends a HTTP GET request and returns the response as a string.

Example:

nyl
content = net.httpGet("https://api.example.com/data")

Function: net.httpGetAsync

  • Signature: fn httpGetAsync(string url, any? headers) NylTask
  • Description: Sends a HTTP GET request asynchronously.

Function: net.httpPatchJson

  • Signature: fn httpPatchJson(string url, any data, any? headers) HttpResult?
  • Description: Sends a HTTP PATCH request with a JSON payload.

Function: net.httpPatchJsonAsync

  • Signature: fn httpPatchJsonAsync(string url, any data, any? headers) NylTask
  • Description: Sends a HTTP PATCH request with JSON payload asynchronously.

Function: net.httpPostForm

  • Signature: fn httpPostForm(string url, any data, any? headers) HttpResult?
  • Description: Sends a HTTP POST request with form-encoded data.

Function: net.httpPostFormAsync

  • Signature: fn httpPostFormAsync(string url, any data, any? headers) NylTask
  • Description: Sends a HTTP POST request with form data asynchronously.

Function: net.httpPostJson

  • Signature: fn httpPostJson(string url, any data, any? headers) HttpResult?
  • Description: Sends a HTTP POST request with a JSON payload.

Example:

nyl
resp = net.httpPostJson("https://api.example.com", '{"id": 123}')

Function: net.httpPostJsonAsync

  • Signature: fn httpPostJsonAsync(string url, any data, any? headers) NylTask
  • Description: Sends a HTTP POST request with JSON payload asynchronously.

Function: net.httpPutJson

  • Signature: fn httpPutJson(string url, any data, any? headers) HttpResult?
  • Description: Sends a HTTP PUT request with a JSON payload.

Function: net.httpPutJsonAsync

  • Signature: fn httpPutJsonAsync(string url, any data, any? headers) NylTask
  • Description: Sends a HTTP PUT request with JSON payload asynchronously.

Function: net.isFileDownloadable

  • Signature: fn isFileDownloadable(string url) bool
  • Description: Checks if a URL points to a downloadable resource by checking headers.

Function: net.isWebSocketActive

  • Signature: fn isWebSocketActive(string serverUrl) bool

Function: net.portInUse

  • Signature: fn portInUse(number port, bool silentlyFail) bool
  • Description: Checks if a specific TCP port is currently in use.

Function: net.uploadFile

  • Signature: fn uploadFile(string url, []byte fileData, bool silentlyFail) bool

Function: net.validUrl

  • Signature: fn validUrl(string url) bool
  • Description: Checks if a string is a valid, well-formed URL.

Module: number

Function: number.parse

  • Signature: fn parse(any value) any?
  • Description: Parses a string to a floating-point number.

Example:

nyl
n = number.parse("123.45")

Module: nylweb

Function: nylweb.createClient

  • Signature: fn createClient(string uri, bool reconnect) NylClient
  • Description: Create NylClient Instance

Function: nylweb.createServer

  • Signature: fn createServer(number port, bool useStaticFile, string basePath, string uri) NylServer
  • Description: Create NylServer Instance
  • Signature: fn createServer(number port, string uri) NylServer
  • Description: Create NylServer with static file serving

Module: os

Module: os.windows

Function: os.windows.createTaskScheduler
  • Signature: fn createTaskScheduler(string actionPath, string? actionArguments, string appDirectory, string taskDescription, number delaySec, number intervalSec, bool onlyCreateIfNotExists, string? Author) datetime?
  • Description: Creates a scheduled task in Windows to run a specific action.

Example:

nyl
os.windows.createTaskScheduler("C:/App/run.exe", "--start", "C:/App", "My Daily Task", 0, 1440)

Function: os.windows.elevatePrivilege
  • Signature: fn elevatePrivilege(string? processName, string? args) bool
  • Description: Attempts to elevate process privileges to Administrator. Restarts the app if needed.

Example:

nyl
os.windows.elevatePrivilege()

Function: os.windows.getBiosInfo
  • Signature: fn getBiosInfo() string
  • Description: Returns combined information about the system BIOS.

Example:

nyl
bios = os.windows.getBiosInfo()

Function: os.windows.getClipboardText
  • Signature: fn getClipboardText() string?
  • Description: Retrieves text from the Windows clipboard.

Example:

nyl
text = os.windows.getClipboardText()

Function: os.windows.getGpuName
  • Signature: fn getGpuName() string
  • Description: Retrieves the name and driver version of the primary GPU/Video Controller.

Example:

nyl
gpu = os.windows.getGpuName()

Function: os.windows.getGpuNameByRegistry
  • Signature: fn getGpuNameByRegistry() string
  • Description: Retrieves the GPU name directly from the Windows Registry.

Example:

nyl
gpu_reg = os.windows.getGpuNameByRegistry()

Function: os.windows.getManufacturer
  • Signature: fn getManufacturer() []string
  • Description: Returns the system manufacturer and model.

Example:

nyl
info = os.windows.getManufacturer() // [Manufacturer, Model]

Function: os.windows.getMotherboardFromRegistry
  • Signature: fn getMotherboardFromRegistry() string
  • Description: Retrieves motherboard information from the Windows registry.

Example:

nyl
board_reg = os.windows.getMotherboardFromRegistry()

Function: os.windows.getMotherboardInfo
  • Signature: fn getMotherboardInfo() string
  • Description: Returns combined information about the motherboard (BaseBoard).

Example:

nyl
board = os.windows.getMotherboardInfo()

Function: os.windows.getProcessorFromRegistry
  • Signature: fn getProcessorFromRegistry() string
  • Description: Retrieves the CPU name directly from the Windows registry.

Example:

nyl
cpu_reg = os.windows.getProcessorFromRegistry()

Function: os.windows.getProcessorName
  • Signature: fn getProcessorName() string
  • Description: Returns the official marketing name of the CPU.

Example:

nyl
cpu = os.windows.getProcessorName()

Function: os.windows.getRegistryValue
  • Signature: fn getRegistryValue(string hive, string subKey, string valueName) any?
  • Description: Gets a value from the Windows Registry.

Example:

nyl
val = os.windows.getRegistryValue("HKEY_LOCAL_MACHINE", "SOFTWARE/...", "Value")

Function: os.windows.getScreenshotsBase64
  • Signature: fn getScreenshotsBase64() []string
  • Description: Captures screenshots of all connected monitors as Base64 encoded PNG strings.

Example:

nyl
images = os.windows.getScreenshotsBase64()

Function: os.windows.getScreenshotsBytes
  • Signature: fn getScreenshotsBytes() [][]byte
  • Description: Captures screenshots of all connected monitors as raw byte arrays (PNG).

Example:

nyl
raw_images = os.windows.getScreenshotsBytes()

Function: os.windows.getSystemErrorStr
  • Signature: fn getSystemErrorStr(number codeError) string
  • Description: Converts a Windows system error code into a human-readable message.

Example:

nyl
msg = os.windows.getSystemErrorStr(5) // "Access is denied"

Function: os.windows.getWindowsFromRegistry
  • Signature: fn getWindowsFromRegistry() string
  • Description: Retrieves the Windows version branding directly from the registry.

Example:

nyl
win_reg = os.windows.getWindowsFromRegistry()

Function: os.windows.getWindowsName
  • Signature: fn getWindowsName() string
  • Description: Returns a descriptive name of the Windows version (e.g. Windows 11 Enterprise).

Example:

nyl
win_name = os.windows.getWindowsName()

Function: os.windows.isAdmin
  • Signature: fn isAdmin() bool
  • Description: Checks if the current process is running with Administrator privileges.

Example:

nyl
if os.windows.isAdmin() { ... }

Function: os.windows.isProcessDPIAware
  • Signature: fn isProcessDPIAware() bool
  • Description: Checks if the current process is DPI-aware on Windows.

Example:

nyl
isAware = os.windows.isProcessDPIAware()

Function: os.windows.isSystemLocked
  • Signature: fn isSystemLocked() bool
  • Description: Checks if the Windows desktop is currently locked.

Example:

nyl
isLocked = os.windows.isSystemLocked()

Function: os.windows.isVirtualGPU
  • Signature: fn isVirtualGPU() bool
  • Description: Checks if the primary video controller indicates a virtualized GPU (e.g., Hyper-V, Remote Desktop).

Example:

nyl
if os.windows.isVirtualGPU() { println("Using Virtual GPU") }

Function: os.windows.isVirtualMachine
  • Signature: fn isVirtualMachine() bool
  • Description: Checks if the operating system is running inside a Virtual Machine.

Example:

nyl
if os.windows.isVirtualMachine() { println("Running in VM") }

Function: os.windows.isVirtualManufacturer
  • Signature: fn isVirtualManufacturer() bool
  • Description: Checks if the hardware manufacturer indicates a virtual environment.

Example:

nyl
is_virt = os.windows.isVirtualManufacturer()

Function: os.windows.msgBox
  • Signature: fn msgBox(string text, string caption) void
  • Description: Displays a standard Windows message box with an OK button.

Example:

nyl
os.windows.msgBox("Operation successful", "Info")

Function: os.windows.msgBoxErr
  • Signature: fn msgBoxErr(string text, string caption) void
  • Description: Displays a standard Windows error message box with an icon.

Example:

nyl
os.windows.msgBoxErr("Something went wrong!", "Critical Error")

Function: os.windows.programFilesPath
  • Signature: fn programFilesPath() string
  • Description: Returns the Program Files path.

Function: os.windows.programFilesX86Path
  • Signature: fn programFilesX86Path() string
  • Description: Returns the Program Files (x86) path.

Function: os.windows.resourceInfo
  • Signature: fn resourceInfo(string filename) void
  • Description: Prints metadata and manifest information from a Windows PE file (exe/dll).

Example:

nyl
os.windows.resourceInfo("target.exe")

Function: os.windows.setClipboardText
  • Signature: fn setClipboardText(string text) bool
  • Description: Copies text to the Windows clipboard.

Example:

nyl
os.windows.setClipboardText("Hello from Nyl!")

Function: os.windows.setRegistryValue
  • Signature: fn setRegistryValue(string hive, string subKey, string valueName, any value) any?
  • Description: Sets a value in the Windows Registry.

Example:

nyl
os.windows.setRegistryValue("HKEY_CURRENT_USER", "SOFTWARE/MyNylApp", "Config", 1)

Function: os.appDataPath

  • Signature: fn appDataPath() string
  • Description: Returns the Roaming Application Data path.

Example:

nyl
path = os.appDataPath()

Function: os.arch

  • Signature: fn arch() string
  • Description: Get OS Architecture string

Example:

nyl
arch = os.arch() // "X64"

Function: os.convertImageToPngBase64

  • Signature: fn convertImageToPngBase64(string path) string?
  • Description: Converts an image file to a Base64-encoded PNG string.

Example:

nyl
base64 = os.convertImageToPngBase64("path/to/image.jpg")

Function: os.copyFile

  • Signature: fn copyFile(string source, string dest, bool overwrite) void
  • Description: Copies an existing file to a new file.

Example:

nyl
os.copyFile("src.txt", "dest.txt", true)

Function: os.createDir

  • Signature: fn createDir(string path, string? atrib) bool
  • Description: Creates all directories and subdirectories in the specified path unless they already exist.

Example:

nyl
os.createDir("C:/NewFolder")

Function: os.createMutex

  • Signature: fn createMutex(string mutexName) bool
  • Description: Create a System Mutex

Example:

nyl
isNew = os.createMutex("MyUniqueApp")

Function: os.currentDir

  • Signature: fn currentDir() string
  • Description: Gets the current functional directory of the application.

Example:

nyl
dir = os.currentDir()

Function: os.deleteAllFilesOfPath

  • Signature: fn deleteAllFilesOfPath(string folderPath, bool allDirectories) bool
  • Description: Deletes all files in the specified path.

Example:

nyl
os.deleteAllFilesOfPath("C:/Temp/Cache", true)

Function: os.dirExists

  • Signature: fn dirExists(string path) bool
  • Description: Determines whether the given path refers to an existing directory on disk.

Example:

nyl
if os.dirExists("C:/Windows") { ... }

Function: os.exec

  • Signature: fn exec(string name, string? args, string? verb, string? workingDirectory) string
  • Description: Executes a process and returns its standard output as a string.

Example:

nyl
output = os.exec("git", "--version")

Function: os.exitCode

  • Signature: fn exitCode(Process process) number

Function: os.fileDelete

  • Signature: fn fileDelete(string path) bool
  • Description: Deletes the specified file.

Example:

nyl
os.fileDelete("old_file.txt")

Function: os.fileExists

  • Signature: fn fileExists(string path) bool
  • Description: Checks if a file exists.

Example:

nyl
if os.fileExists("config.json") { ... }

Function: os.fileReadBytes

  • Signature: fn fileReadBytes(string path, number bufferSize) []byte
  • Description: Reads the entire content of a file into a byte array.

Example:

nyl
data = os.fileReadBytes("image.png")

Function: os.fileReadText

  • Signature: fn fileReadText(string path, number bufferSize) string
  • Description: Reads the entire content of a file into a string.

Example:

nyl
text = os.fileReadText("notes.txt")

Function: os.fileWriteBytes

  • Signature: fn fileWriteBytes(string path, []byte data, number bufferSize) bool
  • Description: Writes a byte array to a file, creating or overwriting it.

Example:

nyl
os.fileWriteBytes("output.bin", data)

Function: os.fileWriteText

  • Signature: fn fileWriteText(string path, string contents, bool append, number bufferSize) bool
  • Description: Writes a string to a file. Supports appending.

Example:

nyl
os.fileWriteText("log.txt", "new log entry\n", true)

Function: os.findFilesInFolder

  • Signature: fn findFilesInFolder(string folderPath, string searchPattern, bool allDirectories, []string subFilter) []string
  • Description: Finds all files in a folder matching a search pattern.

Example:

nyl
files = os.findFilesInFolder("C:/Docs", "*.txt", true)

Function: os.findFilesInFolderWithFilter

  • Signature: fn findFilesInFolderWithFilter(string folderPath, list? subFilter) []string
  • Description: Finds all files in a folder applying a substring filter to the full path.

Example:

nyl
files = os.findFilesInFolderWithFilter("C:/Docs", [".txt", ".pdf"])

Function: os.getAvailableDiskFreeSpace

  • Signature: fn getAvailableDiskFreeSpace() string
  • Description: Returns the available free space on the system's primary disk drive as a formatted string.

Example:

nyl
free = os.getAvailableDiskFreeSpace()

Function: os.getAvailableMemory

  • Signature: fn getAvailableMemory(bool format) ulong | string
  • Description: Get Available Physical Memory

Example:

nyl
avail = os.getAvailableMemory()

Function: os.getCompiledDotnetVersion

  • Signature: fn getCompiledDotnetVersion() string
  • Description: Get .NET Framework Description

Example:

nyl
ver = os.getCompiledDotnetVersion()

Function: os.getCurrentProcessName

  • Signature: fn getCurrentProcessName() string
  • Description: Returns the name of the current running process.

Example:

nyl
name = os.getCurrentProcessName()

Function: os.getDir

  • Signature: fn getDir(string file) string?
  • Description: Returns the directory information for the specified path string.

Example:

nyl
dir = os.getDir("C:/Docs/file.txt") // "C:/Docs"

Function: os.getDisksInfoAsJson

  • Signature: fn getDisksInfoAsJson() string
  • Description: Returns information about all ready drives in the system as a JSON string.

Example:

nyl
json = os.getDisksInfoAsJson()

Function: os.getDiskTotalSize

  • Signature: fn getDiskTotalSize() string
  • Description: Returns the total size of the system's primary disk drive as a formatted string.

Example:

nyl
total = os.getDiskTotalSize()

Function: os.getEnvVar

  • Signature: fn getEnvVar(string varName, string variableTarget) string
  • Description: Gets the value of an environment variable.

Example:

nyl
path = os.getEnvVar("PATH")

Function: os.getFileName

  • Signature: fn getFileName(string pathfile) string
  • Description: Returns the file name and extension of a path string.

Example:

nyl
name = os.getFileName("C:/Docs/file.txt") // "file.txt"

Function: os.getMachineName

  • Signature: fn getMachineName() string
  • Description: Get Machine Name

Example:

nyl
host = os.getMachineName()

Function: os.getProcessArch

  • Signature: fn getProcessArch() string
  • Description: Get Process Arch string (X64 or X86)

Example:

nyl
arch = os.getProcessArch()

Function: os.getProcessByName

  • Signature: fn getProcessByName(string processName) Process?
  • Description: Retrieves a Process object by its name.

Example:

nyl
proc = os.getProcessByName("nyl")

Function: os.getProcessByPid

  • Signature: fn getProcessByPid(number pid) ProcessInfo?
  • Description: Retrieves information about a process using its Process ID (PID).

Example:

nyl
pinfo = os.getProcessByPid(1234)

Function: os.getProcessDir

  • Signature: fn getProcessDir() string
  • Description: Returns the directory path of the current process executable.

Example:

nyl
dir = os.getProcessDir()

Function: os.getProcesses

  • Signature: fn getProcesses() list
  • Description: Returns a list of all currently running processes with basic info.

Example:

nyl
procs = os.getProcesses()

Function: os.getProcessorCount

  • Signature: fn getProcessorCount() number
  • Description: Get number of processors/cores

Example:

nyl
cores = os.getProcessorCount()

Function: os.getProcessProductName

  • Signature: fn getProcessProductName(string filterByProcNameModule, string? processName) string
  • Description: Retrieves the ProductName metadata from a running process or its modules.

Example:

nyl
name = os.getProcessProductName("nyl")

Function: os.getProcessProductVersion

  • Signature: fn getProcessProductVersion(string filterByProcNameModule, string? processName) string
  • Description: Retrieves the ProductVersion metadata from a running process or its modules.

Example:

nyl
ver = os.getProcessProductVersion("nyl")

Function: os.getTotalMemory

  • Signature: fn getTotalMemory(bool format) ulong | string
  • Description: Get Total Physical Memory

Example:

nyl
total = os.getTotalMemory()

Function: os.getUptime

  • Signature: fn getUptime(bool isFormatted) any
  • Description: Get System Uptime

Example:

nyl
uptime = os.getUptime() // e.g. "05:30:15"

Function: os.hasFileWritePermission

  • Signature: fn hasFileWritePermission(string filePath) bool
  • Description: Checks if the current process has write permission for the file.

Example:

nyl
canWrite = os.hasFileWritePermission("data.db")

Function: os.is64bitOS

  • Signature: fn is64bitOS() bool
  • Description: Check if OS is 64-bit

Example:

nyl
if os.is64bitOS() { println("64-bit OS") }

Function: os.is64bitProcess

  • Signature: fn is64bitProcess() bool
  • Description: Check if Current Process is 64-bit

Example:

nyl
if os.is64bitProcess() { println("64-bit Process") }

Function: os.isAndroid

  • Signature: fn isAndroid() bool
  • Description: Check if OS is Android

Example:

nyl
if os.isAndroid() { println("Running on Android") }

Function: os.isBrowser

  • Signature: fn isBrowser() bool
  • Description: Check if OS is Browser (WASM)

Example:

nyl
if os.isBrowser() { println("Running in Browser") }

Function: os.isLinux

  • Signature: fn isLinux() bool
  • Description: Check if OS is Linux

Example:

nyl
if os.isLinux() { println("Running on Linux") }

Function: os.isMacos

  • Signature: fn isMacos() bool
  • Description: Check if OS is MacOS

Example:

nyl
if os.isMacos() { println("Running on MacOS") }

Function: os.isSmallDisk

  • Signature: fn isSmallDisk() bool
  • Description: Checks if the primary disk total size is less than or equal to 70GB.

Example:

nyl
if os.isSmallDisk() { println("Small disk detected") }

Function: os.isWindows

  • Signature: fn isWindows() bool
  • Description: Check if OS is Windows

Example:

nyl
if os.isWindows() { println("Running on Windows") }

Function: os.killProcessByName

  • Signature: fn killProcessByName(string processName, bool killChilds) void
  • Description: Finds and kills all processes with the given name.

Example:

nyl
os.killProcessByName("calc")

Function: os.killProcessByPid

  • Signature: fn killProcessByPid(number pid, bool killChilds) void
  • Description: Kills a specific process by its PID.

Example:

nyl
os.killProcessByPid(1234)

Function: os.localAppDataPath

  • Signature: fn localAppDataPath() string
  • Description: Returns the Local Application Data path.

Example:

nyl
path = os.localAppDataPath()

Function: os.moveFile

  • Signature: fn moveFile(string source, string dest, bool overwrite) void
  • Description: Moves an existing file to a new location.

Example:

nyl
os.moveFile("old.txt", "new_location.txt", true)

Function: os.name

  • Signature: fn name() string
  • Description: Get OS Description string

Example:

nyl
name = os.name() // "Windows 11 ..."

Function: os.newProcess

  • Signature: fn newProcess(string processExec, string? args, Value? outputReceived, Value? errorReceived, Value? onExit) Process?
  • Description: Starts a new generic process with async output/error redirection and exit callback.

Example:

nyl
os.newProcess("git", "status", fn(out) => println(out), nil, fn(code) => println("Exited: {code}"))

Function: os.newTerminal

  • Signature: fn newTerminal(string? args, Value? outputReceived, Value? errorReceived) Process?
  • Description: Starts a new interactive terminal process (cmd.exe or bash) with async output redirection.

Example:

nyl
sh = os.newTerminal(nil, fn(out) => println(out))

Function: os.newTerminalPS

  • Signature: fn newTerminalPS(string? args, Value? outputReceived, Value? errorReceived) Process?
  • Description: Starts a new interactive PowerShell terminal process with async output redirection.

Example:

nyl
ps = os.newTerminalPS(nil, fn(out) => println(out))

Function: os.pathCombine

  • Signature: fn pathCombine([]string paths) string
  • Description: Combines multiple strings into a path.

Example:

nyl
path = os.pathCombine("C:", "Users", "Docs")

Function: os.processExists

  • Signature: fn processExists(string processName) bool
  • Description: Checks if a process with the given name is currently running.

Example:

nyl
if os.processExists("chrome") { ... }

Function: os.run

  • Signature: fn run(string name, string? args, bool createNoWindow, string? workingDirectory, string? verb) Process?
  • Description: Runs a process and returns the Process object. Can be configured to run in the background.

Example:

nyl
proc = os.run("notepad.exe", "file.txt")

Function: os.searchTermOurFilesInFolder

  • Signature: fn searchTermOurFilesInFolder(string searchTermInFile, string folderPath, string searchPattern, bool firstOccurrence, bool allDirectories, []string subFilter) []string
  • Description: Search for a term inside files in a folder.

Example:

nyl
matches = os.searchTermOurFilesInFolder("todo", "C:/Project", "*.nyl")

Function: os.searchTermOurFilesInFolderWithFilter

  • Signature: fn searchTermOurFilesInFolderWithFilter(string searchTermInFile, string folderPath, list? subFilter) []string
  • Description: Search for a term inside files in a folder with sub-filter.

Example:

nyl
matches = os.searchTermOurFilesInFolderWithFilter("todo", "C:/Project", [".nyl"])

Function: os.setEnvVar

  • Signature: fn setEnvVar(string varName, string value, string variableTarget) bool
  • Description: Sets the value of an environment variable.

Example:

nyl
os.setEnvVar("MY_VAR", "value")

Function: os.SIMD

  • Signature: fn SIMD() bool
  • Description: Checks SIMD Support

Example:

nyl
if os.SIMD() { println("SIMD enabled") }

Function: os.sleep

  • Signature: fn sleep(number msTimeOut) void
  • Description: Stop Thread by Milliseconds

Example:

nyl
os.sleep(1000) // Sleep for 1 second

Function: os.startProcess

  • Signature: fn startProcess(string fileName, string verb) bool
  • Description: Starts a file using ShellExecute (e.g., opens a document in its default app).

Example:

nyl
os.startProcess("readme.txt")

Function: os.stopWatchProcesses

  • Signature: fn stopWatchProcesses(ProcessMonitorHandle handle) void
  • Description: Stop a process monitor

Function: os.tempFileExtStr

  • Signature: fn tempFileExtStr() string
  • Description: Creates a uniquely named, empty temporary file on disk and returns its path (with extension).

Example:

nyl
file = os.tempFileExtStr()

Function: os.tempFileStr

  • Signature: fn tempFileStr() string
  • Description: Creates a uniquely named, empty temporary file on disk and returns its path (without extension).

Example:

nyl
file = os.tempFileStr()

Function: os.tempPath

  • Signature: fn tempPath() string
  • Description: Returns the path of the current user's temporary folder.

Example:

nyl
tmp = os.tempPath()

Function: os.wait

  • Signature: fn wait(Process process) void

Function: os.watchProcesses

  • Signature: fn watchProcesses(list names, any onStart, any onStop, number intervalMs) ProcessMonitorHandle
  • Description: Monitor process start/stop events by name

Module: ptr

Function: ptr.add

  • Signature: fn add(nint ptr, number offset) nint
  • Description: Adds an offset (in bytes) to a pointer.

Function: ptr.fromInt

  • Signature: fn fromInt(number num) nint
  • Description: Creates a pointer from a 64-bit integer.

Function: ptr.isNil

  • Signature: fn isNil(nint ptr) bool
  • Description: Checks if a pointer is null.

Function: ptr.nil

  • Signature: fn nil() nint
  • Description: Returns a null pointer (IntPtr.Zero).

Function: ptr.sub

  • Signature: fn sub(nint ptr, number offset) nint
  • Description: Subtracts an offset from a pointer.

Function: ptr.toInt

  • Signature: fn toInt(nint ptr) number
  • Description: Converts a pointer to its 64-bit integer representation.

Module: socketClient

Function: socketClient.close

  • Signature: fn close(SocketClient socketClient) bool
  • Description: Closes the current socket connection.

Function: socketClient.connect

  • Signature: fn connect(SocketClient socketClient) bool
  • Description: Attempts to connect to a Socket Server at the specified IP and port.

Function: socketClient.create

  • Signature: fn create(string ipAddress, number port, ProtocolType protocol, bool reconnect) SocketClient?
  • Description: Creates a new Socket Client instance.

Function: socketClient.isReconnExhausted

  • Signature: fn isReconnExhausted(SocketClient socketClient) bool
  • Description: Checks if reconnection attempts have been exhausted.

Function: socketClient.onConnect

  • Signature: fn onConnect(SocketClient client, fn onConnect) bool
  • Description: Sets a callback for when the client connects to a server.

Function: socketClient.onDisconnect

  • Signature: fn onDisconnect(SocketClient socketClient, fn onDisconnect) bool
  • Description: Sets a callback for when the client is disconnected.

Function: socketClient.onMessage

  • Signature: fn onMessage(SocketClient socketClient, fn onMessage) bool
  • Description: Sets a callback for when the client receives a message from the server.

Function: socketClient.retryWithNewIpAddress

  • Signature: fn retryWithNewIpAddress(SocketClient socketClient, string ipAddress, number port) bool
  • Description: Tries to reconnect to the server using a different IP address.

Function: socketClient.sendMessage

  • Signature: fn sendMessage(SocketClient socketClient, string message) bool
  • Description: Sends a message to the connected server.

Module: socketServer

Function: socketServer.clientExists

  • Signature: fn clientExists(SocketServer server, string clientId) bool
  • Description: Checks if a specific client ID is currently connected.

Function: socketServer.create

  • Signature: fn create(string ipAddress, number port, string protocol) SocketServer
  • Description: Creates a new Socket Server instance.

Function: socketServer.getClient

  • Signature: fn getClient(SocketServer server, string clientId) any?
  • Description: Retrieves information about a specific connected client.

Function: socketServer.getClients

  • Signature: fn getClients(SocketServer server) list
  • Description: Returns a list of IDs of all currently connected clients.

Function: socketServer.listen

  • Signature: fn listen(SocketServer server) bool
  • Description: Starts listening for incoming connections on a specific port.

Function: socketServer.onConnectServer

  • Signature: fn onConnectServer(SocketServer server, fn onConnect) SocketServer
  • Description: Sets a callback for when a client connects to the server.

Function: socketServer.onDisconnectServer

  • Signature: fn onDisconnectServer(SocketServer server, fn onDisconnect) SocketServer
  • Description: Sets a callback for when a client disconnects from the server.

Function: socketServer.onMessageServer

  • Signature: fn onMessageServer(SocketServer server, fn onMessage) SocketServer
  • Description: Sets a callback for when the server receives a message from a client.

Function: socketServer.sendMessageServer

  • Signature: fn sendMessageServer(SocketServer server, string clientId, string message) void
  • Description: Sends a message to a specific connected client.

Function: socketServer.stopServer

  • Signature: fn stopServer(SocketServer server) bool
  • Description: Stops the Socket Server and closes all connections.

Module: string

Function: string.parse

  • Signature: fn parse(any value) any?
  • Description: Converts a value to its string representation.

Example:

nyl
s = string.parse(123)

Module: telegram

Function: telegram.botInfo

  • Signature: fn botInfo(TgBotApi? tgBotApi) TgBotResponse?
  • Description: Retrieves information about the bot (getMe).

Function: telegram.botInit

  • Signature: fn botInit(string token, number chatId) TgBotApi?
  • Description: Initializes a Telegram Bot instance with token and default chat ID.

Function: telegram.botNextUpdatesCallback

  • Signature: fn botNextUpdatesCallback(TgBotApi? tgBotApi, any functionCallback, number periodInSecs) void
  • Description: Starts an asynchronous loop to process incoming Telegram messages via callback.

Function: telegram.botNextUpdatesMessage

  • Signature: fn botNextUpdatesMessage(TgBotApi? tgBotApi) string?
  • Description: Retrieves the next pending message from the Telegram updates queue.

Function: telegram.botSendMessage

  • Signature: fn botSendMessage(TgBotApi? tgBotApi, string message) bool
  • Description: Sends a text message via the Telegram bot.

Function: telegram.botUploadFileFromMemory

  • Signature: fn botUploadFileFromMemory(TgBotApi? tgBotApi, []byte bytes, string caption) bool
  • Description: Uploads a file from a byte array to a Telegram chat.

Function: telegram.botUploadFileFromPath

  • Signature: fn botUploadFileFromPath(TgBotApi? tgBotApi, string path, string caption) bool
  • Description: Uploads a file from a local path to a Telegram chat.

Function: telegram.botUploadImageFromMemory

  • Signature: fn botUploadImageFromMemory(TgBotApi? tgBotApi, []byte bytes, string caption) bool
  • Description: Uploads an image from a byte array to a Telegram chat.

Function: telegram.botUploadImageFromPath

  • Signature: fn botUploadImageFromPath(TgBotApi? tgBotApi, string path, string caption) bool
  • Description: Uploads an image from a local path to a Telegram chat.

Module: template

Function: template.render

  • Signature: fn render(string html, any? data, bool indent) string?
  • Description: Renders an HTML template string by replacing placeholders with data from a Nyl object (map, type instance, or list).

Example:

nyl
type User { string name, int age, bool active }
page = { "title": "My Page", "users": [User("Alice", 25, true), User("Bob", 30, false)] }
html = "<h1>{{title}}</h1><ul nyl-for="user in users"><li>{{user.name}} ({{user.age}})</li></ul>"
rendered = template.render(html, page)
  • Signature: fn render(string htmlPage, string htmlPart, any? data, bool indent) string?
  • Description: Renders an HTML layout page with a partial body template. The layout uses @body to mark where the partial content is inserted.

Example:

nyl
layout = "<html><body>@body</body></html>"
partial = "<h1>{{title}}</h1>"
data = { "title": "Hello" }
rendered = template.renderLayout(layout, partial, data)

Module: web3

Function: web3.stopWatchContract

  • Signature: fn stopWatchContract(Web3MonitorHandle handle) void

Function: web3.watchContract

  • Signature: fn watchContract(string contractAddress, string keyTag, any onChange, any onIncompatible, string currentVersion, bool autoEval, number intervalSecs, string? realm, string? backupPath, []string networks) Web3MonitorHandle

Module: webview

Function: webview.create

  • Signature: fn create(string source, string title, number width, number height) NylWebViewWindow
  • Description: Creates a high-performance WebView instance for displaying HTML/web content.

Module: zip

Function: zip.compressBytesWithPrefix

  • Signature: fn compressBytesWithPrefix([]byte input, string prefix) []byte
  • Description: Compresses a byte array using GZip and adds a custom prefix (default: $zc).

Example:

nyl
comp = zip.compressBytesWithPrefix("myData".toBytes())

Function: zip.createEntryFromBytes

  • Signature: fn createEntryFromBytes(string entryName, []byte contentBytes, string? password, string? comment) []byte
  • Description: Creates a single-entry ZIP archive in memory from a byte array.

Example:

nyl
zip_data = zip.createEntryFromBytes("file.txt", "content".toBytes())

Function: zip.createEntryFromFolder

  • Signature: fn createEntryFromFolder(string folderPath, string? zipName, string? password, string? comment) []byte
  • Description: Creates a ZIP archive in memory (byte array) from a folder's contents.

Example:

nyl
data = zip.createEntryFromFolder("C:/Configs")

Function: zip.createFromFolder

  • Signature: fn createFromFolder(string folderPath, string? zipNameOrLocation, string? password, string? comment) bool
  • Description: Creates a ZIP archive from the contents of a folder.

Example:

nyl
zip.createFromFolder("C:/Project", "C:/Backups/Project.zip")

Function: zip.decompressBytesWithPrefix

  • Signature: fn decompressBytesWithPrefix([]byte input, string prefix) []byte
  • Description: Decompresses a byte array that was compressed with a specific prefix.

Example:

nyl
raw = zip.decompressBytesWithPrefix(comp)

Function: zip.isCompressedBytesWithPrefix

  • Signature: fn isCompressedBytesWithPrefix([]byte input, string prefix) bool
  • Description: Checks if a byte array starts with the specified compression prefix.

Example:

nyl
if zip.isCompressedBytesWithPrefix(data) { ... }

Function: zip.isFileFromBytes

  • Signature: fn isFileFromBytes([]byte zipFileData) bool
  • Description: Checks if the given byte array represents a valid ZIP archive.

Example:

nyl
if zip.isFileFromBytes(data) { ... }

Function: zip.unzipBytesToFolder

  • Signature: fn unzipBytesToFolder([]byte zipFileData, string destinationPath, string? password) bool
  • Description: Extracts a ZIP archive from memory (byte array) to a destination folder.

Example:

nyl
zip.unzipBytesToFolder(zip_data, "output/")

Function: zip.unzipEntryToBytes

  • Signature: fn unzipEntryToBytes([]byte zipFileData, string? password) []byte
  • Description: Extracts the first entry of a ZIP archive in memory directly into a byte array.

Example:

nyl
raw_data = zip.unzipEntryToBytes(zip_data)

Function: zip.unzipFileToFolder

  • Signature: fn unzipFileToFolder(string zipFilePath, string destinationPath, string? password) bool
  • Description: Extracts all contents of a ZIP file to a destination folder.

Example:

nyl
zip.unzipFileToFolder("data.zip", "extracted/")