-
Sat 2018.09.08
re: 'I'm not sure about the context and intentions...'
Thanks for the quick response @allObjects and I'm reviewing the additional links now.
Just trying to test a simple module with cut-n-paste into the editor window right-pane. Following the instructions at Writing+Modules, wrapping the code in
var exports={};
statements. Basically a getter accessor method to attach to, such asled.testUR();
I stripped out all non-essential lines and have it down to the fifteen lines above. Just performing a send creates the error. Simple concepts taken from and modeled after:
http://www.espruino.com/modules/GroveRelay.js
http://www.espruino.com/modules/MySensors.js
http://www.espruino.com/modules/Ping.jsAt this point, I'm just trying to get something, . . . anything to work.
re: 'this is resolved at runtime and means the context'
For clarification for me, technically, as the code has just been sent to the device, isn't it actually running, and therefore we see what I presented above, typing 'this' into the left-hand pane console? My point is, the IDE is aware of the function, otherwise it couldn't possibly know about it otherwise in order to produce the error.
Are you trying this all in the console?
this
is resolved at runtime and means the context.exports
is known from outside of the module when it is uploaded into theModules
cache, because there it is executed... (again, think of 'there is no static code' after Espruino has swallowed the source code...).I'm not sure about the context and intentions... but these conversations may shed some light on what's about with modules in addition to: espruino.com/Writing+Modules: