-
Mon 2018.08.20
@Gordon, there is still a bit of apparent confusion here. Although I have a better grasp on these issues, I feel that anyone new to this environment would have a heck of a time understanding what is going on. As did @allObjects also pointed out in #8. I only mention the following as it is likely that they might go down the same path.
re: 'it's a constant struggle to provide users with enough information to get started without overloading them'
Yes, agree totally. It is a very complex topic to handle all situations for each possible type of users development environment. No complaints
from me. The documentation is rather complete and easy to understand.re: 'You can save the state of Espruino so this doesn't happen using the save() command'
From #6 I originally asked:
'In general why would code execute during a upload/copy process?'
The response was the http://www.espruino.com/Saving link. On that page,
'it's easy to save your code to flash memory and make it permanent'
So, as I read that, those concepts are on how to 'save' and use of the 'save'()' command. But the thought process is on the 'uploading' task.
And, I'm stuck in that task at the moment. This is not the act of saving which is a task that is done to preserve commands once working. I was in the process of attempting to get code sent to the Pico to get it running, not commands to save code that hadn't yet been written. Big difference.Incidentally adding will help
'I'll add a keyword for 'upload/uploading'
When the response from #6 was received, it didn't make sense to read on with the second sentence indicating to save code.
'it's easy to save your code to flash memory and make it permanent'
Even after reading the 'Saving' page, still haven't found what I need to know about the original question posed:
'In general why would code execute during a upload/copy process?'
This is why @allObjects also agreed and posted his observations in #8
'Why' has been explained in #6 and #8 no need to re-hash.
It's there - a
(more information)
link afterYou can save the state of Espruino so this doesn't happen using the save() command
on http://www.espruino.com/Quick+Start+Code (which is where you'd go after you followed the USB/BLE Quick Start to get connected). It's also linked from the FAQ and Troubleshooting.I'll add a keyword for 'upload/uploading'. I'm open to suggestions for extra places to link it, although there's a huge amount of information on the Espruino site, and it's a constant struggle to provide users with enough information to get started without overloading them to the point where 90% of them don't read anything.
@allObjects I know what you mean about
Saving
perhaps not properly explaining everything - again, I'm open to contributions.Could you post up the code that appears?
Your question about flashing to format all saved code is a little more involved than 'yes' on some devices, but on the Pico&WiFi it's not. If you reflash the Pico using the IDE and it completes successfully, it will erase all code. I can guarantee that.
So if it isn't erased then either the flashing hasn't worked, or code got uploaded since you did the flashing.
On Espruino 1v99 and later, just type
reset(true)
and it'll remove all saved code though - it's quicker and easier :)As @Wilberforce says - global scope is probably a more general term here.
I think JavaScript in a webpage is a good example here - If you write:
On a webpage, that's going to make the webpage take a very long time to load enough to show
Some more text
, and probably the browser will report an error after a while. That's running in what we're calling level 0 or the global scope here.If you upload:
Then that's merely defining a function containing the code. The
for
loop isn't in the global scope, butfunction iWillTakeALongTime() { ... }
is. The statementfunction iWillTakeALongTime() { ... }
is still being executed, but the result of executing that statement is that a function callediWillTakeALongTime
is loaded into memory, not that thefor
loop gets executed.