Adding files: Change of behavior, bug or me being dumb?

In arduino 1, if i chose "add file" it made a copy of the file in my project folder, created a new tab with the name of the file and the tab was populated with the file i imported. In arduino 2, adding a file now copies it to my folder but no longer creates the tab with name and populates it. Is this a bug or a new way of doing things or do i have a setting wrong in the new ide?

my version of arduino 1 is: 1.8.9 (intel macos)

my version of arduino 2 is: Version: 2.0.3 (arm64 macos)
Date: 2022-12-07T10:26:21.564Z
CLI Version: 0.29.0 [76251df9]

This is a similar issue from years ago but the issue is closed and I couldn't understand whether it was describing the same issue as mine:

What is the exact name of the file that you are adding ?

i was trying to add images and fonts. pongy.c, FreeSas50pt.h, Arvo_Bold90pt.h. I was opening hte old arduino, adding the files, then going back into arduino 2 in order to use them.

After you added the files did you look in the sketch folder and note that they are added to a folder named data rather than the sketch folder ?

Thanks for bringing this to our attention @nandydean.

I remember that when the Sketch > Add File... capability was added to Arduino IDE 2.x, it was specified as a way to add supplemental files (e.g., documentation) to the data subfolder of the sketch. I never used this feature in Arduino IDE 1.x, but now that I try it out, I see the behavior is more complex than what was specified for the Arduino IDE 2.x developer to implement:

  • If the selected file has a supported sketch code file extension (.ino, .h, .cpp, .c, .S), add it to the the root of the sketch folder.
  • If the selected file has any other file extension, add it to the data subfolder of the sketch.

We already had a feature request for being able to add existing code files to a sketch, so I added this information there:

For now, you will need to add the files to the sketch externally. I see you are already doing that using Arduino IDE 1.x. An alternative approach would be to add the files to the sketch using your file manager software (e.g., Windows "File Explorer"). You can open the sketch folder in the file manager by selecting Sketch > Open Sketch Folder from the Arduino IDE 2.x menus.

If you open a sketch in 2.0.3, then click on the three dots on the far right end of the tabs line, there is a menu choice "New Tab".
Select that and you get a prompt for a name. After putting that in, you get a new, empty tab you can type into, or paste into, that will become part of your sketch.
This is not as straightforward as "adding a file" but that is what it does if you want one from scratch. To include an existing file into a sketch, I use the file manager and drop it into my sketch folder.

  • Wes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.