Adding a new file in WebIDE

So I use the + icon to open a new file, name it widget.h and I also get a widget.cpp.
When I cut some code and paste it into the .h file it also gets pasted into the .cpp.

Is this expected? I would expect the .cpp to remain blank.

HI @rowifi -

I just want to make sure I understand correctly, are you building a new sketch from scratch correct, by copying and pasting come exits code? If this is the case, the IDE should open up with only setup() and loop().

From here you can simply name the “app” you are creating, I assume widget based on your message above.

Do you need top create the .h and .cpp file? or simply .ino? I just did a test, I get the same result when indeed creating .cpp and .h files as well. Seems to be normal behaviour then.

I found you have to click on the .ino first after creating the file. Then select the.h or .cpp, then paste.

Hi

To be honest - I’m having a number of weird problems.
Having successfully copied a project that uses a library 'pubsubclient which worked.

  • I then imported another well used library ’ SerialBufferRK’ but then the compiler claimed it couldnt find the header file - even though all I did was import the library and the dashboard showed it correctly.
    I gave up and decided to cut and paste all the library files into my project one by one which is where I came across the strange editing behaviour of a pasted file going into both the .h and the .cpp.
    Laborious, but now it compiles.
    So aside from the confusion about pasting - I’m confused why adding a library gave the header not found error.

Shane, it’s not the first time I’ve played with particle, but it was a long time ago. I like to think I’m not dim, but there seem to many weird behaviours. I’m using the Web IDE

Mmm I use the WebIDE for quick stuff and tests. I have installed workbench and after a learning curve I am much happier now. Definitely worth the investment in time and you can still flash via the cloud. The features I use the most are autocomplete and intellisense

1 Like

HI @rowifi -

I am by no means an expert, and you will probably get some really cleaver advice from guys like @shanevanj, but to be honest, have not had much success with custom libraries and WebIDE.

I had a similar issue a while back which I resolved using Particle workbench (Visual Studio Code extension) and the CLI instead.

Installing a custom library using the CLI is seamless!! Apologies if I ask trivial questions but I’d rather be thorough and make sure I understand the problem :slight_smile:

EDIT – Agree with @shanevanj

OK. Thanks for the info. I have tried workbench years ago, so may revert to that.

This is not expected but a known quirk.
I just hit Ctrl+A and Del followed by Ctrl+S to get rid of the duplicate. Or if the .cpp is not needed, just X it away.

Your issue with the "not found" header file is also such a quirk. Sometimes it's enough to just change #include "some.h" to #include <some.h> or the other way round to make Web IDE realise that the file is there after all.

Not nice but once you get used to these quirks Web IDE can be useful for smaller projects.

1 Like

Hi @rowifi -

I will agree with @ScruffR. If the duplicate text in the .cpp file is the only problem that can be solved by:

, I would be happy to continue using WebIDE. For most of my projects I use WebIDE, but full disclosure, they might not be nearly as complex as some projects in this forum. To me it is 'easier to use' :slight_smile:

I have used WebIDE for this project, which was my most complex one to date. The only hurdle I ran into was I was unable to get a particular custom library to function. I would pin this rather on me not being able to get it to work as apposed to a WebIDE problem.

Having said this, I managed to add this particular library using Workbench and CLI in a couple of seconds. I recon there is scope for both, depending on your need.

Best of luck!!

2 Likes