Syntax problem

I am probably doing something wrong, but getting a syntax error on a very simple piece of code - see attached screen capture. I literally cut and pasted this from the Agent Guide example and can’t seem to get past this error. I tried entering a hard return after every line and used both Firefox and Chrome.
I am certain I will be embarrassed when someone points out my mistake, but at this point, it will be worth it.

Not sure. Can’t see under the popup :slight_smile: (posting the text is a bit better than a screen image)

I guessed the rest of the code and this seems to compile cleanly for me:

http.onrequest(function(request, res){ if (request.body == "0") { device.send("power", 0); } else if (request.body == "1") { device.send("power", 1); } res.send(200, "okay"); });

OK, your code (cut and pasted into the IDE) works OK. Yet when I cut and paste the following code it fails:

http.onrequest(function(request,res){
if (request.body == “0”){
device.send(“power”,0);
} else if (request.body == “1”){
device.send(“power”, 1);
}
res.send(200, “okay”);
});

strange…

Is it the quotes?

No, I replaced them by entering them from the keyboard and I still get the error.

Please do me a favor and open the “AgentGuide.pdf” and try cutting and pasting the exact same code from page 3 (about the middle of the page.) into the IDE and see if you get the error.

Looks identical to me… quotes should be ok, they look ok in your screenshot…

Figured it out - it’s the semicolons. Visually, they look the same, but somehow trip up the IDE. After pasting in the example from the PDF I get the error. If I go in and overtype the “;” with the keyboard, it compiles OK.

Interesting…

I had the same problem with pasting code from PDF to the Arduino IDE…

That’s really strange! Now I’m going to have to cut and paste those semicolons and see what they actually are… maybe some strange unicode thing!

Thanks, not a big deal, but hopefully this will save someone else some time when working through the examples.

Copy-paste from PDF is a potential can of worms. My guess is that the creator of PDF has used one of the variants of a semicolon. Or even the Greek question mark, which (…drumroll…) looks just like a semicolon. See this fancy page for more info.