Introduction
Nex is a versatile language designed to simplify coding for a variety of applications. Below will show you how to use the language to its fullest.
Syntax
// Define a variable
set x = 10
Examples
// Basic Hello World In 2 Ways
start nex main {
helloWorld // run the script
}
start nex helloWorld {
say "Hello, world!" // Say Hello, world!
}
// OR
start nex main {
helloWorld // Run the script
}
start nex helloWorld {
set string = "Hello, world!" // set the string
say "${string}" // Say the string
}
Standard Functions
List of Nex standard functions:
Basic Output Functions
say ""- Outputs text to the console.start nex nexName- Creates a new nex with a specified name.start nex main- This is where you put all of your nexes, as they execute here.
Variable Functions
set anyName = whateveryouwant- Same as const in JavaScript.read file 'filename.fileextension' as anyVariable- Allows you to get the full content of any file into a variable.
Network Functions
fetch "jsonurl" as anyVariable- Allows you to get any part of a JSON URL.
Utility Functions
List of Nex utility functions:
Date and Time Functions
now()- Gets the current time in ISO.currentTime()- Gets the current time in DD/MM/YYYY MM:HH.
Math Functions
random(min, max)- Generates a random number within the specified range.average(...args)- Averages any number of numbers.round(number, placeValue)- Rounds any number to the specified place value.factorial(num)- Gets the factorial of the specified number.clamp(num, min, max)- Clamps a specified number into the specified range.isEven(number)- Checks if the specified number is even.isOdd(number)- Checks if the specified number is odd.
String Functions
toUpper(string)- Turns the entire string upper-case.toLower(string)- Turns the entire string lower-case.truncate(string, length)- Truncates a string to a specified length.capitalize(string)- Capitalizes a specified string.reverse(string)- Reverses a string.isPalindrome(string)- Checks if a string is a palindrome.stringIncludes(string, substring)- Checks if the specified string has a specified substring.
Color Functions
hexToRgb(hex)- Converts a hex color to RGB.rgbToHex(rgb)- Converts RGB to hex.randomColor()- Generates a random color in RGB.
File Functions
fileSize(path)- Finds the file size of the specified file.getFileExtension(path)- Gets the extension of a specified file.
Miscellaneous Functions
newUuid()- Generates a randomized UUID.isValidEmail(email)- Checks if the specified email is valid.numberWithCommas(num)- Adds commas to numbers.getRandomElement(string)- Gets a random character from a string.
Packages
Packages can be installed by simply running the installer and entering the name of the desired package. To create a package, follow these steps:
Creating a Package
- Create a folder within
nex_packageswith your desired folder name. - Create
main.nexandPACKAGEINFOfiles within that folder. - Define the nexes you want within your
main.nexfile. - Fill out the
PACKAGEINFOfile with the following structure:
packageinfo: {
name: 'packagename';
description: 'packagedescription';
author: 'yournameoralias';
}
FAQ
Find answers to common questions about Nex.