Depending on the type of error, ROBOTC will only be able to highlight the approximate location of the error. For instance, in the example below the missing semicolon is on line 6, but ROBOTC will highlight line 7.<br /><br />

Depending on the type of error, ROBOTC will only be able to highlight the approximate location of the error. For instance, in the example below the missing semicolon is on line 6, but ROBOTC will highlight line 7.<br /><br />

Revision as of 19:19, 14 May 2012

Contents

Overview

ROBOTC for Mindstorms is an Integrated Development Environment. It has been developed to provide as much support as possible for the platforms it is compatible with. The ROBOTC interface will modify itself to accommodate the functionality found in your controller. ROBOTC extends the ‘C’ programming language with a number of built-in variables and functions to provide control over a robot’s hardware devices, i.e. the motors and sensors.

There are three main sections to the ROBOTC IDE:

The Editor

The Code Templates / Function Library

The Main Menu / Toolbar

Editor

This is the part of the interface where the user can write code.

Code Templates / Function Library

This portion of the interface allows user to see all the functions available in ROBOTC at their user level. Portions of code from the "Function Library" can be dragged into the Editor.

Main Menu / Toolbar

This area allows you to perform basic tasks (saving, copy & pasting, undo, etc.), switch between multiple open programs using the tabbed interface, and access all of ROBOTC's additional functionality through the various menus.

Code Editor

Writing Code

Writing Code is the primary focus of ROBOTC, being a C-Based development environment. The ROBOTC Code Editor provides some visual assistance while programming with the use of line numbers and color coding:

Normal Text is displayed as black text. Normal text is used for variable and function names that are user-defined and not recognized by the compiler as reserved words.

Comments are displayed as green text . Comment are any bits of text in a program prefaced with a "//" or a "/*". This "commented text" is not considered code and is ignored when the compiler is generating byte-code to send to the robot controller.

Error Display

At compilation time, the ROBOTC compiler analyzes your code to identify syntax errors, capitalization and spelling mistakes, and code inefficiency, such as unused variables and redundant code. The ROBOTC compiler also has a powerful code optimizer that can shrink your program size by up to 50% before sending it to the robot to preserve memory space on your controller.

The Error display screen reports the number of errors in your code, as well as their types. Double-clicking a compiler message in the Error display screen will highlight the relevant line of code in your program. The "Previous", "Select", and "Next" buttons can also be used to cycle through and select the errors in your program.

Depending on the type of error, ROBOTC will only be able to highlight the approximate location of the error. For instance, in the example below the missing semicolon is on line 6, but ROBOTC will highlight line 7.

Errors:
ROBOTC has found an issue while compiling your program that prevented it from compiling. These are usually misspelled words, missing semicolons, and improper syntax. Errors are denoted with a Red X.

Warnings:
ROBOTC has found a minor issue with your program, but the compiler was able to fix or ignore it to get your code to compile. These are usually incorrect capitalizations of words or infinite loops without any code inside. Warnings are denoted with a Yellow X.

Information:
ROBOTC will generate information messages when it thinks you have declared functions or variables that are not used in your program. These messages have no affect on your program and only serve the purpose of informing you about inefficient programming. Information messages are denoted with a White X.

Breakpoints

Breakpoints are a useful debugging tool in ROBOTC. Breakpoints can be placed on any line of code and tell the controller to stop executing the program when that line is reached. When a breakpoint is reached, the ROBOTC debugger informs the programmer, who can then check the status of the robot, code editor, and debugger windows at that point. ROBOTC supports multiple break points.

Breakpoints are denoted by a red circle in the gray area between the code and the line numbers.

To add a breakpoint:
Right-click on the line number where you wish to add a break point and a context menu will appear. Select "Insert Breakpoint" to place a breakpoint at that line.

To remove a breakpoint:
Right click on the red breakpoint circle and select "Remove Breakpoint".

Running your program with breakpoints:
When a breakpoint is in a program executing on the controller and the debugger is open, you will see the following message from ROBOTC:

This message is just an indication that the breakpoint has been reached. Click OK and then look at your program in the code editor. ROBOTC will highlight the line of the breakpoint that program stopped at, allowing you to see exactly which breakpoint the program executed.