[solved]How to use Tabs in Arduino IDE

They are for accommodate a big sketch in the IDE for better reading and development, I assume. But How to use it, Which is the correct way to separate the sketch in parts over the IDE

I have in mind hide some of the code that is for the setup, variables arrays and stuff.

If you have several .ino files in the sketch directory they will each appear in a separate tab. When compiling they are loaded in alphabetical order after the principal .ino file (the one with the same name as the directory). Global variables defined in earlier .ino files are available to code in later files.

I would put setup() and loop() in the principal file. They could call functions in other files.

...R

I don't even know how to have several .ino files I'm Just curious about that, because I see this little button arrow in the top right corner that has "new tab" button.

I thought that that was for add an other part of the sketch, like a web page that has the main html and the .css and .js files; I actually see the implementation of this technique in one project named BigBlue : http://forum.arduino.cc/index.php?topic=90855.0

I was asking for what structure need to follow in order to take advantage of this feature. thank you for answer me Robin2

I use them like this: first tab is the file you start with. I put notes about the sketch there. then I create some new tabs: a_presetup, b_setup, c_loop, d_more_loop, e_and_more_loop, f_end_loop

The different sections could be put back together as one big long file, breaking it up like this makes it easier to work the different sections, and it seems to compile alphabetically after the initial tab.

Thanks for answer CrossRoads

Well I had an idea of how to use it but not sure how to star.

Lest assume that we have the typical blink sketch. My idea is for example to put the content of the loop in a function in other tab named for example functionTab

int led = 13;
void setup() {                
  pinMode(led, OUTPUT);     
}
void loop() {
 functionBlink();
}

functionTab content:

functionBlink();
{digitalWrite(led, HIGH);   
  delay(1000);            
  digitalWrite(led, LOW);   
  delay(1000); }

the result in the IDE log:

'functionBlink' was not declared in this scope

As I say before is like a web page with extra files; in a web page we use link tag for call css files, I'm pretty sure that I'm missing the link tag here...

It must bee include but I get same error even adding: #include "functionTab"

Edit an apologize for bad English

You might just be missing something basic, such declaring the Type of function. Try adding void in front of it, the same way setup & loop do:

void functionBlink();
{digitalWrite(led, HIGH);   
  delay(1000);            
  digitalWrite(led, LOW);   
  delay(1000); }

Hi,

FWIW I group functions based on the subsystems they operate on by tab. For example I might have all EEPROM functions in one, all that manipulate a display in another, wireless comms in another, general utilities in another and just global declarations, setup() and loop() in the first. Everyone will have their own style of course.

In the case of the example above the semicolon in the first line of the function declaration is what’s messing it up not the tabs.

functionBlink();  // <-- that semicolon
{digitalWrite(led, HIGH);   
  delay(1000);            
  digitalWrite(led, LOW);   
  delay(1000); }

Cheers ! Geoff

If a function doesn't work in a tab move the whole function into the principal sketch and get it to work there. Then move it back to the tab.

...R

I really don't know that was so easy, just copy a functional function into a new tab, thanks Robin2 for the tip.

strykeroz ";" semicolon error :sweat_smile: it happens, actually I copy that from inside the loop, and I miss the declaration of the kind of function. CrossRoads that was the problem yesterday thanks.

by the way was so easy that I couldn't find a reference in the "Learning" > > "Examples" page.

thank you all.

Have a nice week

You can also use the tabs to localize a library to one sketch: for example, you must make changes to the library and therefore want a local copy and not change the master that would affect sketches that rely upon the stock lib!

I just completed a GPS project and hacked the heck out of an Adafruit library. I brought the library .h and .ccp files into the sketch directory as tabs to the main sketch.

Ray

I have found out that the compile includes "all files" automaticly except ".h" Header files by default. I have a need to make changes to an existing sketch, but don't want to loose the existing configuration. (for maintenance purposes).

Therefore I name each tab other then the two initial ones as "xxx.h" making it a header file. In this way I can develop individual functions or globals without directly including them in the sketch main body.

Then I use the #include to include the files that I want in a specific version.

This is a very handy way (but not what header files were suppose to be). I also use the #ifndef, #define, and #endif. These are all part of the normal c++ compiler.

I even GUT the normal content of the ".ino" file and fill it with #includes for each test script, I comment out all but the one test script I want to run.

I also have "class_includes.h" files that has nothing but #includes for each tab (member fragment) that I want to include. The test script names the member_includes.h file needed to build the correct structure for the test.

I also have a file named: "display_state.h" which has all of the monitor write commands to diplsay status information for debugging purposes.

There are many ways to use this facility. Now I am looking into how to #incluude tabs from other sketches. That will allow me to reuse code from other sketches, rather than copying them into the new sketch. "reference" is a lot better than "copy". Maintaining multiple copies becomes a nightmare.

Hope this helps.

mrburnette: You can also use the tabs to localize a library to one sketch: for example, you must make changes to the library and therefore want a local copy and not change the master that would affect sketches that rely upon the stock lib!

I just completed a GPS project and hacked the heck out of an Adafruit library. I brought the library .h and .ccp files into the sketch directory as tabs to the main sketch.

Ray

Thumbs up on this one. It is so simple, but in the past I have had things working, only to have a library update. This allows one to lock in the whole sketch at a moment in time.

CrossRoads: I use them like this: first tab is the file you start with. I put notes about the sketch there. then I create some new tabs: a_presetup, b_setup, c_loop, d_more_loop, e_and_more_loop, f_end_loop

The different sections could be put back together as one big long file, breaking it up like this makes it easier to work the different sections, and it seems to compile alphabetically after the initial tab.

This sounds cool!