@Gordon: Thanks for you quick reply. I was out-of-the-office for a bit, hence this delayed response.
Per you request, I updated the espruino package to ver 0.1.14, and experienced mixed results.
GREAT: I can now require more than one module. Previously a rogue "d" was prefixed to the "Modules" reference generating the following run-time error. However this has been fixed with the 0.1.14 release ... I no longer receive this error:
Uncaught ReferenceError: "dModules" is not defined
at line 1 col 10
dModules.addCached("TestMod3","print('expanding TestMod3.js...
PROBLEM: I still am not able to place an else clause on a second line when the code is expended in-line. Here is the run-time error:
Uncaught SyntaxError: Got else expected EOF
at line 2 col 1
else {
^
Log output of send (with debug enabled): see attached: sendOutput.log
Here are some points of interest and/or questions:
Why is it that I do not experience this problem with the IDE? I was under the impression that this was the same code.
It appears to me that the "else on a subsequent line" is only a problem for code expanded in-line. I do not experience this issue when the code is contained in a function definition.
Does this make sense?
I can work around this issue by placing my in-line code in an IIFE:
(function () {
... my in-line code here
})();
Evidently espruino does not have to do anything special in regard to cr/lf for code contained with function definitions.
Would it make sense for espruino to wrap any code it is sending to the board in an IIFE, rather that attempting to identify/react to special cases like this?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
@Gordon: Thanks for you quick reply. I was out-of-the-office for a bit, hence this delayed response.
Per you request, I updated the espruino package to
ver 0.1.14
, and experienced mixed results.GREAT: I can now require more than one module. Previously a rogue "d" was prefixed to the "Modules" reference generating the following run-time error. However this has been fixed with the 0.1.14 release ... I no longer receive this error:
PROBLEM: I still am not able to place an else clause on a second line when the code is expended in-line. Here is the run-time error:
My full code can be found here:
espruino -j tooling/mcu/jobSandbox1.json --port COM6
Here are some points of interest and/or questions:
Why is it that I do not experience this problem with the IDE? I was under the impression that this was the same code.
It appears to me that the "else on a subsequent line" is only a problem for code expanded in-line. I do not experience this issue when the code is contained in a function definition.
Does this make sense?
I can work around this issue by placing my in-line code in an IIFE:
Evidently espruino does not have to do anything special in regard to cr/lf for code contained with function definitions.
Would it make sense for espruino to wrap any code it is sending to the board in an IIFE, rather that attempting to identify/react to special cases like this?
Your help is greatly appreciated.
Kevin>
1 Attachment