But therein lies the problem. How to get at the block (#438) that contains what we are after when we only have reference to the String name (#428) that is the actual text identifying it's function.
trace("dl") will locate it's referenced block #438, but I need what #438 points to, that is it's content, in this case block #428 the function itself, during runtime.
In our cleaned up version, it is block #438 after locating #428
Attempting to iterate using the entries method is fraught with errors:
>for (let [key, value] of Object.entries(aaa)) {
: console.log(`${key}: ${value}`);
:}
Uncaught SyntaxError: Got '[' expected ';'
at line 1 col 10
for (let [key, value] of Object.entries(aaa)) {
^
for ( let key of Object.entries(aaa)) {
}
Uncaught Error: Function "entries" not found!
at line 1 col 25
for ( let key of Object.entries(aaa)) {
global.forEach(element => console.log(element));
Uncaught Error: Function "forEach" not found!
at line 1 col 8
global.forEach(element => console.log(element));
^
Although I was able to iterate over the history array using just indexers into the array, the rest has become the big surprise, and not what I thought I could get done.
For the curious onlookers:
Please heed the code file internal Warning and read everything before uploading
WARNING - Not for beginners or the impatient. Intended for individuals with intermediate to advanced skills. Will lock up the device it is installed on.
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.
Part 2
But therein lies the problem. How to get at the block (#438) that contains what we are after when we only have reference to the String name (#428) that is the actual text identifying it's function.
trace("dl")
will locate it's referenced block #438, but I need what #438 points to, that is it's content, in this case block #428 the function itself, during runtime.In our cleaned up version, it is block #438 after locating #428
Using:
I learned that the global variable is just a Javascript Object after:
then creating an array that I can manipulate and assigning the contents of the global variable to the array object just created:
Using properties of that object, I am able to extract the data for a var I defined:
That checks out and as expected.
Attempting to iterate using the entries method is fraught with errors:
Although I was able to iterate over the history array using just indexers into the array, the rest has become the big surprise, and not what I thought I could get done.
For the curious onlookers:
Please heed the code file internal Warning and read everything before uploading
WARNING
- Not for beginners or the impatient. Intended for individuals with intermediate to advanced skills. Will lock up the device it is installed on.Better yet, beginners please don't upload at all!
2 Attachments