Go Down

Topic: Impossible to load last sketch at startup (Read 487 times) previous topic - next topic

PHP-IP

Hi,
since few versions of Arduino IDE the software don't load the last sketch edited if I close the software using the X button case at the top right of the windows. The last sketch is only reloaded automaticaly if I use the "Quit" option in the File menu.
I don't have this before, I have try to search on the web but I don't find anything about that :(

I f I use the X case to close the software, in preferences.txt the line last.sketch.count= switch to 0 and the last sketch don't load the next time. If I use the Quit option on the file menu then the line is last.sketch.count=1 and the last sketch load automaticaly.


An idea ?

pert

I also have noticed this and it was previously reported at:
http://forum.arduino.cc/index.php?topic=443558.msg3975428#msg3975428
I also think there is a related report here:
http://forum.arduino.cc/index.php?topic=443558.msg3975314#msg3975314

I've been meaning to submit a bug report for this but have been too busy to take a closer look at the issue. If anyone wants to report it, I'm sure that would be appreciated. Otherwise, I'll get to it as soon as work slows down for me after Christmas.

I've never been overly attached to the "open last sketch" behavior so this change doesn't bother me much. However, I do think that changes to the IDE's behavior should be intentional, rather than accidental. The other report might indicate that there is a more general problem with saving preferences and that is certainly of concern.

pert

While I was lagging on filing an issue report, someone else did it, and one of the Arduino developers has written a proposed fix for it:
https://github.com/arduino/Arduino/pull/8349
Test builds are available at the link above if you want to try it out.

Thanks for reporting the bug!

james1095

I've always found the auto-loading of the last used sketch to be extremely annoying and found this while looking for a way to disable it. Since I normally leave the software open until I'm finished and then when I load it I want it to open up with a new blank sketch. Is it possible to change the default behavior? The Arduino has done a lot of great things but man the software is awful.

pert

when I load it I want it to open up with a new blank sketch.
You can accomplish something like this by creating a shortcut that you use to start the Arduino IDE and adding the path to the blank sketch you want to load on startup. Something like this:
Code: [Select]
E:\ProgramFiles\ArduinoIDE\arduino-nightly\arduino.exe E:\ProgramFiles\ArduinoIDE\arduino-nightly\examples\01.Basics\BareMinimum\BareMinimum.ino
Or if you have .ino files associated with the Arduino IDE, you could just make a shortcut to the .ino file you want.

If you truly wanted a new blank sketch, you could make a script that first runs the command:
Code: [Select]
arduino --pref last.sketch0.path= --save-prefs
That will make it so the IDE forgets the last opened sketch an so falls back to the default behavior of opening a new sketch. Then runs the command to start the Arduino IDE:
Code: [Select]
arduino

The tricky thing is that the first command takes a ridiculously long time to finish and the preference is only saved after that is done. So you need to make sure your script only runs the second command once the first one is done. You might expect that to happen as a matter of course, but it's not so. A Windows batch file would look like this:
Code: [Select]
arduino --pref last.sketch0.path= --save-prefs | more
arduino

I couldn't figure out how to do something similar with a shell script so I resorted to a fixed delay:
Code: [Select]
./arduino.exe --pref last.sketch0.path= --save-prefs
sleep 10s
./arduino.exe

You can adjust the delay to a suitable length for your system. I'm certain there is a better way.

sterretje

Just like James, I find the behaviour highly annoying. There is a big risk for me that I edit something that I don't want to edit.

Looking at pert's reply #4, I assume that there is no way to modify this in preferences.txt?
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

pert

There's no way to permanently modify the behavior by editing preferences.txt one time. The first command in the scripts I shared are actually editing preferences.txt by clearing the value of the last.sketch0.path property, but the Arduino IDE automatically fills that property every time you exit the IDE so it needs to be done every time before you start the IDE again.

Go Up