When I’m asked for example code, it’s always been easier to respond to questions about ROBOTC (or PROS and ConVEX) than it is EasyC. The reason for this is the difficulty in quickly creating and posting code in EasyC’s drag and drop flowchart interface. For some students I think it’s time to move on and start writing code using the EasyC text editor (or just switch programming environments ) so I though I would show how to jump out of the EasyC flowcharts into a more conventional (and yes, less forgiving) way or working.
Here are the steps to jump straight from OperatorControl into a user function written in C.
-
Create a new competition project.
-
In the OperatorControl function, delete the while(1) loop. Drop the “user code” block below the variables block and type into it “UserOperatorControl();” The flowchart should look like this.
[ATTACH]8458[/ATTACH]
- In the project explorer window, right click on “Block Diagram” and select “Add new function…”. In the dialog box that pops up give the function a name, UserOperatorControl. We don’t need any arguments.
[ATTACH]8459[/ATTACH]
This will create a new flowchart tab with the new function. ( We could have skipped this stage and just made a new C file directly but this way works just as well).
- If you wan’t you can create some code in the “normal” way, first add a while(1) loop, this is replacing the while loop that would have normally been in the OperatorControl function, as we are calling this new function from there we need to make sure it does not return back to where it was called from or the code will stop running. Here is a short program I entered.
[ATTACH]8460[/ATTACH]
- Turn this function into a C file, right clock on the function in the project explorer window, select “Convert to C code”. This will be a one way process, once done there’s no going back to the flowchart mode for this function.
[ATTACH]8461[/ATTACH]
6 The converted file looks like this, a text file where we can now start programming using the keyboard rather than drag and drop.
[ATTACH]8462[/ATTACH]
- There’s one more thing to do, we need to let the compiler know about our C code function. In the project explorer, double click on the file UserInclude.h under Header Files. Add one line of text so the file looks like this.
// UserInclude.h : header file
#ifndef USERINCLUDE_H_
#define USERINCLUDE_H_
// TODO: add user code here
void UserOperatorControl ( void );
#endif // USERINCLUDE_H_
Everything should now compile correctly.


