external declarations file without extern

Hi folks. Is it possible to create a file(.ino?) which contains declarations in it which are to be used in another(the main) .ino file without referencing those same variables using the extern command? Reason being is that i am going to generate a bunch of data from within a processing sketch and would like to be able to export it as a file which is simply 'picked up' by the main arduino sketch. the extern command means i have to update it manually which aint the end of the world but would be nice if there was a simple solution... Thanks, Danny.

gonadgranny: ...i am going to generate a bunch of data from within a processing sketch and would like to be able to export it as a file which is simply 'picked up' by the main arduino sketch. the extern command means i have to update it manually...

not following you...

you want to include a file in your source code that contains 'a bunch of data' (in the form of what?) which can be anonymously referenced by your main .ino file?

not following you...

Haha, I appreciate all the help mate, thanks!

you want to include a file in your source code that contains 'a bunch of data' (in the form of what?) which can be anonymously referenced by your main .ino file?

Its those byte arrays ive been working with. So theres going to be quite a lot of byte arrays stored in PROGMEM. Using tabs works fine if functions are in there but when i tried to access my arrays it cant find them (unless i use the extern command....

gonadgranny:
Haha, I appreciate all the help mate, thanks! Its those byte arrays ive been working with. So theres going to be quite a lot of byte arrays stored in PROGMEM.
Using tabs works fine if functions are in there but when i tried to access my arrays it cant find them (unless i use the extern command…

extern tells the compiler not to complain if the variable isn’t defined in that particular file, and that it will be all sorted by the linker later.

is the problem that your byte arrays in the other file are not always defined with the same name?

The arrays are arbitrarily named dependent on the type of movement they represent(they are positions for servos). so i just want to 'export' these sequences from my other piece of software written in the processing environment and have them available to use as and when required in my arduino sketch.

gonadgranny: The arrays are arbitrarily named dependent on the type of movement they represent(they are positions for servos). so i just want to 'export' these sequences from my other piece of software written in the processing environment and have them available to use as and when required in my arduino sketch.

so, you could try to create an array of pointers to your arrays of movements and reference that single pointer as extern in your ino source file. you would then have to build that array in the context of that 'other' file, I suppose you could script that.

there may be better ideas out there...

how did your servo sweep work out?

Anything you put in any .ino file is visible to ALL other .ino files in that project. There is no need to use extern. All the ino files get merged together into a single file before compilation. The only “gotcha” is the one with the same name as the sketch directory is loaded first, and the rest are loaded in alphabetical order, so you may have problems with forward references. You can also just put any shared data into a .h file, and include that at the top of the .ino file.

Regards,
Ray L.

how did your servo sweep work out?

Works perfectly, many thanks for that!

Anything you put in any .ino file is visible to ALL other .ino files in that project. There is no need to use extern. All the ino files get merged together into a single file before compilation. The only "gotcha" is the one with the same name as the sketch directory is loaded first, and the rest are loaded in alphabetical order, so you may have problems with forward references. You can also just put any shared data into a .h file, and include that at the top of the .ino file.

Whenever i tried putting my declarations into another tab i would get hit with a 'variable was not declared in this scope' suggesting that it cant locate it even though the main program is 'the one with the same name as the directory' so im not quite sure whats going on there....however, i tried making a separate .h file and that seems to have done the trick so thanks for that!