ReCT Manual v2.3.1

This document is a one-page ReCT documentation you can download and use offline. It contains all existing docs articles.


Introduction to ReCT

This Introduction covers everything you need to get started!
It contains: Installation, Hello World, Setting up a Project

Installation

Depending on which platform youre planing on using ReCT the install process varies slightly. They are all very straight forward though!
You can find some more info on the Download Page


Updating ReCT

You can update ReCT by either using the update functionality of your Package Manager or, if youre using ReCTManager, by running:

ReCTManager.exe update

Setting up a project

The ReCT Compiler has built-in project support. They aren't necessary, but useful for bigger works and keeping them organized.

To make a new project, just open a terminal and type:

rctc create projectName

If you want it to create the project in a new directory just use the "-n" option:

rctc create projectName -n

And finally if you want rctc to generate some vscode task files as well just use the "-v" or "--vscode" option:

rctc create projectName -n --vscode

To run a project just use the "rctc run" command in the projects directory.

rctc run

Compiling without a Project

When coding in ReCT you sometimes dont want to use a project. In that case you can build your program the old fashioned way.
Call the rctc command followed by your source file and the "-s" and "-f" flags. The "-s" flag will auto-reference all standard Dotnet Assemblies, the "-f" flag will evaluate preprocessor statements like "#attach".

rctc ./sourcefile.rct -s -f

You can also set an output file. This is optional and by default it will just choose the source file's name with the ending ".dll".

rctc ./sourcefile.rct -s -f -o ./outputfile.dll

You can find more info on the Compilers help page when doing:

rctc -h

Hello World

"Hello World" is the standard, first thing, you do in every language when starting out.
So let's take a look at how it works in ReCT.

We want to Print something to the Console, so for that we will need the Sys Package.
You can add it by doing:

package sys;

For convenience, you can also Use a package. I am going to do that here:

package sys; use sys;

Now that we have the Package added, we can call the Print Function:

Print("Hello World!");

And there we go! That is our Hello World program! We can spice it up by having our user Type in something, so let's make the program ask for their name and then tell them Hello.
We can get User Input by using the Input Function that is also inside the Sys Package, and store it inside a Variable:

package sys; use sys;

Print("Whats your name?");
var name <- Input();
Print("Hello " + name + "!");


Welcome to ReCT.


Variables

Variables are used to store Values for later use.

You can Initialize a Variable like this:

var variable <- "something";

The Variable made in the example is of Datatype String

If you are not explicitly setting the Datatype, ReCT will figure out itself what Datatype is needed.



You can set the Datatype yourself if you want, by doing:

var <datatype> someVar <- <something>

so in our Example from earlier it would look like this:

var string variable <- "something";

You can also create a Variable without initializing it like this:

var string myStringVariable;

The normal Base Datatypes will just be assigned their default value. Object Variables will be set to null



Global Variables

If you create a Variable with the 'Var' Keyword, it can only be used in the function it was created.

If you want to use it in other functions, you have to use the 'set' Keyword.

So, making a global Variable would look like this:

set variable <- "this is a global var";

(the same Datatype setting applies here too)

Virtual Variables

Virtual Variables are Variables that can be defined in Abstract Classes and can be overwritten in Inheriting Classes. A Variable can be made virtual by using the "virt" keyword. (NOTE: Only public variables are allowed to be virtual)

virt set someVariable <- 0;

You can find more info on overwriting on the Inheriting Classes Docs Article.


Datatypes

Datatypes exist to set the Type of Data you are / want to be working with.


Every Variable has a Datatype, which sets what kind of data it can store.

There are a lot of different Datatypes, for example String for text, or Int for whole numbers.

You can also convert between Datatypes by using aCast.

Any

"Any" just describes an Object.

It can be set to any of the other Datatypes, and can also be converted back to the Original by using a Cast.


When initializing a Variable as any, you will need to specify the Datatype or else it will automatically choose the literals actual type.

var any someObject <- "this is a string in an object var";

Bool

Bool (short for boolean) is the simplest of all Datatypes.

It can only store 2 states, True of False, which are basically "On" or "Off".



Initializing a Variable as a Bool would look like this:

var someVar <- true;

Int

Int (short for Integer) describes a whole number, without decimals.

An Integer can store a number that can reach from -2147483647 to 2147483647.

Initializing a Variable as an int would look like this:

var someInt <- 1;

String


String describes a string of characters.

You can store any kind of text in it.


Initializing a Variable as a string would look like this:

var someString <- "this is a string";

Functions

The string Datatype has 2 built in Functions:


GetLength()

GetLength() returns the String's length as an Int.



Substring(startindex int, length int)

Substring() makes a Subtring from the current String. It will start at the given starting index and go on for the given Length.



Split(splitter string)

Split() will Split the string at any points where the given splitter is at and return a String Array.



Replace(replaceThis string, withThis string)

Replace() will replace all instances of the given string with the replacement and returns a new String instead of altering the existing one.

At(index int)

At() will return the Character at the given position as a single character string.



Float

Float (short for Floating-point Number) describes a number with a decimal point.

One thing to mention is Floating point jitter. It happens with big Float numbers, when there aren't enough Bits left for the part after the Decimal point, making it lose precision.


Initializing a Float Variable would look like this:

var someFloat <- 1.5;

Byte

Byte describes a whole number that takes up 8 bits.

Its very similar to an int but it only ranges from 0 to 255, that also means it takes up less memory.


Initializing a Variable as a byte would look like this:
(Important! Because Int and Byte share the same literal type you will need to explicitely specify that you want the byte Datatype!)

var byte someByte <- 255;

Functions

The byte Datatype has 2 built in Functions:


GetBit(index -> int)

GetBit() returns the bit in the byte at the given position as an Int.



SetBit(index -> int, value -> int)

SetBit() will set the bit in the byte at the given position to the given value.


Array datatypes

Arrays are a datatype which can hold multiple instances of it's base type.

For example, a string Array can hold multiple strings.

The name of an ArrayType is always the base type + 'Arr', so in case of a string array it would be "stringArr".


You can create an Array like this:

var someArray <- make string array(5);

The number in parentheses is setting the Length of the array.


You can also create an Array by using an Array-Literal, like this:

var someArray <- make string array {"this", "is", "an", "array", "literal"};

To access an Array simply put the wanted index in square brackets behind it:

someArray[0]

Functions

The Array Datatypes have 4 built in Functions:


GetLength()

GetLength() returns the Array's length as an Int.



Push(object -> any)

Push() adds the given Object to the end of the Array.



Pop()

Pop() returns the last element of the Array and removes it from the collection.



At(index int)

At() returns the element at the given index. This is just a different form of the classic [] access.




If Statements

If statements are a way to Block off code behind a Condition.

A typical If statement could look something like this:

if (someVar = "a value")
{
    //do something
}


Else Block

You can also add an Else block, that will be run if the Condition doesn't return true.

if (someVar = "a value")
{
    //do something
}
else
{
    //do something else
}

If you want you can also chain another If Statement onto it like this:

if (someVar = "a value")
{
    //do something
}
else if (someVar = "another value")
{
    //do something else
}

Conditions

Conditions are often used in If Statements, or While Loops, but can also be used outside of them.

Valid Operators for conditions are:

=  Equal
!= Not Equal
<  Less than
>  Greater than
<= Less or Equal
>= Greater or Equal

Loops

Loops are a way to iterate a block of code.

ReCT has 3 different types of Loops: a For Loop, a From To Loop, and a While Loop.


An example of a From To Loop could look like this:

from (i <- 0) to 9
{
    //this code will be run 10 times
}

While Loop

The While Loop is the simplest loop of all three.

It works in very similar Ways to an If Statement.

Basically, as long as the Condition is true, the code will be iterated.



An example of a While Loop would look like this:

while (someVar = "some value")
{
    //hmmmm yes much cod
}

From To Loop

From To Loops are a simpler form of a For Loop.

A From To Loop has a Variable, and a Goal.

(the From To Loop uses the Condition "<="!)



A From To Loop could look like this:

from (i <- 0) to 10
{
    //This will be called 11 times
}

For Loops

For Loops in ReCT work basically the same way as they do in C# and Java.

A For Loop always has a Variable, a Condition and an Action.



A For Loop could look like this:

for (var i <- 0; i < 10; i++)
{
    //this will be run 10 times
}

Functions

Functions are a way to block off code and re-use it.

Functions can have Parameters and can also return objects.



Declaring a Function could look like this:

function someFunc() { ... }

To add Parameters, you can just put them inside the parentheses and specify a Datatype:

function someFunc(someParam string, someOtherParam int) { ... }

To specify a return Type, just add a Datatype after the parentheses:

function someFunc() string { ... }

Since ReCT v2.2 the Type-Arrow (->) is no longer required but is still accepted meaning both these ways are valid:

function newWay(someParam string) int { ... } function oldWay(someParam -> string) -> int { ... }

Calling a Function

Calling a Function is pretty easy.

Just write the Function's name and some parentheses after it, and if you have Parameters set you will have to put them in there.

someFunc()
someFuncWithParams("this is an parameter", 123)

Static Functions

When the Class the Function is in is static, the Function will automatically be static as well.

Public Functions

You can make a Function public, by adding the 'set' keyword when declaring it:


set function globalFunction () { ... }

If you want to access a Function from another Class, it needs to be public!

Virtual Functions

Virtual Functions are Functions that can be defined in Abstract Classes and can be overwritten in Inheriting Classes.
A Functions can be made virtual by using the "virt" keyword.

virt function someVirtualFunction() { ... }

You can find more info on overwriting on the Inheriting Classes Docs Article.


System Packages

System Packages are Packages that are built into ReCT.

Some examples of these system Packages are sys and net.

Sys Package

Include this Package with


package sys;

[i] This package includes most of the fundamental things, like Console functions and things like Sleep().


Print(text string)

Print will Write a message out to the Console, and go to the next line.


Write(text string)

Write will Write a message out to the Console and will stay on the same line.


Input()

Will let the user type a line, and return it as a String.


InputKey()

Will let the user type a character and return it as a String.


InputAction()

Will let the user type a character, but without showing it in the console and return it as a String.


Read()

Will read from the raw console standard input stream character by characterand return the char as an int.


Clear()

Clears all text from the Console.


Sleep(milliseconds int)

Will pause the Thread for the given amount of Milliseconds.


Beep(freq int, duration int)

Plays the given Frequency for the given amount of Time, using the Console's beeper.


Char(asciiCode int)

Will return the Character corresponding to the given ASCII code as a String.


Arg(index int)

Will return the commandline argument at the given index as a string. (NOTE: the first argument is always the path of the executable)


Args()

Will return all commandline arguments as a string array.


SetSize(width int, height int)

SetSize will set the Size of the Console window to the given Width and Height. (Please note that the inputs are in Characters, not Pixels)


GetSizeX()

Will get the Width of the Console in Characters and return it as an Int.


GetSizeY()

Will get the Height of the Console in Characters and return it as an Int.


SetCursor(x int, y int)

Sets the Console's Cursor to the given Position.


GetCursorX()

Will get the X coordinate of the Console's Cursor.


GetCursorY()

Will get the Y coordinate of the Console's Cursor.


SetCursorVisible(state bool)

Sets the Console's Cursor visibility.


GetCursorVisible()

Gets the Console's Cursor visibility and returns it as a Bool.


SetConsoleForeground(color int)

Sets the Console's Foreground color.


SetConsoleBackground(color int)

Sets the Console's Background color.


ReCTs Colortable

ReCT has 16 different colors you can use in the Console. Here is an overview of them:


LaunchApplication(path string)

Will launch the application at the given path in a seperate process.


LaunchApplicationWithArgs(path string, args string, waitForEnd bool)

Will launch the application at the given path with the given arguments in a seperate process. If the wait bool is set, the program will be paused until the process finishes.


LaunchApplicationWithOutput(path string, args string)

Will launch the application at the given path with the given arguments in a seperate process and will wait until it is done, after that it returns the processes output as a string.

Math Package

Include this Package with


package math;

[i] This package includes ReCTs math functions.


Random(maxNum -> int)

This function will return a random Int between 0 and the given Number.


RandomRange(minNum -> int, maxNum -> int)

This function will return a random Int in the range being from the first to the second given number.


Floor(num -> float)

This function will round the given Float to Floor and return the result as an Int.


Ceil(num -> float)

This function will round the given Float to Ceil and return the result an Int.


Pi()

This function will return Pi as a Float.


Sqrt(num -> float)

This function will return square root of the given number as a Float.


Pow(a -> float, b -> float)

This function will return the power of a to b as a Float.


Clamp(num -> float, min -> float, max -> float)

This function will Clamp the given number between the min and max value.


Abs(num -> float)

This function will return the ABS of the given number as a Float..


Sin(angleInRadiants -> float)

This function will return the SIN of the given angle as a Float..


Cos(angleInRadiants -> float)

This function will return the COS of the given angle as a Float..


Tan(angleInRadiants -> float)

This function will return the TAN of the given angle as a Float..


ASin(sin -> float)

This function will return the ASIN of the given sin in Radiants as a Float..


ACos(cos -> float)

This function will return the ACOS of the given cos in Radiants as a Float..


ATan(tan -> float)

This function will return the ATAN of the given tan in Radiants as a Float..


SinDeg(angleInDegrees -> float)

This function will return the SIN of the given angle as a Float..


CosDeg(angleInDegrees -> float)

This function will return the COS of the given angle as a Float..


TanDeg(angleInDegrees -> float)

This function will return the TAN of the given angle as a Float..


ASinDeg(sin -> float)

This function will return the ASIN of the given sin in Degrees as a Float..


ACosDeg(cos -> float)

This function will return the ACOS of the given cos in Degrees as a Float..


ATanDeg(tan -> float)

This function will return the ATAN of the given tan in Degrees as a Float..

IO Package

Include this Package with


package io;

[i] This package includes ReCTs IO / Filesystem functions.


FileExists(path -> string)

Will check if the given file exists and returns the result as a Bool.


ReadFile(path -> string)

Will read the whole given file and return it as a String.


WriteFile(path -> string, text -> string)

Will write the given Text to a File. If the file doesn't exis,t it will be created.


DeleteFile(path -> string)

Will delete the given File.


GetFilesInDirectory(path -> string)

Will fetch all File paths in the given Directory and return them as a String Array/


DirectoryExists(path -> string)

Will check if the given Folder exists and return the result as a Bool.


CreateDirectory(path -> string)

Will create the given path's Directory.


DeleteDirectory(path -> string)

Will delete the given Directory.


GetDirsInDirectory(path -> string)

Will fetch all Folder paths in the given Directory and returns them as a String Array.


GetCurrentDirectory()

Will return the current working directory as a String.


ChangeDirectory(path -> string)

Will change the current working directory to the given path.

Net Package

Include this Package with


package net;

[i] This package includes ReCTs TCP Networking functions.


ConnectTCPClient(ip -> string, port -> int)

Tries to Connect to the IP with the given port. When successful, will return a Tcp Client.


ListenOnTCPPort(port -> int)

Will start to listen for Tcp Clients on the given port. When successful, will return a Tcp Listener.


OpenSocket(socket -> TCPSocket)

Will wait for a Client to connect and return a Tcp Socket.


The legacy TCP Datatypes have been deprecated and removed in ReCT v2.2. They are now replaced with new Classes. The old functions still work and will now return the new Classes.



TCP Client

A TCP Client can be created by either using its Constructor or the ConnectTCPClient() function.

var client <- make TCPClient("ip address", <port>);

To read out messages you can either use ReadLine() to read a whole line of text from the InputStream or Read() which will only read and return the next Character from the InputStream.

var line <- client -> ReadLine();
var nextChar <- client -> Read();

To write and send messages you can use the Write() and WriteLine() functions. The only difference between them is that WriteLine() will put a newline after the message.
IMPORTANT: Write() and WriteLine() only write to the SendBuffer but dont actually send the data for that you need to call the Flush() function. If you just want to write a line and send it instantly you can use WriteFlush()

client -> Write("this message will be sent");
client -> WriteLine("together with the one above");
client -> Flush();

client -> WriteFlush("this will be sent on its own, instantly");


TCP Listener

A TCP Listener can be created by either using its Constructor or the ListenOnTCPPort() function.

var listener <- make TCPListener(<port>);

The Listener is just there to open Sockets for clients when they connect. To open a socket and wait for a Client just call OpenSocket(). (The static OpenSocket() will also work)

var socket <- listener -> OpenSocket();

TCP Socket

A TCP Socket can be created by either using the Listeners OpenSocket() function or the static OpenSocket() function.

var socket <- listener -> OpenSocket();

To read out messages you can either use ReadLine() to read a whole line of text from the InputStream or Read() which will only read and return the next Character from the InputStream.

var line <- socket -> ReadLine();
var nextChar <- socket -> Read();

To write and send messages you can use the Write() and WriteLine() functions. The only difference between them is that WriteLine() will put a newline after the message.
IMPORTANT: Write() and WriteLine() only write to the SendBuffer but dont actually send the data for that you need to call the Flush() function. If you just want to write a line and send it instantly you can use WriteFlush()

socket -> Write("this message will be sent");
socket -> WriteLine("together with the one above");
socket -> Flush();

socket -> WriteFlush("this will be sent on its own, instantly");

Web Package

Include this Package with


package web;

[i] This package includes 2 functions and 3 Classes.


WebRequest

The first of the tree Classes, is the WebRequest Class.
It's Constructor only takes one Argument, that being a string setting the Request type. Valid Types are: "POST" and "GET". (There might be more in the future).


Creating a WebRequest, could look like this:


var req <- make WebRequest("POST");

If you are making a POST Request, you can now add your Form fields with the AddField function:


req->AddField("field0", "some data");
req -> AddField("creativeFieldName", "more data");


You are also able to add Headers to your Request:

req->AddHeader("name", "value");

To now send the Request, just call SendRequest. If you are making a GET Request, you can put your data into the URL now.


req->SendRequest("https://bytespace.tk/");

When run, this function will return a...



HttpResponse

The only way of getting an HttpResponse, is by calling the SendRequest function inside the WebRequest class.


var response <- req -> SendRequest("https://bytespace.tk/");

HttpResponse has 4 Fields

response -> Headers //the response headers as stringArr
response -> StatusCode //the http status code of the response
response -> wasSuccessful //a bool saying if the Request was successful or not
response -> Content //the Content sent back from the server as a string


File Up- and Downloading over http

The web package allows you to Upload and Download files over http (and https)

File Uploading could look like this:

web::UploadFile("someURL", "/some/path/to/a/file");

File Downloading could look like this:

web::DownloadFile("a.url.to.a.file", "/a/location/to/save/it/to");


Websocket Client

You can create a Websocket Client by just using its Constructor and passing in a URL.

var wsclient <- make WebSocketClient('ws://some.domain/');

To open the connection just call the Open() function:

wsclient->Open();

To send a message over the Client just use its Send() function:

wsclient->Send("message");

If you want to Receive data from the Client just call its Receive() function. (NOTE: this will pause the Thread until a message is received.)

var answer <- wsclient->Receive();

To close the Client you can call its Cancel() function at any time.

wsclient->Cancel();

Audio Package

Include this Package with


package audio;

[i] This package adds the AudioPlayer Class.


AudioPlayer

The Audio Player's Costructor doesn't take any Arguments.
To Play an Audio file, just call the Player's Play function:


var player <- make AudioPlayer();
player->Play("someAudioFile.mp3");

The Audio Player's other functions are: Pause, Resume, and Stop.


Casts

Casts are a way to convert one Datatype into another.

But not every Datatype can be converted to every other. As an example, you can't convert a TCPClient into an Integer.



Using a cast could look like this:

var someInt <- int("19");

The Cast here being 'int()'


Classes

Classes are a way of structuring your Code in an Object Oriented style. They can contain Functions and Variables, and can either be Dynamic, Static or Abstract.


A Class Declaration could look like this:

class someClass {..}

Public Variables in Classes need to be declared as global statements (not in any function), heres an example:

class someClass
{
  set myPublicVar <- 0;
  set string anotherPublicVar;
}

Constructors

Constructors are Functions that get run when the Object is created.


A Constructor could look like this:

function Constructor()
{
  ... code that will be run on creation ...
}

To create an object using the Constructor, use the 'make' statement:


var myObj <- make someClass(arguments);

Static Classes

Classes can be made static by adding the 'set' Keyword when declaring the class:


set class someClass { ... }

Accessing a Static Class

You can access a Static Class the same way you would Access an object.


But instead of a Variable, you use a Class name:


Class -> function();

Included Classes

By default, all Classes made in a Script are seperate from the Main class.
If you want a class to be nested inside the Main class just use the "inc" keyword.

inc class someNestedClass { ... }

This also works for static classes.

set inc class someStaticNestedClass { ... }

This is useful for creating Custom Packages in ReCT when you want to include Classes in your Package.

Serializable Classes

Classes can be made Serializable with the "ser" keyword. Serializable classes are useful when interfacing with other dotnet applications.
Being serializable allows an instance of a class to be easely turned into binary information to be sent or stored.

ser class SerializableClass { ... }

Abstract Classes

Abstract Classes can be seen as a kind of blueprint that other Classes can be created from. Abstract Classes themselves cant be instantiated.
An Abstract Class can be created with the "abs" keyword:

abs class AnAbstractClass { ... }

Like any other Class, Abstract Classes can also have Constructors and Variables.
Abstract Classes get a lot more interesting when considering Virtual Functions and Virtual Variables that can be overwritten by Inherating Classes.

Inheriting Classes

Inheriting Classes are Classes that use an Abstract Class as a "blueprint". A Class can inherit from an Abstract class by including the name of the Abstract Class after the classname in parenthesis.
Heres an example:

class someInheritingClass (someAbstractClass) { ... }

Virtual Functions and Variables registered in the base-class will automatically be available in this Class as well, they are also able to be overwritten.


Sidenote: Constructors

If youre using Constructors in your Classes you will have to call your base-class' Constructor inside your Constructor. This can be done with the "base" statement. And should (preferably) be done as the first action inside the Constructor.

abs class someAbstractClass
{
  function Constructor() { ... }
}

class someInheritingClass (someAbstractClass)
{
  function Constructor()
  {
    base();
    ..
  }
}

Overwriting Virtual Functions and Variables

Now finally we get to the cool part: overwriting! Overwriting in ReCT is super simple, just use the "ovr" keyword like in this example:

abs class someAbstractClass
{
  virt set someVariable <- "some Value";
  virt set function someFunction() { ... }
}

class someInheritingClass (someAbstractClass)
{
  ovr set someVariable <- "some different Value";
  ovr set function someFunction { ... different code ... }
}

Packages

Packages are .NET Assemblies that ReCT can read and use.
There are a lot of System Packages you can, use but it is also possible to make your own Packages in any .NET compatible language. (More about that Here)


Adding a Package

To add a Package to your Project, just use the 'package' statement
Adding a Package could look like this:

package sys;

Now that you have added a Package, you can access the things inside it by calling it's Namespace.
For example:

sys::Print("Hello World!");

'Use'-ing a Package

By 'Use'-ing a package you don't need to call it's Namespace when accessing it. You can use a Package by using the 'use' statement as shown below.

package sys; use sys;

Now when we go back to the example from earlier, we dont have to call it's namespace:

Print("Hello World!");

'Alias'-ing a Package

By aliasing a Package you are able to add another name for the same package. This is useful for packages with long inconvinient names. The reason you would do something like this instead of just "Use"-ing the package is to keep your project Organised.


As an example: a Package written by me with the slightly inconvinient name "DownloadPlusPlus"

package dll DownloadPlusPlus; alias DownloadPlusPlus dpp;

Now we can address the package by using our shortened name:

var dl <- make dpp::Downloader();

Custom Packages

Custom Packages can be made in any .NET compatible Language.
The Important thing is that the Module, Namespace and Class names need to be the same and, probably should be the Package name. Also, the class needs to be public and static.
The Structure of a package would look something like this:

(NOTE: This is not C# code! This is just for visualizing the Structure things need to be in!)

module samplePackage
{
  namespace samplePackage
  {
    public static class samplePackage
    {
      //package code here
    }
  }
}

ReCT will read out Functions and Classes, as long as they are public (That also applies to functions and fields inside of classes), and ReCT will not read out Fields in the main Package class! If you want ReCT to be able to access them, you will need to use "{Get; Set}".


Adding a Custom Package

To add a Custom Package, just use the 'package dll' statement followed by the Package's name. (Not filename!)

package dll samplePackage;

The syntax for 'Use'-ing a Custom Package is the same as for a normal Package.

C. Packages in ReCT

You are actually able to create Custom Packages in ReCT itself.

You can set a Type (class) and Namespace name with the "type" and "namespace" statements. (NOTE: Just like in any other dotnet language are only public functions accessable from within rect.)

A package made in ReCT could look like this:

package sys; use sys;
type examplePack;
namespace examplePack;

set function testFunc()
{
  Print("Test Function");
}


When building make sure that the filetype is set to "Assembly (.dll)", and that the filename is the same as the type and namespace name!


If you want to also add Classes to your Package make sure that they are Included by using the "inc" Keyword

inc class classInMyPackage { ... }
set inc class staticClassInMyPackage { ... }

Threading

Threading can be used to do multiple Things simultaneously.
To Create a Thread, just use the Thread statement:

var thread <- Thread(someFunctionName);

To start a Thread, just call it's StartThread function:

thread -> StartThread();

To kill a Thread, you can call it's KillThread function:

thread -> KillThread();

Please keep in mind that when you kill a Thread you can't restart it.


Access Objects

You can Access public Functions and Variables inside objects by using "->".
(You can also access Datatype Typefunctions)

If you want to Access a Variable, you can do something like this:

someString->GetLength()

This also works for expressions and Array items, here are a few examples:

"a string" + "some other"->GetLength()
someStringArray[0]->GetLength()


Operators

ReCTs supported binary operators (in order of priority) are:

*, /
+, -, %
=, !=, >, <, >=, <=, >>, <<
&, &&
|, ||, ^

ReCTs supported unary operators are:

+, -, !, ~

Editors

ReCT supports the following Variable-Editors:

++, --
<-+, <--, <-*, <-/

Ternary Operator

The Ternary Operator can be seen as a shortened If Statement that picks a value based on a Condition
A Ternary Operation in ReCT is structured in a similar way to the C# Ternary Operation:

condition ? aValue : anotherValue

An actual example of this might look something like this:

var DayNightText <- isDay = true ? "It is daytime!" : "Seems to be nighttime"

Is Operator

The Is Operator exists to check if an Instance of an Abstract Class is of a certain Inheriting Classes type.
For example: Image you have an Array of type "someAbstractClass" that holds instances of both "someInheritingClass" and "someOtherInheritingClass" the Is Operator is how you can tell them apart:

var instances <- make someAbstractClass array(100);

from (i <- 0) to instances->GetLength() - 1
{
  if (instances[i] is someInheritingClass)
    // do something
  else if (instances[i] is someOtherInheritingClass)
    // do something else
}

Exception Handlers

Exception handlers (also known as Try-Catch Blocks) are a way of failsafing code. If an error occours inside a Try Block, the program wont crash but simple skip to the Catch Block.
Heres an example for an Exception Handler:

try
{
  ... some code that might crash ...
}
catch
{
  ... code that will be run in case of a crash ...
}

These are especially useful when doing TCP Networking because the only way to detect a TCP Client or Server disconnecting is through an Exception being thrown.


Enums

Enums are a way of assigning meaning to Integers by giving them labels.
Heres an example for an Enum:

enum MyEnum
{
  anEnumMember,
  anotherEnumMember
}

You can also specifically set the Value of the labels:

enum MyOtherEnum
{
  anEnumMember <- 100,
  anotherEnumMember <- 200
}

These 2 styles can also be mixed:

enum MyOthererEnum
{
  anEnumMember,               // 0
  anotherEnumMember,          // 1
  yetAnotherEnumMember <- 20, // 20
  evenAnothererEnumMember,    // 21
}

To access an enum value, simply use a normal Object Access

MyEnum->anEnumMember

Just like Classes, Enums create their own Datatypes, meaning you can have an enum variable that stores an Enum state:

var MyEnum enumVar;
enumVar <- MyEnum->anEnumMember;

Binary / Hex Literals

For your convinience, ReCT also allows you to describe Numbers in binary or hexadecimal.

var someNumber <- 0x1A4;
var someNumber <- 0b1000101;

(NOTE: When using a binary literal thats exactly 8 bits it will return a literal of type Byte instead of Int)


Lambda

ReCTs Lambda is what you would also know as "Anonymous Functions" rather than Lambda Calculus. They are Functions that arent assigned to a symbol, but rather create an Object of type "action" that can be stored in Variables.

var someLambda <- lambda {
  ... function code ...
}

You can also convert an existing function into an action by using the "Action" statement:

var someAction <- Action(someFunction);

To run the Function you simply call the varibles ->Run() typefunction:

someLambda->Run();
someAction->Run();

(NOTE: Because Lambda functions exist in their own space they can only interact with global data)


Preprocessor Statements

Preprocessor Statements (originally called "IDE Flags") are things the Compiler takes care of before doing the actual compilation.
Things like:

(NOTE: If the path given in #copy or #copyFolder is not rooted it will use the /Packages directory as a root. #copy and #copyFolder also support using the current working directory by using the $CWD placeholder like this #copy("$CWD/path/to/file"))