.Net CLR

For more advanced users, the underlying .Net CLR is available to the ARC JavaScript engine. This means you can access the entire underlying ARC platform and operating system from the JavaScript engine.

What Is CLR?

The .NET Framework provides a run-time environment, called the common language runtime, that runs the code and provides services that make the development process easier. Compilers and tools expose the common language runtime's functionality and enable you to write code that benefits from this managed execution environment. Code that you develop with a language compiler that targets the runtime is called managed code. Managed code benefits from features such as cross-language integration, cross-language exception handling, enhanced security, versioning and deployment support, a simplified model for component interaction, and debugging and profiling services.

.NET Framework Example

This example will use the System.IO.StreamWriter to write some text to a log file on the C:\. The ARC JavaScript engine already does provide file writing capabilities, this is used as an example to demonstrate accessing the raw CLR commands and namespaces directly.

// Create an instance of the stream writer
var file = new System.IO.StreamWriter('c:\\log.txt');

// Write some text to the file
file.WriteLine('Hello World !');

// Close the file and dispose the object
file.Dispose();


EZ_B Driver Example

The ARC JavaScript engine exposes the raw EZ_B driver for each EZB connection. This is the same as the ARC.EZBManager.EZBs array when creating a robot skill.

// Move the servo on port D2 to position 20 on EZB #0
EZBs[0].Servo.SetServoPosition(2, 20);