if statement #183
Replies: 6 comments
-
Posted at 2013-12-13 by @gfwilliams I just tried this, and it worked. End result was:
Which version of Espruino were you using? the one from the website, espruino-nightly, or your own build? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2013-12-13 by StuntMonkeh I get the same but I expected it to re-evaluate the if statement if I typed in var a = 20 in the active command line i.e. the black screen on the left using the Chrome app. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2013-12-13 by @gfwilliams The command-line still evaluates everything in order, as you type it... The if statement won't evaluate again unless you tell it to. You could do something like:
And now, that code will keep being called every 100ms so if you write |
Beta Was this translation helpful? Give feedback.
-
Posted at 2013-12-13 by StuntMonkeh Okay, I would ideally like parts of code to execute when values change rather than on a timed basis. I'm sure I had it working earlier... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2013-12-13 by @gfwilliams I'm afraid that's just not how JavaScript works. You could probably implement something with callbacks, but JavaScript wouldn't normally work like that. There's an online 'command prompt' type example here that uses your Web Browser's JS engine: http://www.jsconsole.com/ It's an easy way to see what kind of things it can do. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2013-12-13 by StuntMonkeh Its weird because I'm absolutely sure I had something working before stupidly forgot to save my work. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2013-12-13 by StuntMonkeh
Can someone explain why the following if statement does not execute when I change the variable 'a' in the active command line?
I'm sure I had it working at some point but I forgot to save what I was doing!!!
Beta Was this translation helpful? Give feedback.
All reactions