ROBOTC Interface

From ROBOTC API Guide
< Tutorials
Revision as of 20:22, 14 May 2012 by Bfeher (Talk | contribs)

Jump to: navigation, search
Tutorials → ROBOTC Interface




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.

ROBOTC IDE.png


There are three main sections to the ROBOTC IDE:

  1. The Editor
  2. The Code Templates / Function Library
  3. The Main Menu / Toolbar


Editor

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

ROBOTC-IDE Editor.png


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.

ROBOTC-IDE Toolbar.png


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.

ROBOTC-IDE Templates.png


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:

ROBOTC-2010.01.13-13.14.29.png

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.

Reserved Words/Pre-Defined Functions (int, motor) are displayed as bold blue text and italicized blue text.

Constants and Parameters (127, port1) are displayed as red text.

Syntax and Operands (+, -, *, {, <, [, etc.) are displayed as light red text.


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-explained.png

ROBOTC generates three types of compiler messages: Errors, Warnings and Information Statements.

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.

Insert-breakpoint.png


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

Remove-breakpoint.png


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:

Debugger breakpoint info.gif

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.

Execution-stopped.png


Status Bar

The Status Bar gives you information about the ROBOTC editor and the current program.

Status-bar.png

  1. Context Help - Hover over different sections of the ROBOTC interface for brief descriptions.
  2. Active Project - Displays the most recently compiled program.
  3. Read-only Status - Displays the file permissions for the most recently compiled program.
    1. R/W - Read and Write Access
    2. R/O - Read Only Access
  4. Compiler Errors - Displays the number of Warnings and Errors in a program, if any.
  5. Line/Column Display - Shows the line number and character of where the text cursor is currently located.