The following example steps apply to the gmcs compiler, part of the Mono Project ( Different compilers have different ways of accomplishing these tasks.
#Robotc programming language code#
Furthermore, you must tell your compiler to link your code with UnityEngine.dll (which can be found in /virtualvex_a3 data/Managed. You must set your C# compiler to compile the code as a Class Library, also known as a DLL file. Once you have finished making your code it must be compiled for use in VirtualVEX. This is a chart of which "motors" on the virtual robot are plugged in to which "ports," which is necessary knowledge for programming the robot. VirtualVEX runs in its own control loop, and butting an additional while loop inside could lead to unexpected results. However, there is one IMPORTANT difference: do NOT put the code inside a while loop like you would in ROBOTC.
#Robotc programming language driver#
Since ROBOTC syntax is supported you can program the driver code just as you would a regular VEX ROBOTC program. Driver code goes inside the driver_control() function. This template contains important definitions for ROBOTC constants. Lines 28 and 35 are curly braces, which tells ROBOTC where the code starts (line 28, with the ’, which tells ROBOTC to turn off the motors and stop the program.All VirtualVEX programs must be written within the source.cs template. Line 27 contains the ‘task main()’ declaration that is needed in every ROBOTC program this tells ROBOTC where to start ‘reading’ code.ĥ. Note that the // can be used to comment a single line of text, allowing comments to be placed right next to other lines of code.Ĥ.
This helps readability and allows others to understand the code, even if they were not the original authors of the program. Lines 3 to 26 are comments and are simply notes that the programmer can use to let others know what each line or segment of code does. We can then use these names in the program to tell ROBOTC which motor we want to control.ģ. The first two lines tell ROBOTC that there are motors plugged into motor ports 2 and 3 on the Cortex, and it gives the motor on port 2 the name of ‘rightMotor’, and the motor on port 3 the name of ‘leftMotor’. ROBOTC programs are read by the compiler from the top to the bottom, left to right (just like reading a book).Ģ.