Using tab in Arduino IDE - Error Compiling - Resolved

Hello All

I have been searching & reading a lot of content about compiling errors when using tabs in Arduino IDE and found a way to circumvent
the issue. I had the same issue when I was trying to clean up my sketch, a simple 7 segment clock, adding tabs in IDE for function() calls and always
landed with errors. I found errors occurred while copying portion of your sketch from within IDE and pasting them into tabs.

Objective: To break up a large program, Function calls, into more readable content using Tab in IDE and more importantly compiling without errors.

What you really got to do is to copy the ' jumbled ' code you wrote in one single INO file into a plain text file. I am using NotePad++ for this which has some awesome
features and its a freeware as well.

Once you have copied your code into NP++ ( note pad ++) you just save it as a PLAIN TEXT file using "save as". Make sure you remove any INO extension or INO in the
file name you are going to save.

Start IDE, start a new Sketch (FILE>NEW). Now with your NP++ open, copy relevant content and paste it on your main program. I normally copy all , Variables and
setup() and the void loop(){ ...} in the main program.

Now create your "tab" and copy and paste from the np++ ( this is important .. copy/paste only from np++ text file), relevant function() calls or what ever into
the new tab. I usually name tab with a prefix a, b ,c followed by the file name, for example a_domyclock, b_docalc, c_dodisplay since IDE sorts the tab in
alphabetical order and its much easier to follow while programing and no jumping tons of code to find a particular variable etc. Now, do the same with other functions
into different tabs. Compiles without any error what so ever.

Inference:
Cutting and pasting function() calls from within IDE to tab -> did not work/Errors reported by IDE
Cutting and pasting function() calls from NP++ to IDE to tab -> WORKED.

Can't really figure out whats going on within IDE to cause this issue.

Will like to hear from you guys if got it working too...

Regards
Vijay

OP I am not sure what you are trying to solve. I do not personally break my code up into different .ino files. I prefer to mange code with classes.

Never understood this tabbed method, it left me feeling like I was not 100% in control of my code.

So I have zero knowledge of the issue you are presenting, I took this as a time to examine what you posted, and learn a bit more about using tabs.

I created a project, had several .ino files. In the primary one I added several functions, then copied them to the other tabs. I seen no issues with copy pasting between several tabs, I had no code compile issues.

I did at least grudgingly come to the conclusion that this method of code management was not as horrible as I thought it was.

So OP, what am I missing, I see no issue, and the solution seems overly complex. I am sure I am missing something here.

What you really got to do is to copy the ' jumbled ' code you wrote in one single INO file into a plain text file.

This makes no sense to me. You can freely copy/paste from one IDE tab to another with no need to use an intermediate editor. What extension have you used for the files in the other IDE tabs ?

Please post a simple program that demonstrates the problem

Romonaga:
OP I am not sure what you are trying to solve. I do not personally break my code up into different .ino files. I prefer to mange code with classes.

Classes or no classes, it's still a good idea to break large programs into multiple file. But, IMO, the Arduino-recommend technique of using multiple .ino files is useless. At build time, everything gets crammed into a single file and is compiled as a unit. The technique I prefer is described in Reply #3 Here.

gfvalvo:
Classes or no classes, it's still a good idea to break large programs into multiple file. But, IMO, the Arduino-recommend technique of using multiple .ino files is useless. At build time, everything gets crammed into a single file and is compiled as a unit. The technique I prefer is described in Reply #3 Here.

I agree, this is what I meant by classes. I prefer to use conventional methods of breaking up complex code. not to mention creating libraries of common functionality allows for faster development.

However, while many of us do not like the tabbed system, it does allow new developers a simpler way of managing code, without the complexity of header files and cpp files. While, it is best to rip the band-aid off, and get new developers to learn proper code management, I understand the choice that was made here.

It is a free IDE, it is geared to hobby developers, for the target audience, for some of us, other solutions do exist.

@ Romonaga
Thank you for your time and posting your feedback.
If you search the forum for ' using tab in IDE ' you will find quite a few
complaining of the compile errors. I also note that you had no errors showing up
when you copied and pasted function() into a tab format. Basically, I put up the posting
for those who had the issue with tab compiling error with a thought it may help.

@UKHeliBob : What extension have you used for the files in the other IDE tabs ?
They are all INO files. I am posting 2 identical programs, one which works and the
other which generates compile errors.

@gfvalvo :
Note what you write and did give a read to what you linked up as well. Don't you think it
gets a little hard at the beginner level to understand. For that matter, I am just a year old
into Arduino as well and with what little I have learnt thought may help fellow developers.

I must mention that it is purely a personal preference in using tab and respect others who use
an alternate method and learn from them. TQ.

I am attaching to identical programs of which one will compile without errors and the other will
come up with errors. Sorry, I had to put it up as zip files to avoid confusion.

The not_working file is the one I copied functions() from within IDE main prog.
The _working file is the one I exported to NP++ and pasted back onto IDE tab.

The errors that showed up at compile time:

C:\Users\WELCOME\Desktop\WV Sketches\BIG_7_seg_4_modules_Clock_DS3231_DHT11_TSOP_with_buzzer_02.ino\BIG_7_seg_4_modules_Clock_DS3231_DHT11_TSOP_with_buzzer_02.ino.ino: In function 'void loop()':

BIG_7_seg_4_modules_Clock_DS3231_DHT11_TSOP_with_buzzer_02.ino:158:12: error: 'doblinks' was not declared in this scope

doblinks();

^
BIG_7_seg_4_modules_Clock_DS3231_DHT11_TSOP_with_buzzer_02.ino:160:14: error: 'datedisp' was not declared in this scope

datedisp();

^
BIG_7_seg_4_modules_Clock_DS3231_DHT11_TSOP_with_buzzer_02.ino:161:15: error: 'dayofweek' was not declared in this scope

dayofweek();

^
C:\Users\WELCOME\Desktop\WV Sketches\BIG_7_seg_4_modules_Clock_DS3231_DHT11_TSOP_with_buzzer_02.ino\datedisp.ino: In function 'void ReadDS3231()':

datedisp:2:16: error: a function-definition is not allowed here before '{' token

void datedisp(){

^
dayofweek:1:17: error: a function-definition is not allowed here before '{' token

void dayofweek(){

^
dotemp:38:1: error: expected '}' at end of input

}

^
exit status 1
'doblinks' was not declared in this scope

4_Module_Clock_Tabs_NOT_WORKING.zip (6.71 KB)

4_module_clock_with_tabs_working.zip (5.96 KB)

wvijay:
@gfvalvo :
Note what you write and did give a read to what you linked up as well. Don't you think it
gets a little hard at the beginner level to understand.

If you ask specific questions about what you don't understand, I'd be happy to explain further.

gfvalvo:
If you ask specific questions about what you don't understand, I'd be happy to explain further.

gfvalvo:
If you ask specific questions about what you don't understand, I'd be happy to explain further.

Tq.

Regards