Rearranging tabs in IDE??

Is there any way to reorder tabs? I have my sketch split among several tabs for readability, and it seems I need to move them around so variables are declared before they are used.

For the life of me I cannot figure out how to do this - is it something obvious?

At the top of any file that uses a variable from another file you should declare it as "extern" -

For example if File2.cpp declares an integer variable like this:

int counter2;

and you want to use the variable in File1.cpp
at the top of File1.cpp ( or at least before you try to use it) declare it like this:

extern int counter2;

That lets the compiler know what type of variable counter2 is when it runs into it as it processes File1.

Right, but I;m talking about "normal" tabs rather than .cpp or .h tabs. I think the IDE concatenates all normal tabs into one file before compilation.

In my case I have some global variables describing configuration of the external hardware; I wanted them out of the way so I can concentrate on the code.

Then put them in a header file (e.g. globals.h) and #include them in your sketch at the top #include "globals.h". They are then guaranteed to be at the top of your sketch. This is one of things header files are good for.

That makes sense. But for those curious, I have found out how to rearrange tabs.

The tabs (other than the first) seem to be ordered alphabetically. So you can rename your tabs to arrange them in the order you please.

One simple way of doing this is to name them "_1xxx" "_2xxx" "_3xxx" etc.

Hi,
Prof. Chaos is right, the files are processed sorted on their filenames.
But the main file that gives the name to the sketch is always processed first. So you should be fine placing all global declarations at the top of the main sketch-file.

Eberhard