View unanswered posts | View active topics It is currently Tue Jul 29, 2014 12:36 pm






Reply to topic  [ 8 posts ] 
Include file help??? 
Author Message
Rookie

Joined: Thu Nov 06, 2008 4:35 pm
Posts: 12
Post Include file help???
hello I am having problems with making a include file. i do not know if robot c include files work the same as your common c++ include files. the problem i was having was that it could not locate the file , the correct name was typed in the # include command. i don't know why it is not locating the file. thank you for your response.

also is it leagl and functional on the felid management system to have custom include files?

_________________
Palm Harbor University High School, Robotics team Pandara #506


Mon Dec 15, 2008 11:24 pm
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 601
Post Re: Include file help???
The include file can be found in the "[InstallPath]/ROBOTC for Mindstorms/Includes". IF you don't have the JoystickIncludes in that folder, uninstall ROBOTC and reinstall it as it seems something is missing.

Custom include files are allowed.

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Tue Dec 16, 2008 10:07 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post Re: Include file help???
ROBOTC checks several directories for include files:
  1. It first checks to see if the filename is a fully qualitfy ("absolute") file name. That is, one that contains both disk drive name and parent file folder(s)
  2. It next checks several different folder/directories for the file, It does this by prefixing the directory name to the prefix.
  3. It checks the folder that contains the main program file.
  4. It checks the folder that contains the system include files. This folder name is specified in the registry entries for ROBOTC.
  5. I recall that ROBOTC also allows for the standard "." and ".." designation used in specifiying parent folders and sub-folders. [Advanced users only.[/list]
Generatlly, most users will not need to understand the folder search order.


Mon Dec 22, 2008 3:33 pm
Profile
Expert
User avatar

Joined: Tue Oct 14, 2008 7:16 pm
Posts: 171
Location: Investigating an unidentified ship sighted in Sector 31428
Post Re: Include file help???
The RobotC compiler needs to know where to look for includes. In a full compiler there are a number of predefined directories, usually a subdirectory of the compiler's main directory, where it looks for common includes accessed like this:
Code:
#include <iomain> //For demonstrative purposes ONLY!! Windows C++ headers, don't try this with RobotC you will get an error!!
#include <iostream>

IDEs with integrated compilers will usually create a special project directory and include those paths as well in the search. RobotC which is far simplier than high end IDEs doesn't set up a special directory for projects but you can specify a directory to search for custom includes. Under the View menu select "Preferences"; then select the "Directories" tab and in the "Directory for Source Files" type the directory where you are keeping your source files. Remember that if this is a place like My Documents you must enter "Windows Drive (usually C:)\Documents and Settings\User name\My Documents\..." or for the less technically inclinded use the "Browse" button to find your directory.
You can then reference your headers or includes thusly:
Code:
#include "includes.h"
    //or
#include "includes.c"


You can also include another file from an include, like so:
Code:
//main.c
#include "include 1.h"
#include "include 3.h

Code:
//include 1.h
#include "include 2.h"


Just keep in mind when putting functions in includes that the function must be defined prior to its usage. If you use a function in "header 1.h" or "header 2.h" you can use it in "header 3.h" but a function declared in "header 3.h" may not be used in the other two files.

Also keep in mind that you must not include the same header more than once. So in the above example you could not put a #include for "include 2.h" in "include 3.h".
Code:
//main.c
#include "include 1.h"
#include "include 3.h

Code:
//include 1.h
#include "include 2.h"

Code:
//include 3.h
#include "include 2.h" //Wrong this will generate an error because "include 2.h" has already been included


Additionally you can not have circular includes,
Code:
//main.c
#include "include 1.h"
#include "include 3.h

Code:
//include 1.h
#include "include 2.h"

Code:
//include 2.h
#include "include 1.h" //Wrong this will also generate an error because "include 1.h" references "include 2.h" which references "include 1.h"


Separating your code into spearate files can be an extremely useful tool, espicially if you have a large amount of code. If you have functions that you might use over and over or that can be used from year to year putting those in an header file that can be accessed in later programs will save you time and bulk in your main program. As long as you are wary of the rules of includes then you should be fine. Keep in mind also the fact that includes add a layer of complexity to your code and thus you run the risk of creating more errors; use them only if you are comfortable coding as well as debuging.

Hope this helps and good luck with your ventures with "ROBOTC". :programmer:

_________________
Captain, Head programmer, School of the Arts, Silverbots Robtics Team #2890
Code:
using namespace System;
using namespace Genius;
using namespace Personality;
public ref class Nerd : Geek, IAnserable
{
    Geek::Type brainMode = Geek::Type::Programmer;
}


Wed Jan 07, 2009 7:26 pm
Profile
Novice

Joined: Tue Jan 13, 2009 5:22 pm
Posts: 72
Location: USA, Pennsylvania
Post Re: Include file help???
I have the same problem, RobotCincludes.h. Please talk so other people understand. :x Where can I download the file if possible, or do I have to reinstall the program.
We really need help now because of a competition very soon :!: :!:

_________________
We need a Linux Version!


Tue Jan 13, 2009 5:33 pm
Profile WWW
Expert
User avatar

Joined: Tue Oct 14, 2008 7:16 pm
Posts: 171
Location: Investigating an unidentified ship sighted in Sector 31428
Post Re: Include file help???
Emilhem wrote:
I have the same problem, RobotCincludes.h.

What problem exactly are you having? If by problem you are referring to being unable to use your own include files then follow the directions above to tell RobotC where you are keeping your includes. If you are having a problem with the "RobotCIncludes.h" file found in the RobotC directory then you might have a larger problem in which case the simplist solution would be to uninstall and reinstall RobotC.

_________________
Captain, Head programmer, School of the Arts, Silverbots Robtics Team #2890
Code:
using namespace System;
using namespace Genius;
using namespace Personality;
public ref class Nerd : Geek, IAnserable
{
    Geek::Type brainMode = Geek::Type::Programmer;
}


Wed Jan 14, 2009 5:16 pm
Profile
Novice

Joined: Tue Jan 13, 2009 5:22 pm
Posts: 72
Location: USA, Pennsylvania
Post Re: Include file help???
It was someone in school that had access to that computer who erased some files i think. :programmer: :breakcomputer: But I reinstalled the program and it works perfectly now. :bigthumb:

_________________
We need a Linux Version!


Sun Jan 18, 2009 11:41 am
Profile WWW
Rookie

Joined: Thu Nov 06, 2008 4:35 pm
Posts: 12
Post Re: Include file help???
Thank you for the help, I got it working now. but i was trying to do it with a custom file and i got another problem it cant locate , i did the same method i did to locate the files before but it didn't work. i cant tell if this is another problem or not. thank you for your response!!!

_________________
Palm Harbor University High School, Robotics team Pandara #506


Sat Jan 31, 2009 3:01 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.