VSCode cpp: How to split source code in specific files?

Hello all. I’m pretty new to VSCode and PlatformIO.

In Arduino IDE I’m used to split my code among files according to their purpose in the whole application. This way they appear in separate tabs and makes troubleshooting much easier. For example, I’d use “main.ino”, “WebServer.ino”, “Calculations.ino”, “IOs.ino” and so on.

I’ve tried to do the same in VSCode/PlatformIO and I’ve got a lot of compiling errors. Please find them in attached picture.

Is there somehow to split the source code in separate files?

Thank you.
Regards, Ciro.

Please post code as code, not as screenshots. Same with error messages as text. If we can’t get a complete picture of the code it’s very hard to say what’s going on. All that error says is that you’re trying to use the index_html variable which hasn’t been previously declared. If you have shared variables (and functions) between main.cpp and WebServer.cpp, then create a header file (usually one for each .cpp file) where you declare these, then include them in the .cpp file. This is detailed in multiple topics in this forum, see e.g. Tutorial for creating multi cpp file arduino project - #36 by NormanDunbar.

It’s good to know how much Arduino IDE does to make our life easier.
It works like writing the next chapter from the next page. It makes sense, doesn’t it?
It makes it very quick and clear to find what you need. I can’t see any reason for writing a big one chapter book.