Variables are one of the building blocks of learning a programming language. All programming languages have them, whether it is a dynamically-typed language or not (which RustlerScript is). Variables allow the programmer to create letter- or word-named items that can be used later in the code.
In RustlerScript, assigning a variable is just like any Videos language; you would type the keyword "var", and then, with a space right after that, the name of your variable. However, RustlerScript limits your variable names to 50 characters, as well as preventing you from using spaces in variable names. In addition, regular variable names have to be typed like this: testVariableOne. You would have to have the first letter of the variable lowercase, and the rest uppercase, a rule in which most languages have.
Prior to RustlerScript 12.0, variables were defined with parantheses and quotes. In RustlerScript 12.1, it is defined with just the universal "var".
Assigning values in RustlerScript is also very much the same as assigning variables in C#, C, Java, and JavaScript. However, Rustler's value policies are a bit stricter than that of Videos languages. In RustlerScript, you are limited to only have a numercial value, an object value, and a string literal.
Integers are also one of the msot common types of objects in all programming languages. However, RustlerScript has its own unique ways of describing them, unlike any Videos programming language.
In RustlerScript, you would normally define an integer by typing "int" (the keyword here) and then assigning it a class followed by an equals sign, and then identifying whether your new integer is an int16, int32, or int64. In addition, you would need to assign a name for your new integer. Right after the "int16, int32, or int64" attribute, you would put a comma, type "name", and then in quotes, the name of the integer. Below is an example of defining a regular integer:
RustlerScript has the same policy for naming an int as a variable: the first letter is lowercase, and anything after that is uppercase, an integer rule that is, once again, in most Videos languages.
RustlerScript allows you to use variables and integers together, meaning that you can have a value of a variable set as an integer name. Below, you can see this theory in action:
RustlerScript can get a little weird when it comes to assigning a new integer as the value of a variable. RustlerScript's ways of doing this have infuriated some programmers over the years after they have been with C#, C, C++, and JavaScript for so many years. This is one downside of RustlerScript.
Functions in RustlerScript have always been very easy to deal with, as it is a dynamically-typed language. Functions in RustlerScript are like functions in any Videos language, except there are some small details that RustlerScript has that is different from Videos languages.
RustlerScript's functions are different from that of Rust. Functions in Rust start with the unusual "fn main()". RustlerScript, however, is not like that. It declares functions with a "function" keyword, and then, after a space, the name of the function goes in parantheses. As always, the first letter of the function is lowercase, and anything following that is uppercase. Finally, on the next line, curly brackets open, as shown below:
In RustlerScript, there are more than one type of function. One is the main function, running the main variables and integers. However, there is a case when you might want to have a function inside a function. This is where sub-functions come in handy.
To define a sub-function, you would start with the regular "function", the name of the function in parantheses, but before the curly brackets, you would first type a comma, and then assign the class attribute. Type an equals sign, and in quotes type "sub-function". Finally, on the next line, open curly brackets. This is demonstrated below:
Like any Videos programming language, RustlerScript includes the capability to create and name strings. Strings in RustlerScript are very much like integers, although they are mainly used for a sentence of text.
In RustlerScript, a regular string would have a name and content, which could also come many lines later in the code. To define a string, you would type the keyword "string". Next, type a double equals sign, and then the content of the string right after that in quotes. Remember, the first letter is always lowercase, while the rest is uppercase. After the name of the string, you may choose to write the content of the string (always one sentence, wtih no special characters) or you may choose to write it later. Below is a listing of when the content of the string is addressed immediatley:
A string MUST be defined. Otherwise, the compiler will throw error R29263 and say "string content undefined."
RustlerScript allows you to assign an integer name of a string. This means that you can define a string for the name of an integer (any type will work.) RustlerScript is unique this way, as neither C#, C, C++, or JavaScript allows you to do this. Normally, to do this, you would first define the string and its content before defining the integer. You may not define the content after defining the integer. Below is the code for doing so: