-
Tue 2019.03.26
cont from #7 @Gordon
'@Robin can you point to one? Every issue I've seen thus far '
Attempting to reference a post before a link
The # symbol is ommited and text size changes
Another is attempting to *bold text inside an italicized sentence* or visa versa
Note the extra stars and lack of desired formatting
The Markdown parser?@allObjects had a lengthy code block within the last six weeks, where efforts were abandoned and mixed format was used in frustration, just unable to locate right now.
@Robin can you point to one? Every issue I've seen thus far (apart from hashes inside code) has been an issue with the formatting of the text the post. If you haven't used it before it can take a while to get the hang of.
I just checked this post, and there are three backticks before your code, but not after it as well (I guess you might have pasted over them by accident?). I just edited it to add them and it's fine now.
Anyway - back to the question :)
What you're doing in
sendCap
with the nesting looks fine to me. I'll check it out here and get back to you - it's possible you need a delay as the host computer may not be expecting to be getting keypresses sent so quickly.But the other main issue you have (why
sendNewTest
doesn't work) is:This is an issue if you're new to JavaScript. Basically it can take a while to send a keypress (if you're in a low power mode it might be half a second). Rather than stop you running any other code during that time, Espruino executes the function right away and goes on to execute what's right after. When the keypress is finally sent, it calls the callback function - and it's in that function that you need to send the next keypress - hence the nesting.
There are ways to get around that - for instance calling the same function over and over, taking characters off a string of characters to send - or you can use 'Promises' (a standard JS thing - google it for some good tutorials) to avoid the nesting as well.